[2611] in java-interest
Re: modulus on floats?
daemon@ATHENA.MIT.EDU (Jim Graham)
Fri Oct 6 02:53:11 1995
Date: Thu, 5 Oct 1995 21:44:50 -0700
From: flar@bendenweyr.Eng.Sun.COM (Jim Graham)
To: java-interest@java.Eng.Sun.COM, lemay@lne.com
> The alpha spec says that a % b on floats is equivalent to:
>
> a - ((int)(a / b) * b)
>
> However, that's not what a % b is currently behaving like, and I'm getting
> really bizarre results. 12.5 % 7.5, for example, is now -1.5. Huh?
>
> What's the new formula for floating-point modulus?
The prebeta1 JDK had an implementation of floating-point modulus
that used the IEEE remainder formula (i.e. a - round(a/b)*b) for
its result.
Since this caused the % operator to give radically different results
for floats than it gave for integers, we have changed it back to what
the alpha specification says (i.e. a - trunc(a/b)*b) in the next release.
Sorry for the confusion.
...jim
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com