+ 1
Something weird
https://code.sololearn.com/cJaUUFw4Y5y7/?ref=app How does this code go into negatives??? Like what in the holy hot crispy Kentucky fried chicken frick? Tryin to make a Fibonacci code. https://code.sololearn.com/cJaUUFw4Y5y7/?ref=app
5 odpowiedzi
+ 2
By default a java int is signed which means the last bit is used to signal if the number should be positive or negative. you end up overflowing that bit causing numbers to become negative by accident
+ 2
No clue, you can look up the supported ranges for java data types in the documentation. long will give you a larger range but will still overflow eventually
0
yo thats kinda weird
0
do they explain that in the java course?
0
oh ok. thx man!