Re: Questions on clz and toInteger

2013-07-12 Thread Allen Wirfs-Brock
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

RE: Questions on clz and toInteger

2013-07-12 Thread Luke Hoban
From: Allen Wirfs-Brock [mailto:al...@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).

Re: Questions on clz and toInteger

2013-07-12 Thread Mark Miller
On Fri, Jul 12, 2013 at 8:58 AM, Luke Hoban lu...@microsoft.com wrote: From: Allen Wirfs-Brock [mailto:al...@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?

Re: Questions on clz and toInteger

2013-07-12 Thread Allen Wirfs-Brock
On Jul 12, 2013, at 9:01 AM, Mark Miller wrote: On Fri, Jul 12, 2013 at 8:58 AM, Luke Hoban lu...@microsoft.com wrote: From: Allen Wirfs-Brock [mailto:al...@wirfs-brock.com] 2) Is it intentional that Number.toInteger(Infinity) returns true? Huh? How's that? Number.toInteger

Re: Questions on clz and toInteger

2013-07-12 Thread Oliver Hunt
On Jul 12, 2013, at 8:58 AM, Luke Hoban lu...@microsoft.com wrote: From: Allen Wirfs-Brock [mailto:al...@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?

Re: Questions on clz and toInteger

2013-07-12 Thread Tab Atkins Jr.
On Fri, Jul 12, 2013 at 10:19 AM, Mark S. Miller erig...@google.com wrote: No. Even if toInteger meant no fractional component, I would still expect it only to return true if there is some specific mathematical integer that the JS number can be said to exactly represent. For the same reason, I

Re: Questions on clz and toInteger

2013-07-12 Thread Oliver Hunt
On Jul 12, 2013, at 10:19 AM, Mark S. Miller erig...@google.com wrote: No. Even if toInteger meant no fractional component, I would still expect it only to return true if there is some specific mathematical integer that the JS number can be said to exactly represent. For the same reason, I

Re: Questions on clz and toInteger

2013-07-12 Thread Allen Wirfs-Brock
On Jul 12, 2013, at 10:27 AM, Tab Atkins Jr. wrote: On Fri, Jul 12, 2013 at 10:19 AM, Mark S. Miller erig...@google.com wrote: No. Even if toInteger meant no fractional component, I would still expect it only to return true if there is some specific mathematical integer that the JS number

Re: Questions on clz and toInteger

2013-07-12 Thread Tab Atkins Jr.
On Fri, Jul 12, 2013 at 10:48 AM, Allen Wirfs-Brock al...@wirfs-brock.com wrote: On Jul 12, 2013, at 10:27 AM, Tab Atkins Jr. wrote: On Fri, Jul 12, 2013 at 10:19 AM, Mark S. Miller erig...@google.com wrote: No. Even if toInteger meant no fractional component, I would still expect it only to

Re: Questions on clz and toInteger

2013-07-12 Thread Allen Wirfs-Brock
On Jul 12, 2013, at 1:48 PM, Mark S. Miller wrote: On Fri, Jul 12, 2013 at 11:00 AM, Tab Atkins Jr. jackalm...@gmail.com wrote: On Fri, Jul 12, 2013 at 10:48 AM, Allen Wirfs-Brock al...@wirfs-brock.com wrote: In other words you want to define Number.isInteger to return true only if

Re: Questions on clz and toInteger

2013-07-12 Thread Jeff Walden
On 07/12/2013 10:27 AM, Tab Atkins Jr. wrote: And, because of what we discussed in the recent thread... Number.isInteger(Math.pow(2,53)-1) == true Number.isInteger(Math.pow(2,53)) == false I need to comment in the other thread again and push back against what people have said there, but

Re: Questions on clz and toInteger

2013-07-12 Thread Allen Wirfs-Brock
On Jul 12, 2013, at 3:54 PM, Jeff Walden wrote: On 07/12/2013 10:27 AM, Tab Atkins Jr. wrote: And, because of what we discussed in the recent thread... Number.isInteger(Math.pow(2,53)-1) == true Number.isInteger(Math.pow(2,53)) == false I need to comment in the other thread again and

Re: Questions on clz and toInteger

2013-07-12 Thread Tab Atkins Jr.
On Fri, Jul 12, 2013 at 3:54 PM, Jeff Walden jwalden...@mit.edu wrote: On 07/12/2013 10:27 AM, Tab Atkins Jr. wrote: And, because of what we discussed in the recent thread... Number.isInteger(Math.pow(2,53)-1) == true Number.isInteger(Math.pow(2,53)) == false I need to comment in the other

Re: Questions on clz and toInteger

2013-07-12 Thread Jeff Walden
On 07/12/2013 04:03 PM, Allen Wirfs-Brock wrote: are you suggesting that if we want such an function, it should be named something else, such as isExactInteger, isPreciseInteger, isUnambiguousInteger, etc? Possibly, but I don't think so. Whether a value is exact or precise is a function

Re: Questions on clz and toInteger

2013-07-12 Thread Jeff Walden
On 07/12/2013 04:13 PM, Tab Atkins Jr. wrote: If you don't agree with that reasoning, then I suppose you'd argue that *all* numbers 2^53 should return true, since they're all forced into being represented as integers? All numbers = 2**53 except Infinity, yes. I think isInteger implies the

Re: Questions on clz and toInteger

2013-07-12 Thread Allen Wirfs-Brock
On Jul 12, 2013, at 4:18 PM, Jeff Walden wrote: On 07/12/2013 04:03 PM, Allen Wirfs-Brock wrote: are you suggesting that if we want such an function, it should be named something else, such as isExactInteger, isPreciseInteger, isUnambiguousInteger, etc? Possibly, but I don't think so.

Re: Questions on clz and toInteger

2013-07-12 Thread Jorge Chamorro
On 13/07/2013, at 01:24, Jeff Walden wrote: On 07/12/2013 04:13 PM, Tab Atkins Jr. wrote: If you don't agree with that reasoning, then I suppose you'd argue that *all* numbers 2^53 should return true, since they're all forced into being represented as integers? All numbers = 2**53 except

Re: Questions on clz and toInteger

2013-07-12 Thread Jeff Walden
On 07/12/2013 04:32 PM, Allen Wirfs-Brock wrote: So the other thread was a discussion concerning the appropriate value of Number.MAX_INTEGER. Do you think it should be 2^53-1, or 2^53, or the same thing as Math..MAX_VALUE. Number.MAX_INTEGER should be 2**53. People who want 2**53 - 1 (and

Re: Questions on clz and toInteger

2013-07-12 Thread Allen Wirfs-Brock
On Jul 12, 2013, at 4:39 PM, Jeff Walden wrote: On 07/12/2013 04:32 PM, Allen Wirfs-Brock wrote: So the other thread was a discussion concerning the appropriate value of Number.MAX_INTEGER. Do you think it should be 2^53-1, or 2^53, or the same thing as Math..MAX_VALUE.

Re: Questions on clz and toInteger

2013-07-12 Thread Jeff Walden
On 07/12/2013 04:56 PM, Allen Wirfs-Brock wrote: So you seem to be saying that that Number.isInteger(MAX_VALUE) should be true, but that Number.MAX_VALUE Number.MAX_INTEGER is also true because for isInteger you using the mathematical definition of Integer but for MAX_INTEGER you are

RE: Questions on clz and toInteger

2013-07-12 Thread Domenic Denicola
While I sympathize with the desire to make integer mean mathematical integer, I don't think it's going to work out very well. Nobody actually cares about such functions, and you of course have the WATs of ```js Number.isInteger(9007199254740992.5) === true ``` since the runtime couldn't

Re: Questions on clz and toInteger

2013-07-12 Thread Jeff Walden
On 07/12/2013 06:17 PM, Tab Atkins Jr. wrote: On Fri, Jul 12, 2013 at 5:15 PM, Domenic Denicola dome...@domenicdenicola.com wrote: While I sympathize with the desire to make integer mean mathematical integer, I don't think it's going to work out very well. Nobody actually cares about such

Re: Questions on clz and toInteger

2013-07-12 Thread Tab Atkins Jr.
On Fri, Jul 12, 2013 at 6:39 PM, Jeff Walden jwalden...@mit.edu wrote: On 07/12/2013 06:17 PM, Tab Atkins Jr. wrote: On Fri, Jul 12, 2013 at 5:15 PM, Domenic Denicola dome...@domenicdenicola.com wrote: While I sympathize with the desire to make integer mean mathematical integer, I don't

RE: Questions on clz and toInteger

2013-07-12 Thread Domenic Denicola
From: Tab Atkins Jr. [mailto:jackalm...@gmail.com] Exactly, which is why we can only *accurately* answer for numbers = 2^53-1. Probably a horrible idea in practice, but I feel like the correct answer here is `throw`ing outside that range. It's like asking is Tab's second head blonde or

Questions on clz and toInteger

2013-07-11 Thread Luke Hoban
Two questions on new Number APIs: 1) Is it intentional that clz is on Number.prototype instead of Number? Why? 2) Is it intentional that Number.toInteger(Infinity) returns true? Luke ___ es-discuss mailing list es-discuss@mozilla.org