Maximum INT size for 32-bit system

Suppose we are talking about a 32-bit system.

PHP does not support unsigned INT. This means that the value of INT should be from -2,147,483,648 to 2,147,483,647. And INT takes 4 bytes to store a 32-bit value.

Does this mean that I have only 31 bits for the value and 1 bit for the sign? Or can I use the whole 32 bits to store the value?

+1
source share
7 answers

You use all 32 bits. It's just that the output functions by default interpret it as a signed integer. If you want to display the value "raw", use:

printf("%u", -1);    //  %u for unsigned

PHP , , , , / .. - , ints.

+4

, (, 10k), bcmath .

-, php , . entropy ( 0 [1]) 1, 31 , , 31, 2 32= 4 294 967 296 . , .


[1] - 0 , .

+1

, 32- - , 2147483647, float, float php 10000000000000.

+1

32- unsigned , . , (-1) +1 1 , unsigned, , , unsigned , , true, . , 32 , , 1 , , .

0
0

2147483647 - 2 ^ 31-1. 1 -1, 0.

: " , - (32 ). 64- 9E18. PHP . Integer PHP_INT_SIZE PHP_INT_MAX PHP 4.4.0 PHP 5.0.5."

0

Yes, if he used an unsigned integer, he would use 32-bit for storage, since you do not need a character in this case, but since it only supports signed integers, 32-bit systems will have 31 bits for the value and 1 bit for sign s0 maximum signed integer range from -2147483648 to 2147483647.

0
source

Source: https://habr.com/ru/post/1672274/


All Articles