MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/i9llic/someone_try_this/g1gn9e1
r/ProgrammerHumor • u/wtfevenislifelol • Aug 14 '20
433 comments sorted by
View all comments
3
What logic/lines of code make it take an error like that and try to correct it by switching to the largest 32 bit integer?
1 u/slimscsi Aug 14 '20 Nothing tries to correct anything. This is standard twos compliment arithmetic. Except it totally wrong. Because a signed integer would go to -1, and a signed integer would be over 4 billion not 2. 1 u/techgineer13 Aug 14 '20 It's undefined behavior in unmanaged languages like C and C++, so most compilers just underflow it to "prevent" bugs.
1
Nothing tries to correct anything. This is standard twos compliment arithmetic. Except it totally wrong. Because a signed integer would go to -1, and a signed integer would be over 4 billion not 2.
It's undefined behavior in unmanaged languages like C and C++, so most compilers just underflow it to "prevent" bugs.
3
u/Painfulyslowdeath Aug 14 '20
What logic/lines of code make it take an error like that and try to correct it by switching to the largest 32 bit integer?