…, PHP just brought me a new definition of “portable” – and that was when working with… integers. PHP is not able to handle unsigned integers… PHP decides to treat them as integers, you’re in trouble. Oh wait, no – that’s on 32-bit platforms only! PHP int… 2007 now but there’s no native 64-bit integer type in PHP. Let me remind that built-in “int” might be…
Comment: Integers in PHP, running with scissors, and portability
…’s also documented on http://www.php.net/manual/en/language.types.integer.php: “The size of an integer is platform-dependent, although a… functions (http://www.php.net/manual/en/function.pack.php) as they allow you using machine dependent formats: i signed integer (machine dependent size and byte order) I unsigned integer (machine…
Post: PHP vs. BIGINT vs. float conversion caveat
… had already written about the mess that 64-bit integers are in PHP. But if the numbers you use do not cover… that PHP floats are in fact doubles, i.e. double-precision 64-bit numbers. They have 52 bits for mantissa, and integer….0: s1=1125899906842625 s2=1125899906842625 However 32-bit FreeBSD with PHP 4.4.7 produces different results: s1=1.1258999068426E+15…
Comment: PHP vs. BIGINT vs. float conversion caveat
… have a php function call on each op). About php and large integers, it never supported anything else than 32bits integer. Whether the integer was stored in the system default integer (64bits…
Comment: PHP vs. BIGINT vs. float conversion caveat
… php.net/float by the way). Doubles have 52 bits allocated for mantissa, which means that 52-bit (actually 53-bit) INTEGER values MUST be stored without ANY precision loss. > PHP tries to handle this in a… of scope. One should be able to manipulate 52-bit integer values stored as doubles without any precision loss. That actually…
Comment: Integers in PHP, running with scissors, and portability
[...] Integers in PHP, running with scissors, and portability | MySQL Performance Blog (tags: php integer bug) [...]
Comment: MySQL automatic data truncation can backfire
… fact 64bit php returns a 64 bit signed integer which wont wrap at the same position as a 32bit signed integer. I’ve… is negative and then store all crc32 values as unsigned integers in mysql.
Comment: PHP vs. BIGINT vs. float conversion caveat
… excerpt Sometimes you need to work with big numbers in PHP (gulp). For example, sometimes 32-bit identifiers are not enough… had already written about the mess that 64-bit integers are in PHP. But if the numbers you use do not cover… fully, floats might save the day. The trick is that PHP floats are in fact doubles, i.e. double-precision 64…
Comment: Integers in PHP, running with scissors, and portability
… PHP_INT_SIZE. However, this bit is hidden pretty well IMO. PHP_INT_SIZE is neither mentioned in the section on integer types, nor can be easily found in the documentation (results from http://www.php.net/results.php?q=int…
Post: MySQL automatic data truncation can backfire
… problem I found out PHP and MySQL are both to blame. PHP is to blame because in 32bit PHP version result of crc32() function was returned as signed integer, in 64bit build of same PHP…

