Try starting with an extended-precision value:

   f0b 98x
135301852344706746049
   f2a 98      NB. not needed here
135301852344706746049

If you apply extended precision after-the-fact, the intermediate calculations will all be performed on floating-point numbers, which is where the precision loss happens.

On Sat, 25 Sep 2021, Skip Cave wrote:

From: https://code.jsoftware.com/wiki/Essays/Fibonacci_Sequence

f0b=: (-&2 +&$: -&1) ^: (1&<) M.

f2a=: 3 : '{. +/\@|.^:y 0 1x'

x:f0b 98

135301852344706760704

x:f2a 98

135301852344706746049


(x:f0b 98) -: x:f2a 98

0


Why the discrepancy?


Skip


Skip Cave
Cave Consulting LLC
----------------------------------------------------------------------
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