0
Why does the code print negative numbers?
That is a fibonacci generator. On ~45 number prints negative. why? https://code.sololearn.com/cf2czO30H8JV/?ref=app
2 Respostas
+ 12
The int datatype has a maximum value of (2 ^ 31) - 1 minimum value of -(2 ^ 31) , when your number reaches that it will drop to -(2 ^ 31) and start counting from there
If my explanation confuses you let me explain with byte
Byte can store numbers in the range -128 to 127
so this: byte x = 130 is effectively -126
+ 10
Using long will work better