From: Bruno Lalande (bruno.lalande_at_[hidden])
Date: 2008-02-12 04:24:07


Hi John,

> Can you follow the error handling policies for overflow here:
>
> http://svn.boost.org/svn/boost/trunk/libs/math/doc/sf_and_dist/html/math_toolkit/main_overview/error_handling.html?
>

OK, this is done.

Using boost::math::tools::promote_args<T>::type to calculate the result type
> based on the argument type will work for integer and floating point args:
> not sure how this integrates with Boost.Units though.
>

Maybe we don't have the same need here. What I don't understand is the fact
that for you, a power with integral argument should return a double. My
original need when I first talked about returning different possible types
was just to respect the type used by the caller. That is, if the caller asks
for pow<2>(int) and works with integers in all the rest of its code,
providing the result in a float or double can be disturbing and even slow it
down. For instance, returning the result of pow<2>(10) in a float sounds
unnatural to me if 10 was originally stored in an int. But obviously,
pow<-N>(int) should return a floating point since the result is of the form
1/int.

If I understand well, your approach is rather to take care of providing a
type capable of holding the result even in case of big integral exponent and
big integral base. Am I right or is there another rationale behind what you
propose?

Which one of those two approaches is the most appropriated in your opinion?

Thanks
Bruno