C++ Header Library Designed for formatting number +/- error;
- C++11 (either clang++ or g++)
- Boost (test, math, system, lexical_cast, multiprecision)
- cmake
- ccache (Optional - only if you want to build using it)
- libmpfr-dev
A stable version of clang++
is available llvm-apt;
To build the library,
mkdir build
cd build
Then run of the following commands:
CC="gcc" CXX="g++" cmake ../ -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=None
CC="ccache gcc" CXX="ccache g++" cmake ../ -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=None
CC="ccache clang" CXX="ccache clang++" cmake ../ -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=None
None
can be replaced with one the following: Debug, Release, RelWithDebInfo, MinSizeRel, Coverage;
make all && make test
will build and run the unit tests;
- lcov
- gcov
- genhtml
- gcovr
make all && make test && make all_coverage
Use None, Debug, or Coverage build modes;
<browser> results/index.html
view the coverage report;
The basic rule:
a. If the three highest order digits of the error lie between 100 and 354 round to two significant digits.
b. If the three highest order digits of the error lie between 355 and 949 round to one significant digit.
c.If the three highest order digits of the error lie between 950 and 999 round up to 1000 and keep two significant digits.
In all cases the central value is given with a precision that matches that of the error.
####For example, ####|central value| < |error|
0.827 ± 0.119
→0.83 ± 0.12
0.827 ± 0.367
→0.8 ± 0.4
1.827 ± 0.967
→1.8 ± 1.0
####|central value| < |error|
0.0119 ± 0.122
→0.01 ± 0.12
0.0119 ± 0.827
→0.0 ± 0.8
0.0367 ± 0.977
→0.0 ± 1.0
Rounding is not performed if a result comes from a single measurement (without any averaging). In that case, the number of digits published in the original paper is kept (unless we [PDG] feel it inappropriate).
The basic rule:
- |central value| > |error|; then the precision on the error is two significant digits, the precision on the central value matches that of the error.
- |central value| < |error|; then the precision on the central value is two significant digits, the precision on the error matches that of the central value.
The precision is two significant digits on the lesser significant value and the other value has precision that matches that of the lesser significant value.
For example,
0.827 ± 0.119
→0.83 ± 0.12
0.827 ± 0.367
→0.83 ± 0.37
0.827 ± 0.0119
→0.827 ± 0.012
0.827 ± 0.0367
→0.827 ± 0.037
0.0119 ± 0.827
→0.012 ± 0.827
0.0367 ± 0.827
→0.037 ± 0.827
The basic rule: If given n (n ≥ 1) decimal values; say x₁,...,xₙ these values can be decimal point aligned.
- currently using precision of 2 when (∀ l | xₗ > 1.0);
- precision is fixed to be 1 more than the least signficant (∃ l | xₗ < 1.0 )
- in other words if one of the value is in the range (-1,1);
For example,
1459.210
2.110
-0.020
or
0.0125
0.0022
0.0059
Uses Terminal Aligning, but then replaces ' ' with '~'; then encapsulates the
entire string within \ensuremath{}
.
- Can use
+/-
,±
- Better Example
- Latex Aligning
- Terminal Aligning
- Changing locale breaks tests (because imbuing a gloabl locale changes number formatting)
- Added an executable:
format_error --pdg central_value error
;format_error --pdg --latex central_value error
;format_error --simple central_value error_1 error_2
;format_error --utf ...
;format_error --latex --name=...
- Add additional tests;
- Need to fix a problem related to not having an /etc/ld.so.conf.d config file (and then re-running ldconfig)
- static libraries work; adding to the link command
/usr/lib/numeric_error_format/libpdg.a
If you install the package using the DEB. To use the code you'd do something like:
#include "numeric_error_format/symmetric_error.hpp"
to_fixed_string<double>(x.yzabc,3);//[std::string] x.yza
g++ -std=c++11 <your_code>.cpp -L/usr/lib/numeric_error_format -lpdg -lsymmetric
Doesn't work yet
g++ -std=c++11 <your_code>.cpp /usr/lib/numeric_error_format/libsymmetric.a
** DOES WORK**