diff options
author | David Wagner <david.wagner@intel.com> | 2014-03-11 14:20:53 +0100 |
---|---|---|
committer | Mattijs Korpershoek <mattijsx.korpershoek@intel.com> | 2014-06-25 10:52:26 +0200 |
commit | 59cc1e33810c55e6fa1e3bd320e1cf29e24d23be (patch) | |
tree | 632b95d1026ff684b3b37627a17db2922c0f74e7 /parameter/BitParameterBlock.cpp | |
parent | 8ef87a1fe5d2f05557856efa6faf070bb9b03337 (diff) | |
download | external_parameter-framework-59cc1e33810c55e6fa1e3bd320e1cf29e24d23be.zip external_parameter-framework-59cc1e33810c55e6fa1e3bd320e1cf29e24d23be.tar.gz external_parameter-framework-59cc1e33810c55e6fa1e3bd320e1cf29e24d23be.tar.bz2 |
Correct FixedPointParameter display precision
BZ: 176178
Explain the precision computation (m * log10(2)):
For a Qn.m number, the step between each storable number is 2^(-m).
Hence, on a decimal representation, the Dth digit after the decimal
point can take all possible values (1..9) - meaning that it is
significant - only if
2^(-m) <= 10^(-D)
-m <= log2(10^(-D))
-m <= log10(10^(-D)) / log10(2)
-m <= -D / log10(2)
m * log10(2) >= D
Conversly, the Dth digit can be represented if
D <= m * log10(2)
We add 1 to the precision in order to display the digit right after the last
significant digit. This will lead to oddities such as:
$ setParameter /Test/test/f32_Q8.23 0.1234569
$ getParameter /Test/test/f32_Q8.23
> 0.1234570
but it will avoid modifying raw values when converting from string to Q-format
and back to string.
Also, use std::setprecision() on the stream instead of manually truncating the
displayed number.
Change-Id: Ief2a7daabf4505ae4312e79036b0374f53368cac
Signed-off-by: David Wagner <david.wagner@intel.com>
Diffstat (limited to 'parameter/BitParameterBlock.cpp')
0 files changed, 0 insertions, 0 deletions