Hi all !

Case 1:
    3!:0 [ (n^2)

8

     (n^2) | 5729082486784839

0

It is non-intuitive that an integer raised to an integer is a float, but I think it is normal. It would be possible with a performance penalty to get an integer result. One problem with that is that it would easily overflow. It would also be possible to have a special operation for this case. When the left argument is a float the right argument has to be converted to a float. It must be assumed that this conversion is intentional, even though it is implicit.

Case 2:
     3!:0 [ (n^2)

8

     (n^2) | 5729082486784839x

0

3!:0 (n^2) | 5729082486784839x

8

Here the rational seems to be converted to a float and the result is float. Shouldn't we have an error instead of converting rationals to float?

Case 3:

3!:0 (x: n^2)

128

     (x: n^2) | 5729082486784839

0

3!:0 (x: n^2) | 5729082486784839

128

I have a hard time understanding what happens here. This result seems very peculiar. Is the left and right argument converted to float and the float result converted to rational?!
Shouldn't we have an error instead of converting rationals to float?
We could not have floats auto-converted to rationals?
In this case the integer should be converted to rational and we should get a rational result?

It is non-intuitive that (*: n) does not give the same result as (n^2). Maybe once this was decided because of performance reasons.

Cheers,

Erling Hellenäs

On 2017-09-05 18:41, Rob B wrote:
Could someone explain this please?

  n=.14
    n
14
    (*: n) | 5729082486784839
147
    196 | 5729082486784839
147
    (n^2) | 5729082486784839
0
    (n^2) | 5729082486784839x
0
    (x: n^2) | 5729082486784839
0
    (x: n^2) | 5729082486784839x
147


Regards, Rob Burns
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to