bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problems with division et al.


From: Kacper Gutowski
Subject: Problems with division et al.
Date: Tue, 23 Jun 2020 17:34:42 +0200

When dividing a number relatively close to zero by an integer, the result unexpectedly gets clamped to zero:

      (2⋆¯34)÷1
0

Using ⌹ or ×÷ gives expected results instead.
Looks like it happens at the line IntCell.cc:543 which should be removed. But I don't think there should be a check for near-zero even in the zero-divisor branch. With float and complex divisors, an exact zero is tested instead.

      (2⋆¯34)÷0         ⍝ shouldn't that still be a domain error?
1
      (2⋆¯34)÷0J0       ⍝ like here
DOMAIN ERROR
      (2⋆¯34)÷0
      ^      ^

The complex one is missing a check for finiteness:

      (2⋆999)÷2⋆¯999    ⍝ correct: 2⋆1998 is not representable
DOMAIN ERROR
      (2⋆999)÷2⋆¯999
      ^      ^
      (2⋆999)÷2⋆¯999J0  ⍝ ??
∞

When trying to see if I can trigger the above, I also noticed that something is off with power too:

      2⋆¯999J0          ⍝ correct
1.866527237E¯301
      2J0⋆¯999          ⍝ ??
0
      2⋆9999            ⍝ this is probably wrong too
∞

There's also some error in parser:

      1.000000001E¯301
1000000001
      1.000000001E¯302
1.000000001E10
      1.000000001E¯308  ⍝ this is still representable as double
0


-k



reply via email to

[Prev in Thread] Current Thread [Next in Thread]