|
From: Matthias S. <mat...@us...> - 2007-04-15 07:09:09
|
Update of /cvsroot/boost-sandbox/boost-sandbox/libs/units/example In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv31090/libs/units/example Modified Files: measurement.hpp unit_example_11.cpp unit_example_17.cpp unit_example_18.cpp unit_example_2.cpp unit_example_3.cpp unit_example_4.cpp unit_example_6.cpp unit_example_7.cpp Log Message: correct example output, remove llrint/llround, add #includes to test_predicates Index: unit_example_3.cpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/libs/units/example/unit_example_3.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- unit_example_3.cpp 16 Mar 2007 18:29:53 -0000 1.1.1.1 +++ unit_example_3.cpp 15 Apr 2007 07:09:03 -0000 1.2 @@ -26,8 +26,8 @@ L*L = 4 m^2 L/L = 1 dimensionless L*meter = 2 m^2 -kilograms*(L/seconds)*(L/seconds) = 4 m^2 kg s^(-2) -kilograms*(L/seconds)^2 = 4 m^2 kg s^(-2) +kilograms*(L/seconds)*(L/seconds) = 4 m^2 kg s^-2 +kilograms*(L/seconds)^2 = 4 m^2 kg s^-2 L^3 = 8 m^3 L^(3/2) = 2.82843 m^(3/2) 2vL = 1.41421 m^(1/2) @@ -41,8 +41,8 @@ L*L = (-7,24) m^2 L/L = (1,0) dimensionless L*meter = (3,4) m^2 -kilograms*(L/seconds)*(L/seconds) = (-7,24) m^2 kg s^(-2) -kilograms*(L/seconds)^2 = (-7,24) m^2 kg s^(-2) +kilograms*(L/seconds)*(L/seconds) = (-7,24) m^2 kg s^-2 +kilograms*(L/seconds)^2 = (-7,24) m^2 kg s^-2 L^3 = (-117,44) m^3 L^(3/2) = (2,11) m^(3/2) 2vL = (2,1) m^(1/2) @@ -119,8 +119,8 @@ << "L*L = 4 m^2" << std::endl << "L/L = 1 dimensionless" << std::endl << "L*meter = 2 m^2" << std::endl - << "kilograms*(L/seconds)*(L/seconds) = 4 m^2 kg s^(-2)" << std::endl - << "kilograms*(L/seconds)^2 = 4 m^2 kg s^(-2)" << std::endl + << "kilograms*(L/seconds)*(L/seconds) = 4 m^2 kg s^-2" << std::endl + << "kilograms*(L/seconds)^2 = 4 m^2 kg s^-2" << std::endl << "L^3 = 8 m^3" << std::endl << "L^(3/2) = 2.82843 m^(3/2)" << std::endl << "2vL = 1.41421 m^(1/2)" << std::endl @@ -132,8 +132,8 @@ << "L*L = (-7,24) m^2" << std::endl << "L/L = (1,0) dimensionless" << std::endl << "L*meter = (3,4) m^2" << std::endl - << "kilograms*(L/seconds)*(L/seconds) = (-7,24) m^2 kg s^(-2)" << std::endl - << "kilograms*(L/seconds)^2 = (-7,24) m^2 kg s^(-2)" << std::endl + << "kilograms*(L/seconds)*(L/seconds) = (-7,24) m^2 kg s^-2" << std::endl + << "kilograms*(L/seconds)^2 = (-7,24) m^2 kg s^-2" << std::endl << "L^3 = (-117,44) m^3" << std::endl << "L^(3/2) = (2,11) m^(3/2)" << std::endl << "2vL = (2,1) m^(1/2)" << std::endl Index: unit_example_7.cpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/libs/units/example/unit_example_7.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- unit_example_7.cpp 5 Apr 2007 00:37:32 -0000 1.2 +++ unit_example_7.cpp 15 Apr 2007 07:09:03 -0000 1.3 @@ -374,7 +374,6 @@ std::stringstream sstream1, sstream2; double zero = 0.0, - inf = std::numeric_limits<double>::infinity(), nan = 0.0/zero; sstream1 << "Using C++ array..." << std::endl << std::endl; Index: unit_example_18.cpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/libs/units/example/unit_example_18.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- unit_example_18.cpp 16 Mar 2007 18:29:52 -0000 1.1.1.1 +++ unit_example_18.cpp 15 Apr 2007 07:09:03 -0000 1.2 @@ -22,13 +22,13 @@ 1.5 m 1 g 1.5 m g -1.5 m g^(-1) +1.5 m g^-1 -1 m kg s^(-2) -1 kg s^(-2) +1 m kg s^-2 +1 kg s^-2 -1 kg s^(-2) cm -1 m^(-1) kg s^(-2) cm +1 kg s^-2 cm +1 m^-1 kg s^-2 cm 0.015 m^2 @@ -80,13 +80,13 @@ sstream2 << "1.5 m" << std::endl << "1 g" << std::endl << "1.5 m g" << std::endl - << "1.5 m g^(-1)" << std::endl + << "1.5 m g^-1" << std::endl << std::endl - << "1 m kg s^(-2)" << std::endl - << "1 kg s^(-2)" << std::endl + << "1 m kg s^-2" << std::endl + << "1 kg s^-2" << std::endl << std::endl - << "1 kg s^(-2) cm" << std::endl - << "1 m^(-1) kg s^(-2) cm" << std::endl + << "1 kg s^-2 cm" << std::endl + << "1 m^-1 kg s^-2 cm" << std::endl << std::endl << "0.015 m^2" << std::endl << std::endl; Index: unit_example_2.cpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/libs/units/example/unit_example_2.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- unit_example_2.cpp 16 Mar 2007 18:29:53 -0000 1.1.1.1 +++ unit_example_2.cpp 15 Apr 2007 07:09:03 -0000 1.2 @@ -25,8 +25,8 @@ L-L = m L/L = dimensionless meter*meter = m^2 -M*(L/T)*(L/T) = m^2 kg s^(-2) -M*(L/T)^2 = m^2 kg s^(-2) +M*(L/T)*(L/T) = m^2 kg s^-2 +M*(L/T)^2 = m^2 kg s^-2 L^3 = m^3 L^(3/2) = m^(3/2) 2vM = kg^(1/2) @@ -74,8 +74,8 @@ << "L-L = m" << std::endl << "L/L = dimensionless" << std::endl << "meter*meter = m^2" << std::endl - << "M*(L/T)*(L/T) = m^2 kg s^(-2)" << std::endl - << "M*(L/T)^2 = m^2 kg s^(-2)" << std::endl + << "M*(L/T)*(L/T) = m^2 kg s^-2" << std::endl + << "M*(L/T)^2 = m^2 kg s^-2" << std::endl << "L^3 = m^3" << std::endl << "L^(3/2) = m^(3/2)" << std::endl << "2vM = kg^(1/2)" << std::endl Index: unit_example_6.cpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/libs/units/example/unit_example_6.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- unit_example_6.cpp 16 Mar 2007 18:29:53 -0000 1.1.1.1 +++ unit_example_6.cpp 15 Apr 2007 07:09:03 -0000 1.2 @@ -25,11 +25,11 @@ L+L = 8 x 10^3 m T+T = 0.2 s L*T = 400 m s -L/T = 40 x 10^3 m s^(-1) +L/T = 40 x 10^3 m s^-1 L*seconds = 4 x 10^3 m s -kilograms*(L/T)*(L/T) = 1.6 x 10^9 m^2 kg s^(-2) -kilograms*(L/T)^2 = 4 x 10^9 m^2 kg s^(-2) -(L/T)^3 = 0.4 x 10^15 m^3 s^(-3) +kilograms*(L/T)*(L/T) = 1.6 x 10^9 m^2 kg s^-2 +kilograms*(L/T)^2 = 4 x 10^9 m^2 kg s^-2 +(L/T)^3 = 0.4 x 10^15 m^3 s^-3 (L/T)^(3/2) = 0.632456 x 10^15 m^(3/2) s^(-3/2) 2v(L/T) = 63.2456 x 10^3 m^(1/2) s^(-1/2) (3/2)v(L/T) = 7.36806 x 10^9 m^(2/3) s^(-2/3) @@ -167,11 +167,11 @@ sstream2 << "L+L = 8 x 10^3 m" << std::endl; sstream2 << "T+T = 0.2 s" << std::endl; sstream2 << "L*T = 400 m s" << std::endl; - sstream2 << "L/T = 40 x 10^3 m s^(-1)" << std::endl; + sstream2 << "L/T = 40 x 10^3 m s^-1" << std::endl; sstream2 << "L*seconds = 4 x 10^3 m s" << std::endl; - sstream2 << "kilograms*(L/T)*(L/T) = 1.6 x 10^9 m^2 kg s^(-2)" << std::endl; - sstream2 << "kilograms*(L/T)^2 = 4 x 10^9 m^2 kg s^(-2)" << std::endl; - sstream2 << "(L/T)^3 = 0.4 x 10^15 m^3 s^(-3)" << std::endl; + sstream2 << "kilograms*(L/T)*(L/T) = 1.6 x 10^9 m^2 kg s^-2" << std::endl; + sstream2 << "kilograms*(L/T)^2 = 4 x 10^9 m^2 kg s^-2" << std::endl; + sstream2 << "(L/T)^3 = 0.4 x 10^15 m^3 s^-3" << std::endl; sstream2 << "(L/T)^(3/2) = 0.632456 x 10^15 m^(3/2) s^(-3/2)" << std::endl; sstream2 << "2v(L/T) = 63.2456 x 10^3 m^(1/2) s^(-1/2)" << std::endl; sstream2 << "(3/2)v(L/T) = 7.36806 x 10^9 m^(2/3) s^(-2/3)" << std::endl; Index: unit_example_4.cpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/libs/units/example/unit_example_4.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- unit_example_4.cpp 13 Apr 2007 01:39:22 -0000 1.10 +++ unit_example_4.cpp 15 Apr 2007 07:09:03 -0000 1.11 @@ -428,47 +428,47 @@ sstream2 << "S1 : 2" << std::endl; sstream2 << "X1 : 2" << std::endl; sstream2 << "X2 : (4/3)" << std::endl; - sstream2 << "U1 : m kg s^(-2)" << std::endl; - sstream2 << "U2 : m^2 kg s^(-2)" << std::endl; - sstream2 << "Q1 : 1 m kg s^(-2)" << std::endl; - sstream2 << "Q2 : 2 m^2 kg s^(-2)" << std::endl; + sstream2 << "U1 : m kg s^-2" << std::endl; + sstream2 << "U2 : m^2 kg s^-2" << std::endl; + sstream2 << "Q1 : 1 m kg s^-2" << std::endl; + sstream2 << "Q2 : 2 m^2 kg s^-2" << std::endl; sstream2 << std::endl; - sstream2 << "U1*S1 : 2 m kg s^(-2)" << std::endl; - sstream2 << "S1*U1 : 2 m kg s^(-2)" << std::endl; - sstream2 << "U1/S1 : 0.5 m kg s^(-2)" << std::endl; - sstream2 << "S1/U1 : 2 m^(-1) kg^(-1) s^2" << std::endl; + sstream2 << "U1*S1 : 2 m kg s^-2" << std::endl; + sstream2 << "S1*U1 : 2 m kg s^-2" << std::endl; + sstream2 << "U1/S1 : 0.5 m kg s^-2" << std::endl; + sstream2 << "S1/U1 : 2 m^-1 kg^-1 s^2" << std::endl; sstream2 << std::endl; - sstream2 << "U1+U1 : m kg s^(-2)" << std::endl; - sstream2 << "U1-U1 : m kg s^(-2)" << std::endl; - sstream2 << "U1*U1 : m^2 kg^2 s^(-4)" << std::endl; + sstream2 << "U1+U1 : m kg s^-2" << std::endl; + sstream2 << "U1-U1 : m kg s^-2" << std::endl; + sstream2 << "U1*U1 : m^2 kg^2 s^-4" << std::endl; sstream2 << "U1/U1 : dimensionless" << std::endl; - sstream2 << "U1*U2 : m^3 kg^2 s^(-4)" << std::endl; - sstream2 << "U1/U2 : m^(-1)" << std::endl; - sstream2 << "U1^X : m^2 kg^2 s^(-4)" << std::endl; - sstream2 << "X1vU1 : m^(1/2) kg^(1/2) s^(-1)" << std::endl; + sstream2 << "U1*U2 : m^3 kg^2 s^-4" << std::endl; + sstream2 << "U1/U2 : m^-1" << std::endl; + sstream2 << "U1^X : m^2 kg^2 s^-4" << std::endl; + sstream2 << "X1vU1 : m^(1/2) kg^(1/2) s^-1" << std::endl; sstream2 << "U1^X2 : m^(4/3) kg^(4/3) s^(-8/3)" << std::endl; sstream2 << "X2vU1 : m^(3/4) kg^(3/4) s^(-3/2)" << std::endl; sstream2 << std::endl; - sstream2 << "Q1*S1 : 2 m kg s^(-2)" << std::endl; - sstream2 << "S1*Q1 : 2 m kg s^(-2)" << std::endl; - sstream2 << "Q1/S1 : 0.5 m kg s^(-2)" << std::endl; - sstream2 << "S1/Q1 : 2 m^(-1) kg^(-1) s^2" << std::endl; + sstream2 << "Q1*S1 : 2 m kg s^-2" << std::endl; + sstream2 << "S1*Q1 : 2 m kg s^-2" << std::endl; + sstream2 << "Q1/S1 : 0.5 m kg s^-2" << std::endl; + sstream2 << "S1/Q1 : 2 m^-1 kg^-1 s^2" << std::endl; sstream2 << std::endl; - sstream2 << "U1*Q1 : 1 m^2 kg^2 s^(-4)" << std::endl; - sstream2 << "Q1*U1 : 1 m^2 kg^2 s^(-4)" << std::endl; + sstream2 << "U1*Q1 : 1 m^2 kg^2 s^-4" << std::endl; + sstream2 << "Q1*U1 : 1 m^2 kg^2 s^-4" << std::endl; sstream2 << "U1/Q1 : 1 dimensionless" << std::endl; sstream2 << "Q1/U1 : 1 dimensionless" << std::endl; sstream2 << std::endl; - sstream2 << "+Q1 : 1 m kg s^(-2)" << std::endl; - sstream2 << "-Q1 : -1 m kg s^(-2)" << std::endl; - sstream2 << "Q1+Q1 : 2 m kg s^(-2)" << std::endl; - sstream2 << "Q1-Q1 : 0 m kg s^(-2)" << std::endl; - sstream2 << "Q1*Q1 : 1 m^2 kg^2 s^(-4)" << std::endl; + sstream2 << "+Q1 : 1 m kg s^-2" << std::endl; + sstream2 << "-Q1 : -1 m kg s^-2" << std::endl; + sstream2 << "Q1+Q1 : 2 m kg s^-2" << std::endl; + sstream2 << "Q1-Q1 : 0 m kg s^-2" << std::endl; + sstream2 << "Q1*Q1 : 1 m^2 kg^2 s^-4" << std::endl; sstream2 << "Q1/Q1 : 1 dimensionless" << std::endl; - sstream2 << "Q1*Q2 : 2 m^3 kg^2 s^(-4)" << std::endl; - sstream2 << "Q1/Q2 : 0.5 m^(-1)" << std::endl; - sstream2 << "Q1^X1 : 1 m^2 kg^2 s^(-4)" << std::endl; - sstream2 << "X1vQ1 : 1 m^(1/2) kg^(1/2) s^(-1)" << std::endl; + sstream2 << "Q1*Q2 : 2 m^3 kg^2 s^-4" << std::endl; + sstream2 << "Q1/Q2 : 0.5 m^-1" << std::endl; + sstream2 << "Q1^X1 : 1 m^2 kg^2 s^-4" << std::endl; + sstream2 << "X1vQ1 : 1 m^(1/2) kg^(1/2) s^-1" << std::endl; sstream2 << "Q1^X2 : 1 m^(4/3) kg^(4/3) s^(-8/3)" << std::endl; sstream2 << "X2vQ1 : 1 m^(3/4) kg^(3/4) s^(-3/2)" << std::endl; sstream2 << std::endl; @@ -481,19 +481,19 @@ sstream2 << std::endl; sstream2 << "dimless = 1" << std::endl; sstream2 << std::endl; - sstream2 << "v1 = 2 m s^(-1)" << std::endl; + sstream2 << "v1 = 2 m s^-1" << std::endl; sstream2 << std::endl; - sstream2 << "F = 1 m kg s^(-2)" << std::endl; + sstream2 << "F = 1 m kg s^-2" << std::endl; sstream2 << "dx = 1 m" << std::endl; - sstream2 << "E = 1 m^2 kg s^(-2)" << std::endl; + sstream2 << "E = 1 m^2 kg s^-2" << std::endl; sstream2 << std::endl; sstream2 << "r = " << 5e-7 << " m" << std::endl; - sstream2 << "P = 101325 m^(-1) kg s^(-2)" << std::endl; + sstream2 << "P = 101325 m^-1 kg s^-2" << std::endl; sstream2 << "V = " << 5.23599e-19 << " m^3" << std::endl; sstream2 << "T = 310 K" << std::endl; sstream2 << "n = " << 2.05835e-17 << " mol" << std::endl; #if BOOST_UNITS_HAS_TYPEOF - sstream2 << "R = 8.314472 (rel. unc. = " << 1.8e-6 << ") m^2 kg s^(-2) K^(-1) mol^(-1)" << std::endl; + sstream2 << "R = 8.314472 (rel. unc. = " << 1.8e-6 << ") m^2 kg s^-2 K^-1 mol^-1" << std::endl; #else sstream2 << "no typeof" << std::endl; #endif // BOOST_UNITS_HAS_TYPEOF @@ -502,17 +502,17 @@ sstream2 << "sin(theta) = " << 0.366273 << " dimensionless" << std::endl; sstream2 << "asin(sin(theta)) = " << 0.375 << " rad" << std::endl; sstream2 << std::endl; - sstream2 << "V = (12.5,0) m^2 kg s^(-3) A^(-1)" << std::endl; + sstream2 << "V = (12.5,0) m^2 kg s^-3 A^-1" << std::endl; sstream2 << "I = (3,4) A" << std::endl; - sstream2 << "Z = (1.5,-2) m^2 kg s^(-3) A^(-2)" << std::endl; - sstream2 << "I*Z = (12.5,0) m^2 kg s^(-3) A^(-1)" << std::endl; + sstream2 << "Z = (1.5,-2) m^2 kg s^-3 A^-2" << std::endl; + sstream2 << "I*Z = (12.5,0) m^2 kg s^-3 A^-1" << std::endl; sstream2 << std::endl; sstream2 << std::scientific << std::setprecision(1); - sstream2 << "x+y-w = 0.48 (rel. unc. = " << 1.3 << ") m" << std::endl; - sstream2 << "w*x = 9.04 (rel. unc. = " << 1.0e-1 << ") m^2" << std::endl; - sstream2 << "x/y = 0.6667 (rel. unc. = " << 2.2e-1 << ") dimensionless" << std::endl; - sstream2 << "w*y^2/(u*x)^2 = 10.17 (rel. unc. = " << 3.5e-1 << ") m^(-1)" << std::endl; - sstream2 << "w/(u*x)^(1/2) = 3.1961 (rel. unc. = " << 5.0e-2 << ") dimensionless" << std::endl; + sstream2 << "x+y-w = 0.48(+/-0.632772) m" << std::endl; + sstream2 << "w*x = 9.04(+/-0.904885) m^2" << std::endl; + sstream2 << "x/y = 0.666667(+/-0.149071) dimensionless" << std::endl; + sstream2 << "w*y^2/(u*x)^2 = 10.17(+/-3.52328) m^-1" << std::endl; + sstream2 << "w/(u*x)^(1/2) = 3.19612(+/-0.160431) dimensionless" << std::endl; sstream2 << std::endl; std::string str1(sstream1.str()); Index: unit_example_11.cpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/libs/units/example/unit_example_11.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- unit_example_11.cpp 5 Apr 2007 00:35:47 -0000 1.2 +++ unit_example_11.cpp 15 Apr 2007 07:09:03 -0000 1.3 @@ -46,8 +46,6 @@ fma(q1,q2,q3) : 16.25 m^2 fpclassify(q1) : 4 hypot(q1,q2) : 2.91548 m -llrint(q1) : 2 m -llround(q1) : 2 m nearbyint(q1) : 2 m nextafter(q1,q2) : 1.5 m nexttoward(q1,q2) : 1.5 m @@ -111,8 +109,6 @@ << "fma(q1,q2,q3) : " << fma BOOST_PREVENT_MACRO_SUBSTITUTION (q1,q2,q3) << std::endl << "fpclassify(q1) : " << fpclassify BOOST_PREVENT_MACRO_SUBSTITUTION (q1) << std::endl << "hypot(q1,q2) : " << hypot BOOST_PREVENT_MACRO_SUBSTITUTION (q1,q2) << std::endl - << "llrint(q1) : " << llrint BOOST_PREVENT_MACRO_SUBSTITUTION (q1) << std::endl - << "llround(q1) : " << llround BOOST_PREVENT_MACRO_SUBSTITUTION (q1) << std::endl << "nearbyint(q1) : " << nearbyint BOOST_PREVENT_MACRO_SUBSTITUTION (q1) << std::endl << "nextafter(q1,q2) : " << nextafter BOOST_PREVENT_MACRO_SUBSTITUTION (q1,q2) << std::endl << "nexttoward(q1,q2) : " << nexttoward BOOST_PREVENT_MACRO_SUBSTITUTION (q1,q2) << std::endl @@ -148,8 +144,6 @@ sstream2 << "fma(q1,q2,q3) : 16.25 m^2" << std::endl; sstream2 << "fpclassify(q1) : "<< fpclassify BOOST_PREVENT_MACRO_SUBSTITUTION (q1) << std::endl; sstream2 << "hypot(q1,q2) : 2.91548 m" << std::endl; - sstream2 << "llrint(q1) : 2 m" << std::endl; - sstream2 << "llround(q1) : 2 m" << std::endl; sstream2 << "nearbyint(q1) : 2 m" << std::endl; sstream2 << "nextafter(q1,q2) : 1.5 m" << std::endl; sstream2 << "nexttoward(q1,q2) : 1.5 m" << std::endl; Index: measurement.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/libs/units/example/measurement.hpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- measurement.hpp 13 Apr 2007 01:38:40 -0000 1.4 +++ measurement.hpp 15 Apr 2007 07:09:03 -0000 1.5 @@ -17,7 +17,7 @@ #include <iostream> #include <boost/io/ios_state.hpp> -#include <boost/numeric/interval.hpp> +//#include <boost/numeric/interval.hpp> #include <boost/units/static_rational.hpp> namespace boost { @@ -40,7 +40,7 @@ public: typedef measurement<Y> this_type; typedef Y value_type; - typedef numeric::interval<value_type> interval_type; +// typedef numeric::interval<value_type> interval_type; measurement(const value_type& val = value_type(), const value_type& err = value_type()) : @@ -72,7 +72,7 @@ value_type lower_bound() const { return value_-uncertainty_; } value_type upper_bound() const { return value_+uncertainty_; } - interval_type get_interval() const { return interval_type(lower_bound(),upper_bound()); } +// interval_type get_interval() const { return interval_type(lower_bound(),upper_bound()); } this_type& operator+=(const value_type& val) { @@ -318,30 +318,32 @@ //os << std::setw(21); - if (val.uncertainty() > Y(0)) - { - const Y relative_uncertainty = std::abs(val.uncertainty()/val.value()); +// if (val.uncertainty() > Y(0)) +// { +// const Y relative_uncertainty = std::abs(val.uncertainty()/val.value()); +// +// const double exponent = std::log10(relative_uncertainty); +// const long digits_of_precision = static_cast<long>(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 +// << relative_uncertainty << ")"; +// } +// else +// { +// os << val.value() << " (exact)"; +// } - const double exponent = std::log10(relative_uncertainty); - const long digits_of_precision = static_cast<long>(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 - << relative_uncertainty << ")"; - } - else - { - os << val.value() << " (exact)"; - } + os << val.value() << "(+/-" << val.uncertainty() << ")"; return os; } Index: unit_example_17.cpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/libs/units/example/unit_example_17.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- unit_example_17.cpp 16 Mar 2007 18:29:52 -0000 1.1.1.1 +++ unit_example_17.cpp 15 Apr 2007 07:09:03 -0000 1.2 @@ -24,8 +24,8 @@ L+L = [L] L-L = [L] L/L = dimensionless -M*(L/T)*(L/T) = [L]^2 [M] [T]^(-2) -M*(L/T)^2 = [L]^2 [M] [T]^(-2) +M*(L/T)*(L/T) = [L]^2 [M] [T]^-2 +M*(L/T)^2 = [L]^2 [M] [T]^-2 L^3 = [L]^3 L^(3/2) = [L]^(3/2) 2vM = [M]^(1/2) @@ -70,8 +70,8 @@ sstream2 << "L+L = [L]" << std::endl; sstream2 << "L-L = [L]" << std::endl; sstream2 << "L/L = dimensionless" << std::endl; - sstream2 << "M*(L/T)*(L/T) = [L]^2 [M] [T]^(-2)" << std::endl; - sstream2 << "M*(L/T)^2 = [L]^2 [M] [T]^(-2)" << std::endl; + sstream2 << "M*(L/T)*(L/T) = [L]^2 [M] [T]^-2" << std::endl; + sstream2 << "M*(L/T)^2 = [L]^2 [M] [T]^-2" << std::endl; sstream2 << "L^3 = [L]^3" << std::endl; sstream2 << "L^(3/2) = [L]^(3/2)" << std::endl; sstream2 << "2vM = [M]^(1/2)" << std::endl; |