You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Fibonacci example on the website doesn't work past 2 billion. I'm worried this might
be indicative of deeper problems.
What steps will reproduce the problem?
1. Go to http://golang.org.
2. Load up the Fobonacci example.
3. Edit the "main" function so that it execudes "fn()" 47 times (I
think).
4. Observe that the last 3 numbers output are "1134903170 1836311903
-1323752223". This is not Finonacci.
5. Similar weirdness continues for even higher numbers.
What is the expected output?
Well, 1134903170 + 1836311903 = 2971215073. So:
1134903170 1836311903 2971215073
What do you see instead?
1134903170 1836311903 -1323752223
Which compiler are you using (5g, 6g, 8g, gccgo)?
Whatever's on the website http://golang.org/.
Which operating system are you using?
Ditto.
I'm viewing the website using Google Chrome 12.0.742.91 on Windows 7.
Which revision are you using? (hg identify)
Ditto
Other info:
I know nothing about "go". I was just thinking of learning it. This bug I
found straight away makes me slightly disinclined to bother.
The text was updated successfully, but these errors were encountered:
This is a toy program demonstrating in the context a familiar problem things more
interesting than integer arithmetic.
What you're seeing is integer overflow. Machines have fixed-size words. It would be an
easy exercise to rewrite this code to use package big.
by robinwinslowmorris:
The text was updated successfully, but these errors were encountered: