Boost logo

Boost :

From: Andy Little (andy_at_[hidden])
Date: 2006-08-19 08:03:42

"Manfred Doudar" wrote
> Hi Andy,

Hi Manfred,

> Andy Little wrote:
>> "Thorsten Ottosen" <nesotto_at_[hidden]> wrote in message
>>> Andy Little <andy <at>> writes:
>>>> // Quan
>>>> quan::length::ft qft(3);
>>>> std::cout << "quan qft.numeric_value() = "<< qft.numeric_value() << '\n';
>>>> assert(qft.numeric_value() ==3);
>>> Just a question: why is the member called numeric_value? are there other
>>> values?
>> The function is called numeric_value as it returns the numeric value of the
>> quantity.
>> quan::length::mi my_journey(25); // distance in miles
>> quan::length_<int>::nm dx (25); // distance in nanometers
>> The numeric value of journey is 25, the numeric value of dx is 25, but the
>> units are very different.
> What you are getting with the call to 'numeric_value' is the scalar
> component of the "quantity" - right?

No I don't think so. When you get the numeric value of the quantity you have
effectively lost some inportant information; IOW what the units are.
It is necessary to be able to get at the numeric value, but as has been found in
practise, once you do that then you have effectively exited the type checking
and have to be very careful about what that number actually means.

> Just a suggestion then, would a more reasonable name for the method be
> 'magnitude'; it sounds better, and ties better to the problem domain.

Again 'magnitude' would be more like ' value', where the 'value' of the quantity
is numeric value + unit.

magnitude IMO is a vaguely similar situation to 'numeric value' versus
'value', but in vector terms. When you get the magnitude of a vector you have
lost the other useful information about the direction.

In fact there is a 2D and 3d vector in quan so you can do:

quan::some_vect< quan::length:: m > position_a, position_b;

quan::length:: m distance_a_to_b = magnitude(position_b - position_a);

Because of that useage It might get confusing.

Andy Little

Boost list run by bdawes at, gregod at, cpdaniel at, john at