![]() |
Home | Libraries | People | FAQ | More |
This example demonstrates using of absolute temperatures and relative temperature
differences in Fahrenheit and converting between these and the Kelvin temperature
scale. This issue touches on some surprisingly deep mathematical concepts
(see Wikipedia
for a basic review), but for our purposes here, we will simply observe that
it is important to be able to differentiate between an absolute temperature
measurement and a measurement of temperature difference. This is accomplished
by using the absolute
wrapper class.
First we define a system using the predefined fahrenheit base unit:
typedef temperature::fahrenheit_base_unit::unit_type temperature; typedef get_system<temperature>::type system; BOOST_UNITS_STATIC_CONSTANT(degree,temperature); BOOST_UNITS_STATIC_CONSTANT(degrees,temperature);
Now we can create some quantities:
quantity<absolute<fahrenheit::temperature> > T1p( 32.0*absolute<fahrenheit::temperature>()); quantity<fahrenheit::temperature> T1v( 32.0*fahrenheit::degrees); quantity<absolute<si::temperature> > T2p(T1p); quantity<si::temperature> T2v(T1v);
Note the use of absolute
to wrap a unit. The resulting output is:
{ 32 } F { 273.15 } K { 273.15 } K [ 32 ] F [ 17.7778 ] K [ 17.7778 ] K