HaloO,

Luke Palmer wrote:
That is, is 1 different from 1.0?

I opt for 1 being Int and 1.0 being Num. But for the
latter a test .does(Int) might succeed on the footing
that the fractional part is zero, that is 1.0%1 == 0.
Note that 1/3*3 does not necessarily equal 1.0 for
floating point math. It's more like 0.999... which raises
the question how the construction of an Int from a Num works?
Do we truncate, floor or round? Would (1/3*3).does(Int) be
true?


 Should 10**500 be infinity or a 1 with 500 zeroes after it?

IEEE 754 distinguishes Overflow from Inf. Both are outside the
order of the valid numbers. Should we have these exceptional values
comparable? E.g. code like

    # some calculation involving $x
    if $x == Overflow {...}

seems reasonable. And I think that Inf == Inf and things
like $x < Inf should be valid syntax. I think Overflow < Inf
makes sense as well.


 Should 10**10**6 run out of memory?  Should
"say (1/3)**500" print a bunch of digits to the screen or print 0?

Are we silently underflowing to zero? Or should it return an
Underflow? In particular I would expect Underflow to carry a
sign and Underflow.abs > 0.

Also Num needs to support signed zero e.g. for handling 1/(1/$x)
for $x == +/-Inf to end up with the correct sign of Inf. But of
course +0 == -0.


A somewhat tangential idea of mine are types like int31 that makes
signed 32 bit arithmetic modulo the Mersenne prime 2**31 - 1. That
would guarantee two things. First $x * $y > 0 whenever $x > 0 &&
$y > 0, that is there are no divisors of zero. Second -2**31 is
available to encode "infinity" or NaN. In int61 arithmetic with
modulus 2**61 - 1 in a 64 bit value we have the two spare bit combinations 01 and 10 after the sign to encode special numbers.

Regards, TSa.
--

Reply via email to