Boost logo

Boost Users :

Subject: Re: [Boost-users] getting started with Boost::Units
From: David Conner (dcconner_at_[hidden])
Date: 2009-01-09 16:27:27


Typically a {-1} exponent just means invert; i.e. h^{-1} = 1/h

On Fri, Jan 9, 2009 at 3:59 PM, Mark Volkmann <mark_at_[hidden]> wrote:
> On Jan 9, 2009, at 1:16 PM, Matthias Schabel wrote:
>
>>> Thanks!
>>>
>>> Why does the the following simple code output "605 mi h^-1" instead of
>>> "605 mi/h"? Why is the "^-1" at the end?
>>>
>>> #include <iostream>
>>> #include <boost/units/base_units/us/mile.hpp>
>>> #include <boost/units/base_units/metric/hour.hpp>
>>> #include <boost/units/io.hpp>
>>>
>>> using namespace boost::units;
>>> using namespace std;
>>>
>>> typedef us::mile_base_unit::unit_type mile_unit;
>>> typedef metric::hour_base_unit::unit_type hour_unit;
>>> typedef divide_typeof_helper<mile_unit, hour_unit>::type miles_per_hour;
>>>
>>> int main() {
>>> quantity<miles_per_hour> mph = 605.0 * miles_per_hour();
>>> cout << mph << endl;
>>> return 0;
>>> }
>>
>> The output code does not give special status to exponents of -1, but just
>> treats them consistently. If you want specialized output, see
>> examples/composite_output.cpp for an example.
>
>
> Why is the exponent -1 in this example? I could understand if it was zero,
> but I don't think -1 makes sense.
>
> ---
> Mark Volkmann
>
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


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