Boost logo

Boost Users :

Subject: Re: [Boost-users] [Units] Un-scaling dimensionless value
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2014-02-14 20:27:04


AMDG

On 02/14/2014 04:06 PM, Lindley French wrote:
> <snip>
> Now, when I cout these values, I see that everything is technically the
> correct. The problem is that total is a dimensionless quantity which is
> scaled----it's 1,250,000,000, when I expect 1,250,000, and it displays as
> "1250000000 m", where m is "milli", not "meters".
>
> What is the correct way to un-scale dimensionless quantities? I tried this:
> quantity<si::dimensionless,rational<unsigned>> unscaled(total);
>
> However, unscaled still has the same value.
>

The result comes out as zero for me.

> I also tried
> typedef make_scaled_unit<si::dimensionless, scale<10, static_rational<0> >
>> ::type dimensionless_unit;
> quantity<dimensionless_unit,rational<unsigned>> unscaled(total);
>
> but this time, unscaled came out zero.
>
> Any suggestions?
>

The reason it's zero comes down to:

std::cout << rational<unsigned>(1250000000) * 0.001 << std::endl;
// prints 0/1

Conversions involving rational do not work
correctly, because rational does not support
multiplication by double.

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