Numerical error on native float access
Martin Buchholz
martinrb at google.com
Tue Apr 20 00:02:16 PDT 2010
On Sat, Apr 17, 2010 at 15:37, Ulf Zibis <Ulf.Zibis at gmx.de> wrote:
> There seems to be a bug in Float.intBitsToFloat(int) and/or
> Float.floatToRawIntBits(float) and/or sun.misc.Unsafe.getInt/Float.
>
> If I replace
> return
> Float.intBitsToFloat(Integer.reverseBytes(unsafe.getInt(offset)));
> with
> return reverseBytes(unsafe.getFloat(offset));
It looks like you are accessing a float value using getInt,
which is breaking the rules.
In any case, swapping bytes of floating point values is
something no one is likely to care about.
At least, I'm finding it hard to care.
Martin
More information about the nio-dev
mailing list