Java 8 RFR 8010430: Math.round has surprising behavior for odd values of ulp 1
Brian Burkhalter
brian.burkhalter at oracle.com
Wed Aug 28 17:58:55 UTC 2013
On Aug 28, 2013, at 10:55 AM, Dmitry Nadezhin wrote:
> TLS 1 specification contained verbal statement
> "The result is rounded to an integer by adding , taking the floor of the result, and casting the result to typeint".
> and Java code
> Math.floor(f + 0.5).
>
> It seems to me that the verbal statement says about mathematical "+" .
> It maps a pair of reals to there exact sum without rounding.
>
> "+" in Java code is machine adding that is mathematic adding followed by rounding.
>
> In my opionion this is the source of mismatch.
Agreed.
> The verbal TLS 1 statement is equivalent to
> "Returns the closest {@code int} to the argument, with ties rounding to positive infinity".
> The Java code "Math.floor(f + 0.5) is not.
>
> This is just a remark.
> I agree that formulation "Returns the closest {@code int} to the argument, with ties rounding to positive infinity" is clear.
If others agree, I can update the webrev to use this verbiage. A CCC might be in order as well.
Brian
More information about the core-libs-dev
mailing list