Just discovering J language, I typed:
1+^o.*0j1
I expected the answer to be 0
, but I get 0j1.22465e_16
. Although this is very close to 0, I was wondering why there is a numerical error in the answer while J is supposed to be able to perform arbitrary precision arithmetic? How could I get the correct answer 0
?
Arbitrary precision is for integers and rationals.
The constants π (1p1
) and e (1x1
) are still floating point numbers with precision of about 17 significant decimal digits .
The only way to produce exactly 0 is if your code is "aware" of the case. The composition ^@o.
is special code for this case.
^@o. 0j1
_1