Kevin Jackson a écrit :

Adding these would greatly simplify my current code, or if anyone
knows how to get the mantissa without resorting to String manipulation
- even using x * 10^mantissaLength % 10^mantissaLength /
10^mantissaLength is fairly nasty in client code (and you get rounding
errors that way).

Here is some code from the org.apache.commons.math.util.MathUtils.nextAfter method:

        // split the double in raw components
        long bits     = Double.doubleToLongBits(d);
        long sign     = bits & 0x8000000000000000L;
        long exponent = bits & 0x7ff0000000000000L;
        long mantissa = bits & 0x000fffffffffffffL;

This snippet cuold be promoted to public methods by itself (beware that the exponent part is the raw exponent which includes an offset, it is not a simple integer).

Luc

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to