Update of /cvsroot/boost-sandbox/boost-sandbox/boost/units
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv2560
Modified Files:
measurement.hpp
Log Message:
need to fix to emulate NIST CODATA formatting...
Index: measurement.hpp
===================================================================
RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/measurement.hpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- measurement.hpp 4 Apr 2007 20:04:25 -0000 1.10
+++ measurement.hpp 4 Apr 2007 21:18:04 -0000 1.11
@@ -316,20 +316,33 @@
boost::io::ios_width_saver width_saver(os);
boost::io::ios_flags_saver flags_saver(os);
- os << std::setprecision(13)
- << std::setw(21)
- << std::scientific
- << val.value();
-
+ os << std::setw(21);
+
if (val.uncertainty() > Y(0))
+ {
+ const Y relative_uncertainty = std::abs(val.uncertainty()/val.value());
+
+ const long exponent = std::log10(relative_uncertainty),
+ digits_of_precision = std::ceil(std::abs(exponent))+3;
+
+ // should try to replicate NIST CODATA syntax
+ os << std::setprecision(digits_of_precision)
+ //<< std::setw(digits_of_precision+8)
+ //<< std::scientific
+ << val.value();
+// << long(10*(relative_uncertainty/std::pow(Y(10),Y(exponent))));
+
os << " (rel. unc. = "
<< std::setprecision(1)
<< std::setw(7)
<< std::scientific
- << std::abs(val.uncertainty()/val.value()) << ")";
+ << relative_uncertainty << ")";
+ }
else
- os << " (exact)";
-
+ {
+ os << val.value() << " (exact)";
+ }
+
return os;
}
|