Mark S. Miller (2013-07-12T15:54:10.000Z)
On Fri, Jul 12, 2013 at 8:49 AM, Allen Wirfs-Brock <allen at wirfs-brock.com>wrote:

>
> 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?
>
> Generally, operations that operate upon a value of a specific type are
> expressed as instance methods.  We see this all the time with regular
> objects but we also we see this in String where we have many methods that
> operate upon string values.  For Number we have the toFixed, etc. methods
> that convert  number values to strings.  To me, clz seem like it fall into
> this category of method that operate upon instances of a specific type.
>  For example, compare and contrast:
>
> '00101000111100001111000011110000'.indexOf('1') // 2
> 0x28f0f0f0.clz()   //2
>
> both use instance methods, applied to a primitive value, that  report
> something about the structure of the value
>
> The (new) is* methods on the Number constructor are generally different in
> that they are predicates that test values that may not actually be numbers
> so they can't be Number.prototype methods.
>
> 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.
>
> >
> > 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.
>

I must have missed that when it came up. I find it bizarre that
toInteger(anything) === Infinity. Infinity is not an integer.




>
>
>
> >
> > Luke
> >
> > _______________________________________________
> > es-discuss mailing list
> > es-discuss at mozilla.org
> > https://mail.mozilla.org/listinfo/es-discuss
> >
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>



-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130712/a02d3dc6/attachment-0001.html>
domenic at domenicdenicola.com (2013-07-12T16:33:25.994Z)
On Fri, Jul 12, 2013 at 8:49 AM, Allen Wirfs-Brock <allen at wirfs-brock.com>wrote:

> > 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.

I must have missed that when it came up. I find it bizarre that `toInteger(anything) === Infinity`. `Infinity` is not an integer.