+ 33
Code problem or ... ? (fibonacci series)
Why after the 46th number, it resualts negative number ? 🤔 even it doesn't calculate properly after 46th number https://code.sololearn.com/caP8649IZ2fH/?ref=app
3 Respuestas
+ 5
Try using #include <stdint.h> and uint64_t instead of int so you can use the maximum number an int can store
+ 3
This will be due to an overflow error. Data types have a limit due to the way they store numbers, after the 46th you kind of 'loop around' into the negatives. Try using a long data type instead - however this has a limit too and at some point will suffer from the same issue
+ 3
~ swim ~ I often used those long and short data types, but with the standardized types it's way easier to understand and maintain the code because you see directly how large every int it is