Closed marcoscaceres closed 11 years ago
The spec says:
"Round x to the nearest integer, choosing the even integer if it lies halfway between two."
Do you guys think that mean that Math.round() can't be used here?
I'm reading the above as:
//check if it's in the middle? yes, floor it, otherwise, round it up.
(Math.abs(x - Math.round(x)) === .5 ) ? Math.floor(x) : Math.round(x);
oh, no, wait...
is it half way?
No: round it.
Yes: is an even number?
yes: round it
no: floor it.
Math.abs(x - Math.round(x)) === 0.5 ? (((Math.round(x) % 2 ) === 0) ? Math.round(x) : Math.floor(x)) : Math.round(x);
Implemented but untested. Waiting in pull request queue.
No longer blocked. Tests have been integrated. Just needs a review (only 34 lines): https://github.com/extensibleweb/webidl.js/blob/master/lib/types/Boolean.js
http://www.w3.org/TR/WebIDL/#idl-short