Boost logo

Boost Users :

Subject: Re: [Boost-users] [units] how to use scaled_base_unit?
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2013-04-24 10:47:33


AMDG

On 04/24/2013 07:08 AM, Olaf Peter wrote:
>
> maybe I misuse it? Expect the compile errors I get
>
> $ ./units
> 1000000000 q
> 0 m
>

- Don't use integer conversion factors. The library
  assumes that it can use constructs like x * (1/factor).
  You don't gain any precision by using int. Anything
  that can be represented in an int32_t can be represented
  exactly in a double.
- You need to use bu::make_system/bu::unit for millimeter_base_unit,
  just like for meter_base_unit.
- You can define multiple conversion factors. Just add
  BOOST_UNITS_DEFINE_CONVERSION_FACTOR(
    clients::units::my::length_base_unit,
    boost::units::si::meter_base_unit,
    double, 1000000000);
  to enable conversion to and from the Boost.Units systems.

In Christ,
Steven Watanabe


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