Allen Wirfs-Brock (2013-07-12T16:44:10.000Z)
On Jul 12, 2013, at 9:01 AM, Mark Miller wrote:

> 
> 
> 
> On Fri, Jul 12, 2013 at 8:58 AM, Luke Hoban <lukeh at microsoft.com> wrote:
> >From: Allen Wirfs-Brock [mailto:allen at wirfs-brock.com]
> >
> 
> >>
> >> 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.
> 
> And I find that equally bizarre and unpleasant.

ToInteger is an internal operation.  Algorithms that call it can explicitly check for infinities if it is important to them.  However, a quick scan of its current uses shows that passing through infinities is exactly want is needed in most cases.

Number.toInteger is a language level function and it is certainly reasonable to explicitly discuss what it should  return for infinities (and for that matter NaN and -0).  So what do you think it should do for those cases?

Also, the current Math.isInteger spec. is just plan bogus:

    3.   If integer is not equal to number, return false.

What (in the spec.) does "not equal" mean?  I must have been asleep at the keyboard or  maybe it's strawman language that slipped through into the spec. without adequate review...

Allen




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130712/e149c2b5/attachment.html>
domenic at domenicdenicola.com (2013-07-15T22:42:25.839Z)
On Jul 12, 2013, at 9:01 AM, Mark Miller wrote:

> And I find that equally bizarre and unpleasant.

ToInteger is an internal operation.  Algorithms that call it can explicitly check for infinities if it is important to them.  However, a quick scan of its current uses shows that passing through infinities is exactly want is needed in most cases.

`Number.toInteger` is a language level function and it is certainly reasonable to explicitly discuss what it should  return for infinities (and for that matter NaN and -0).  So what do you think it should do for those cases?

Also, the current `Math.isInteger` spec. is just plan bogus:

    3.   If integer is not equal to number, return false.

What (in the spec.) does "not equal" mean?  I must have been asleep at the keyboard or  maybe it's strawman language that slipped through into the spec. without adequate review...