Boost logo

Boost Users :

Subject: Re: [Boost-users] [Units]
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2017-10-05 23:06:01


AMDG

On 10/05/2017 12:44 PM, CD Clark via Boost-users wrote:
>> The reason that it fails is that the output code
>> instantiates the default implementation even if
>> you override it. The problem is that there is
>> no symbol defined for 10^-4.
>
> Ah, that explains why it works for millimeter. Multiplying two millimeter
> units together gives 10^-6, which has a symbol. Does this mean that the IO
> can't handle units that have base units raised to some power that does not
> correspond to a symbol, or is this just supposed to be done a different way?
>
> Looking at the libraries definition of farad (which contains seconds to the
> fourth power), a derived dimension is defined for capacitance, and then an
> a unit for that dimension is created. Should I be creating the centimeter
> squared unit from the area dimension directly instead of trying to build it
> from already defined units?
>

Based on the way you're using this, I would recommend,
setting up the scaling at the base unit level, instead
of scaling the whole unit:

namespace t {
  using cm = scaled_base_unit<
    si::meter_base_unit,
    scale<10, static_rational<-2> > >::unit_type;
}

This should make the output work the way you
want automatically, as it causes cm*cm to
be represented as (cm)^2 instead of (c^2)(m^2).

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