As I understand it IEEE double float represents integers between plus/minus
2^53 exactly. Looking at the internal representation of 14^2 the value is
exact. Using Power (^) to compute the square gives the same result as 14*14
or *:14 when converted to float.

   3!:3]14^2
e300000000000000
0800000000000000
0100000000000000
0000000000000000
0000000000806840
   3!:3]{.196 0.5
e300000000000000
0800000000000000
0100000000000000
0000000000000000
0000000000806840

I verified that the above numbers are exactly 196 in IEEE double float.

   ({.196 0.5)|5729082486784839
0

verifies that it is not the power causing the problem, but the fact that
the left argument is float.

What is interesting is that residue starts working for larger values for
the left argument.

   ({.>:1e4 0.5)|5729082486784839
1257
   ({.>:1e3 0.5)|5729082486784839
0
   ({.>:1e3 0.5)|572908248678483.9
718.875

It seems that the problem occurs when the ratio of the arguments exceeds
some large number that residue fails.

   2^.5729082486784839%196
44.7325

   ({.1960 0.5)|5729082486784839
1519
   ({.19.6 0.5)|5729082486784839
0
   ({.196 0.5)|572908248678483.9
151.875

One possible solution would be to convert the arguments to integer if the
float values are integral, but that would still have failures when either
argument is not integral. In any case, that it starts working for larger
values for the left argument is disturbing.

The same problem shows up in antibase (#:) as well.

   JVERSION
Engine: j806/j64avx/windows
Beta-3: commercial/2017-04-10T18:03:23
Library: 8.06.06
Qt IDE: 1.6.0/5.6.2
Platform: Win 64
Installer: J806 install
InstallPath: c:/users/don/j64-806o
Contact: www.jsoftware.com
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to