+ 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

4th Jul 2019, 9:38 PM
Joseph Hardie
Joseph Hardie - avatar
7 Antworten
+ 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
4th Jul 2019, 10:23 PM
Agent_I
Agent_I - avatar
+ 3
Unfortunately data types cannot hold values up to infinity.
5th Jul 2019, 2:24 AM
Sonic
Sonic - avatar
+ 2
Because int can't hold numbers that are so big ;)
4th Jul 2019, 9:42 PM
Luk
Luk - avatar
+ 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??
4th Jul 2019, 9:44 PM
Joseph Hardie
Joseph Hardie - avatar
+ 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
4th Jul 2019, 10:17 PM
Agent_I
Agent_I - avatar
+ 2
Unsigned long long int? What's that?
4th Jul 2019, 10:18 PM
Joseph Hardie
Joseph Hardie - avatar
+ 2
I'll try that!
4th Jul 2019, 10:26 PM
Joseph Hardie
Joseph Hardie - avatar