On Wed, Sep 17, 2008 at 7:35 PM, Brendan Eich <[EMAIL PROTECTED]> wrote:

> On Sep 17, 2008, at 10:13 PM, Mark S. Miller wrote:
>
> On Wed, Sep 17, 2008 at 6:50 PM, Maciej Stachowiak <[EMAIL PROTECTED]> wrote:
>
>>
>>
>> I agree that typeof 1.5m == typeof 1.1m. However, I do not agree that 1.1m
>> == 1.1. These should be !=, since they represent distinct real numbers.
>>
>>
>> It seems to me that Brendan said 1.1m != 1.1 and did not question this.
>>
>
> Brendan, please correct me if I misrepresent your argument.
>
> I took Brendan to be saying that
>
> 1) If typeof 1.1m were 'number' then we'd be obligated to have 1.1m == 1.1.
>
> 2) We want 1.1m != 1.1.
>
> 3) Therefore, typeof 1.1m must not be 'number'.
>
> I disagree with #1 and thus #3.
>
>
> Here is what I wrote:
>
> Without "use decimal", typeof 1.1m must not be "number" to preserve
> this same invariant [that a === b  <=>  typeof a == typeof b && a == b].
> Otherwise (without "use decimal") 1.5m == 1.5
> but 1.1m != 1.1, so without making typeof 1.5m != typeof 1.1m, we
> cannot have typeof 1.5m == "number".
>
>
> Please expand your syllogistic reasoning:
>
> Major premise #1: a == b
> Minor premise #1: typeof a == typeof b
> Conclusion #1: a === b
> (you can switch == and === above -- the implication goes both ways and
> choice of == or === for typeof a OP typeof b does not matter since typeof's
> result is of string type.)
>

Agreed.



> Major premise #2: 1.5m == 1.5
> Minor premise #2: typeof 1.5m == "number" (your position, IIUC)
> Conclusion #2: 1.5m === 1.5
> (by Conclusion #1 and ES1-3 (which define typeof 1.5 == "number"))
>

Yes.



> Counter-example: 1.1m != 1.1
> but typeof 1.1m == typeof 1.1 in your proposal (again IIUC)
>

Yes. That's because the binary floating point literal written as "1.1" does
not represent the real number "1.1".



> This is a for-all problem. If there exists some double value x such that,
> for the decimal form y spelled literally using the same digits but with an
> 'm' suffix, x != y, yet typeof x == typeof y, then typeof must depend on
> whether its operand value converts losslessly to decimal from double and
> double from decimal.
>
> This is broken -- typeof should depend on type, not value.
>

No, I agree that typeof must depend on type, not value. I advocate the
following results:

typeof 1.1 === typeof 1.1m === typeof 1.5 === typeof 1.5m === 'number'
1.1 !== 1.1m
1.1 === 1.1000
1.1m === 1.1000m
1.5 === 1.5m === 1.5000m

The reason? The binary floating point literal "1.1" evaluates to a binary
floating point numeric value that denotes a real number other than the real
number 1.1.

For all finite numeric values X and Y, if the real number exactly
represented by X and Y is the same, then X === Y and X and Y are in the same
generalized cohort. Otherwise X !== Y.

I am not defining my position based on conversion between binary and decimal
numeric values, but rather by correspondence with the reals. Thus I also
advocate that 1.000000000000000000000000000000000000000000000000001m === 1m
=== 1.00000000000000000000000000000000000000000000000002 === 1, since these
are all evaluated to numeric values that all exactly represent the real
number 1.



> Hence my position (Waldemar's too) that typeof 1.1m == typeof 1.5m &&
> typeof 1.1m == "decimal".
>
>
> However, with the introduction of decimal, we've got cohorts galore. 1.1m
> has a different operational behavior than 1.1000m, but we've agree they
> should be ===. With the introduction of decimal, === no longer approximates
> a test of operational equivalence, and we still need such a test.
>
>
> === does approximate operational equivalence apart from significance.
> Right? (I'm asking because I could be wrong, not rhetorically!)
>

AFAIK, yes, and apart from minus-zero-ness. And ignoring the fact that the
extra digits in "1.000m", whatever they might mean, apparently mean
something other than "significance". Recall all the clarifications,
especially by Mike Colishaw, that these extra zeros aren't "significance".
And I agree that they shouldn't be significance, but I'm still unclear on
what they are instead.


> 0/-0 != 0/0. Does it thus seem wrong that -0 === 0?
>
> Well, yes, actually it does seem wrong to me, but we all accept that
> particular wrongness. This is just more of the same.
>
>
> A lot more.
>
> Two wrongs don't make a right.
>
> One exception to the rule is better than two, or 2^53 or larger.
>

"apart from somthing like significance" is a huge new set of exceptions. A
large enough set that we can no longer understand === as approximating
operational equivalence. If instead we understand === to be asking whether
two operands are cohorts, and we define cohorts to be those numeric values
that exactly represent a given real number, then
1) -0 vs 0 is no longer irregular
2) We can explain why 1.5 === 1.5m === 1.5000m
3) We can explain why 1.1 !== 1.1m.


-- 
   Cheers,
   --MarkM
_______________________________________________
Es-discuss mailing list
Es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to