Luke Hoban (2013-07-12T15:58:55.000Z)
domenic at domenicdenicola.com (2013-07-12T16:31:39.644Z)
From: Allen Wirfs-Brock [mailto:allen at wirfs-brock.com] > On Jul 11, 2013, at 9:01 PM, Luke Hoban wrote: > >> Two questions on new `Number` APIs: >> >> 1) Is it intentional that `clz` is on `Number.prototype` instead of `Number`? Why? > > I think there is a stronger case to me made for `Math.clz(number)`. `Number.prototype` and `Math` both seem like plausible homes for `clz`. In the end, I placed it on `Number` prototype because it is an operation that is specific to a particular numeric encoding rather than an implementation of a general mathematical function. Yeah, I think `Math` would have been less surprising. I don't feel strongly, but `Number.prototype` wasn't what I had expected. >> 2) Is it intentional that `Number.toInteger(Infinity)` returns `true`? >Huh? How's that? > > `Number.toInteger` is specified as the single step: > > 1 Return ToInteger(number) > >and step 4 of the abstract operation ToInteger(number): > > 4 If number is +0, -0, +∞, or -∞, return number. > Sorry, I meant `isInteger`. Per your quoted section, `toInteger(Infinity)` is `Infinity`, so `isInteger(Infinity)` is `true`.
domenic at domenicdenicola.com (2013-07-12T16:29:24.442Z)
>From: Allen Wirfs-Brock [mailto:allen at wirfs-brock.com] > >On Jul 11, 2013, at 9:01 PM, Luke Hoban wrote: > >> Two questions on new Number APIs: >> >> 1) Is it intentional that clz is on Number.prototype instead of Number? Why? > >I think there is a stronger case to me made for Math.clz(number). Number.prototype and Math both seem like plausible homes for clz. In the end, I placed it on Number prototype because it is an operation that is specific to a particular numeric encoding rather than an implementation of a general mathematical function. > Yeah, I think Math would have been less surprising. I don't feel strongly, but Number.prototype wasn't what I had expected. >> 2) Is it intentional that Number.toInteger(Infinity) returns true? >Huh? How's that? > > Number.toInteger is specified as the single step: > > 1 Return ToInteger(number) > >and step 4 of the abstract operation ToInteger(number): > > 4 If number is +0, -0, +∞, or -∞, return number. > Sorry, I meant `isInteger`. Per your quoted section, `toInteger(Infinity)` is `Infinity`, so `isInteger(Infinity)` is `true`.