Buglet in ES3 Math.round description
Mike Cowlishaw
MFC at uk.ibm.com
Thu Apr 17 01:21:48 PDT 2008
While looking through ES3 for other things, I happened to notice a minor
fault. What is the best way to record it so it can be fixed in due
course?
The error is in an informative note, so is not critical. It is in section
15.8.2.15, NOTE 2, which states:
"The value of Math.round(x) is the same as the value of Math.floor(x+0.5),
except when x is ?0 or is less than 0 but greater than or equal to -0.5;
for these cases math.round(x) returns ?0, but Math.floor(x+0.5) returns
+0."
This is not true when x is 0.49999999999999994, which when converted to
double is the next representable value below 0.5. In this case,
Math.floor(x+0.5) would return +1 but Math.round(x) would return +0.
Mike
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Mike Cowlishaw, IBM Fellow
IBM UK (MP8), PO Box 31, Birmingham Road, Warwick, CV34 5JL
mailto:mfc at uk.ibm.com -- http://www2.hursley.ibm.com/mfcsumm.html
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number
741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
More information about the Es4-discuss
mailing list