commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luc Maisonobe <>
Subject Re: [math][patch] Mantissa + Characteristic methods for MathUtils
Date Tue, 26 Sep 2006 04:00:08 GMT
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).


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message