Eğer çok büyük sayılarla çalışmak için izin, özel kütüphaneler almamak, ne büyük PHP saklayabilirsiniz int var?
Kimden PHP manual:
The size of an integer is platform-dependent, although a maximum value of about two billion is the usual value (that's 32 bits signed). PHP does not support unsigned integers. Integer size can be determined using the constant PHP_INT_SIZE, and maximum value using the constant PHP_INT_MAX since PHP 4.4.0 and PHP 5.0.5.
32-bit builds of PHP:
64-bit builds of PHP:
Sayılar dahildir.
Bu aralıklar içinde olmayan değerleri tam olarak bu aralıkların dışında değerler genellikle, Kayan nokta değerleri ile temsil edilmektedir.
32-bit ve 64-bit yapıları arasında bazı diğer alışılmadık farklılıklar vardır. 64-bit 2147483647 yukarıda elde edilen değerleri oluşturur olumlu kalır ise Örneğin, bir 32-bit, CRC32 (negatif tamsayılar olmak için 2147483647 Yukarıdaki değerleri sonuçlanan) fonksiyonu sarar oluşturmak. Bu, the output of crc32() is incompatible between 32-bit and 64-bit builds unless you do some correction on the result afterwards.
PHP gibi "imzasız" tamsayılar için destek vardır.
PHP ints boyutu platform dependent:
The size of an integer is platform-dependent, although a maximum value of about two billion is the usual value (that's 32 bits signed). PHP does not support unsigned integers. Integer size can be determined using the constant PHP_INT_SIZE, and maximum value using the constant PHP_INT_MAX since PHP 4.4.0 and PHP 5.0.5.
PHP 6 "uzun ürünler" (64 bit ints) ekler.
(Biraz geç, ama yararlı olabilir)
Sadece güven PHP_INT_MAX and PHP_INT_SIZE, bu değer kemerin (32/64 bit) üzerinde değişir ve işletim ...
Başka herhangi bir "tahmin" veya "ipucu" yanlış olabilir.
Bu OS bağlıdır, ancak 2147483647 manual göre, olağan değerdir.
Ah ben buldum: 2 32 - 1 (2147483647)
Integer overflow
PHP tamsayı türü sınırlarının ötesinde bir numara karşılaşırsa, bunun yerine bir float olarak yorumlanır. Ayrıca, tamsayı türü sınırlarının ötesinde bir dizi sonuçlanan bir operasyon yerine, bir float dönecektir.
<?php
$large_number = 2147483647;
var_dump($large_number);
// output: int(2147483647)
$large_number = 2147483648;
var_dump($large_number);
// output: float(2147483648)