|
Boost : |
From: Johan Råde (rade_at_[hidden])
Date: 2007-03-19 14:23:17
Matthias Schabel wrote:
> While porting the proposed Boost.Units (currently mcs::units) library
> to some (mainly older)
> platforms, we have run into problems with <cmath> functions being
> unavailable. For example,
> gcc 3.4.4 on Cygwin does not implement nexttoward, llrint, llround
> (possibly others). Given
> that the proposed fp utilities library already gives portable
> implementations of some TR1
> functions in <cmath>, is it possible to extend support to provide a
> TR1 support for all functions
> aside from the special functions that John and Paul are working on
> providing?
>
> Matthias
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>
llrint:
I don't see how to do a platform independent implementation.
The function rounds to the nearest integer,
using the current rounding direction.
You get the current rounding direction using fegetround.
It would be very hard to do a platform independent
implementation of fegetround.
I think it will be very hard to do platform independent
implementations of any of the fe... functions in <cmath>.
You probably need assembler to implement them at all.
Does the Boost.Units library really need these functions?
nextafter, nextbefore, nexttoward:
Doable.
To get the next floating point number after a given floating point
number you copy the bits into an integer, add 1, and copy them back.
You also need to do some special handling of
1: 0
2: std::numeric_limis<T>::min (if there are no denormals)
3: std::numeric_limits<max>::max
4: infinity
5: NaN
If there is a need for this, I might do it, but not during the next two
months.
-- Johan Råde
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk