+ 4
Fibonacci generator negatives?
My first programme. After the 48th iteration it starts throwing negatives. Obviously that's wrong. Why is it doing this? https://code.sololearn.com/cBxK7M33qOlT/?ref=app
7 Answers
+ 3
An integer data type that is at least 8 bytes long, although it says at least, most compiler will use 8 bytes. The unsigned means it only holds positive number. Basically it can hold bigger number
+ 3
Unfortunately data types cannot hold values up to infinity.
+ 2
Because int can't hold numbers that are so big ;)
+ 2
Is there a different type of variable for big integers?? I don't believe that C++ can't handle large numbers! Or is it just in this mobile compiler??
+ 2
Joseph Hardie
You could use unsigned long long int, but even if you do so, it won't last hundreds of iteration. Not just C++, but also almost every programming languages doesn't directly support an integer data type that is bigger than 8 bytes
+ 2
Unsigned long long int? What's that?
+ 2
I'll try that!