My operating System is windows 7 and 64bit.
Now I run following code:
echo PHP_INT_SIZE;//prints 4
echo PHP_INT_MAX;//prints 2147483647
But I think it should be 8
and (2^63-1)//^ represents power
Can anyone explain me why this happen?
My operating System is windows 7 and 64bit.
Now I run following code:
echo PHP_INT_SIZE;//prints 4
echo PHP_INT_MAX;//prints 2147483647
But I think it should be 8
and (2^63-1)//^ represents power
Can anyone explain me why this happen?
Integer size are always compiler/interpreter/platform dependent (this applies for other languages too).
In the case of PHP on Windows it does not support 64-bit integers at all, even if both the hardware and PHP are 64-bit
On windows x86_64, PHP_INT_MAX is 2147483647. This is because in the underlying c-code, a long is 32 bit.
Linux on x86_64 uses a 64bit long so PHP_INT_MAX is going to be 9223372036854775807.
If you need a bigger precision you could use either GMP or BCMath extension.
Tip: never make assumptions on the max value a type will be able to handle unless you need exactly on which php version/platform the code will run.
Your OS is 64-bits. Your PHP version is x86.
How to determine the PHP version is using the constant
PHP_INT_SIZE will return 4 for x86 version
PHP_INT_SIZE will return 8 for x64 version
Related info:
Doubleword: a 4-byte (32 bit) data item
Quadword: an 8-byte (64 bit) data item
Hope that's clear :)