[concurrency-interest] double to long

Joe Bowbeer joe.bowbeer at gmail.com
Mon Jul 4 06:48:55 EDT 2005


On 7/3/05, Nikolai V. Chr. <nikolai at ifad.dk> wrote:
> 
> I would like to know if these two produce the same result:
> 
> double initialValue;
> a = Double.doubleToLongBits(initialValue);
> b = (long) initialValue;
> 

Nope.

See http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Double.html

a is the IEEE bits
b is the truncated/rounded long value

Btw,

new Double(initialValue).longValue() == (long) initialValue



More information about the Concurrency-interest mailing list