Boost logo

Boost Users :

Subject: Re: [Boost-users] [units] how to use scaled_base_unit?
From: Olaf Peter (ope-devel_at_[hidden])
Date: 2013-04-24 10:08:32


> On 04/23/2013 11:55 AM, Olaf Peter wrote:
>> at this time I start to understand boost.units. Following the doc
>> http://www.boost.org/doc/libs/1_53_0/doc/html/boost_units/Units.html#boost_unit
>> scaled_units are useful. But I didn't found use cases in the test or
>> examples. E.g.
>> https://svn.boost.org/svn/boost/trunk/libs/units/test/test_output.cpp
>> show how to typedef this, but no usage.
>>
>
> scaled_base_unit works exactly like any other
> base unit. For instance, boost::units::si::kilogram_base_unit
> is a scaled_base_unit.
>
>> I try to map metric/si and imperial/us length to an intrinsic length
>> using integer scale factors to avoid double representation uncertainly.
>> Using BOOST_UNITS_DEFINE_CONVERSION_FACTOR I can convert meter and inch
>> to the intrinsic length. But what about mm/um and thou/mil etc? For this
>> I did consider scaled_base_unit. I like to convert between all of them.
>> Since the dimensions are constant, no runtime conversation are required
>> (as the dollar/euro example it shows). Later area calculations based on
>> the intrinsic length are required, convertible also to metric/si and
>> imperial systems.

maybe I misuse it? Expect the compile errors I get

$ ./units
1000000000 q
0 m




Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net