Best I've found on the net uses some bit arithmetic. long bits = Double.doubleToLongBits(5894.349580349);
boolean negative = (bits & 0x8000000000000000L) != 0; long exponent = bits & 0x7ff0000000000000L >> 52; long mantissa = bits & 0x000fffffffffffffL; Cheers, Mark On Sep 25, 2006, at 11:39 PM, Kevin Jackson wrote:
Hi, I've just been working on some fairly simple code (in any other language), and realised that I needed some of the most basic methods available and suprise Java doesn't have them in the base libraries. These are very tiny, but I can't believe that no-one else has ever needed to get the mantissa of a float/double before me - if these exist in some other form please forgive this intrusion. 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). Thanks, Kev --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
