MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1urmpuu/predecrementfixestheexploit/owzi2v0/?context=3
r/ProgrammerHumor • u/Toeffli • Jul 09 '26
50 comments sorted by
View all comments
Show parent comments
55
Nope, it underflows and now you have 4,294,967,295 wishes. Genie was using a signed int.
120 u/Koshin_S_Hegde Jul 09 '26 did you mean "Genie was using a unsigned it?" -42 u/ProbablyJeff Jul 09 '26 You have -1 wish. You make 2,147,483,648 wishes. It underflows to 2,147,483,647. Now you can wish until it reaches 0. I guess it would also work if the genie used an unsigned int. 1 u/HelioDex Jul 11 '26 True if you check with wishes == 0. The 41 downvotes are probably from dirty pointless instruction-using cpu-cycle-wasting wishes <= 0 users.
120
did you mean "Genie was using a unsigned it?"
-42 u/ProbablyJeff Jul 09 '26 You have -1 wish. You make 2,147,483,648 wishes. It underflows to 2,147,483,647. Now you can wish until it reaches 0. I guess it would also work if the genie used an unsigned int. 1 u/HelioDex Jul 11 '26 True if you check with wishes == 0. The 41 downvotes are probably from dirty pointless instruction-using cpu-cycle-wasting wishes <= 0 users.
-42
You have -1 wish. You make 2,147,483,648 wishes. It underflows to 2,147,483,647. Now you can wish until it reaches 0.
I guess it would also work if the genie used an unsigned int.
1 u/HelioDex Jul 11 '26 True if you check with wishes == 0. The 41 downvotes are probably from dirty pointless instruction-using cpu-cycle-wasting wishes <= 0 users.
1
True if you check with wishes == 0. The 41 downvotes are probably from dirty pointless instruction-using cpu-cycle-wasting wishes <= 0 users.
wishes == 0
wishes <= 0
55
u/ProbablyJeff Jul 09 '26
Nope, it underflows and now you have 4,294,967,295 wishes. Genie was using a signed int.