you are viewing a single comment's thread
view the rest of the comments
[–] [S] 2 points 3 days ago (1 child)

there's integer overflow and integer underflow. when you have an 8-bit signed integer variable: signed char x = 127 and you try to increment it by 1: signed char y = x + 1 and then you print y: `printf("%d\n", int(y))", it will print -128. the reason is integer overflow, kinda like when you add 1 to 999, you get 1000. but if the variable can only store 3 digits, you get 000 instead, which is 0. the computer interprets that as a negative value though because of offset etc.

the same works in reverse. -999 - 1 = -1000 which gets interpreted as -000 which gets interpreted as a positive number then.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 3 points 3 days ago*

    Hah for some reason I thought it was arithmetic underflow but given that the original joke was integer overflow and not arithmetic overflow it makes more sense for it to be integer underflow too. And I agree fits better.

  • source
  • parent