Boost logo

Boost Users :

Subject: Re: [Boost-users] [units] Conversions from quantities
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2015-08-13 15:14:02


AMDG

On 08/12/2015 04:39 PM, Michael Powell wrote:
>
> Just wanted to clarify something. These should convert from given
> quantities to the desired units?
>

If what you really want is a raw double,
than, yes, this should work.

> double
> unit_conversion::from_length_to_inches(quantity<length> const & L) {
> const quantity<inch_base_unit::unit_type> result_(L);
> return result_.value();
> }
>
> double unit_conversion::from_mass_to_pounds(quantity<mass>
> const & M) {

Pounds is a unit of force, not mass. To do
such a conversion, you need to multiply by g.

> const quantity<ounce_base_unit::unit_type> result_(M);
> return result_.value();
> }
>

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