r/ProgrammerHumor • • Aug 14 '20

Someone try this

Post image
53.6k Upvotes

433 comments sorted by

View all comments

Show parent comments

62

u/qnsb Aug 14 '20

The post also says the highest value for a signed int, implying it uses a signed number

25

u/merlinsbeers Aug 14 '20

Nobody reviewed the post before pushing.

1

u/qnsb Aug 14 '20

Review before pushing? What do you mean?

/s

-15

u/writtenbymyrobotarms Aug 14 '20 edited Aug 14 '20

It doesn't explicitly say signed.

Edit: my argument is that the poster should have written 4,294,967,295 instead of 2,147,483,647. This post only makes sense with unsigned integers. Signed integers do not underflow at 0.

47

u/qnsb Aug 14 '20

But it does mention 2147483647 as the largest 32-bit int which is only true for signed ints

17

u/Booleard Aug 14 '20

I came in here looking for this conversation. I'm glad to see it's already here.

3

u/Serinus Aug 14 '20

I'm here for

they're value

0

u/[deleted] Aug 14 '20

[deleted]

2

u/TruthYouWontLike Aug 14 '20 edited Aug 14 '20

Each number in the series represents a value 0-15 using 0-9 and A-F. This is called hexadecimal, and is the number system used by computers to store stuff in memory. It translates directly to binary and is more human-readable.

00000000 = 0, 00000001 = 1, 0000000A = 10, 0000000F = 15, 00000010 = 16, 0000001A = (16+10) = 26, 0000002F = (16*2+15) = 47, etc. and finally, 7FFFFFFF = 2147483647, the highest number that can be represented with a signed integer, in other words, a structure that can represent a number either positive or negative.

Then it rolls over into 80000000 and starts counting backwards from 0 until FFFFFFFF which is -2147483648.

So what the guy is suggesting is you have a baby go backwards $1, which makes the system roll from 00000000 to FFFFFFFF. This would be cool if it was an unsigned integer, in other words, a structure capable of representing 0 to 4294967295, however as it is a signed integer (as suggested by the number he's putting in the post) it means baby will instead start with a whopping $2billion and change in debt.

Which is unfortunate, but not entirely untrue, given the current FED monetary policy of just printing more debt to make the economy go round.

1

u/PRIGK Aug 14 '20

In order to hold on to numbers you want, a computer has to allocate memory so that it remembers them when you want them. If you don't give it enough memory and then try to make the number too big, it will do funny things to the computer.

9

u/pseudozombie Aug 14 '20

Well, maybe they are using a 31-bit processor.

8

u/qnsb Aug 14 '20

But the post says 32-bit

1

u/pseudozombie Aug 14 '20

Oh, you're right. I missed that

2

u/l0c4lh057 Aug 14 '20

Maybe they implemented a 31 bit int just for that

3

u/qnsb Aug 14 '20

But the post says 32-bit

4

u/l0c4lh057 Aug 14 '20

Mistyped

1

u/qnsb Aug 14 '20

Well played

1

u/writtenbymyrobotarms Aug 14 '20 edited Aug 14 '20

Tell me how does a signed int32 underflow from 0 to maxint?

1

u/qnsb Aug 14 '20

It doesn't, that's the whole point here

1

u/writtenbymyrobotarms Aug 14 '20

Oh right, I didn't connect your original comment with its parent. Makes sense now.