Why can not I store the value '4294967295' in an integer of 4 bytes?

3

I would like to know why I can not store the value '4294967295' in a% byte of 4 bytes and the quoted value converted to binary gives exactly 4 bytes (or 32 bits)?

    
asked by anonymous 03.05.2018 / 05:45

1 answer

6

Because it does not fit in int . % W / o% has both positive and negative numbers. Because of this it goes up to 2147483647, precisely because it goes from -2147483648 to 2147483647.

Note that both int and uint32 have 4 bytes and also have 4294967296 possible numbers. The difference is that one starts from zero and the other does not, you will be able to use 4294967295 if you use int32 . This is because one of the bits will be used as any data, rather than a signal. The uint uses a bit as a signal, while 1 is negative, for example.

    
03.05.2018 / 06:01