# Dealing with large numbers

Mark Wieder mwieder at ahsoftware.net
Wed Sep 17 12:53:44 CDT 2008

```All-

I just ran into an integer overflow problem and I'm wondering if there
is a preferred way of dealing with this. I get the right number of
digits, but after iteration 79 the last digits are all zero. Is there
a way of dealing with large numbers? Here's a simple handler that
gives wrong answers:

--------------------------------------------------
-- Find the Nth Fibonacci number
-- Usage: Fibonacci(100)
-- note: this overflows at around iteration 79
--------------------------------------------------
on Fibonacci pIteration
local tFibNum
local tPrevious
local tTemp

-- prime the pump
put 1 into tPrevious -- Fibonacci number 1
put 1 into tFibNum -- Fibonacci number 2
repeat with x=3 to pIteration
put tFibNum into tTemp
add tPrevious to tFibNum
put tTemp into tPrevious
-- show your work
put "Iteration" && x & "=" && tFibNum & cr after field 1
end repeat
end Fibonacci

--
-Mark Wieder
mwieder at ahsoftware.net

```

More information about the use-livecode mailing list