June 20, 2013

Post: Integers in PHP, running with scissors, and portability

…, PHP just brought me a new definition of “portable” – and that was when working with… integers. PHP is not able to handle unsigned integers… data from binary strings to PHP variables. What if you try to unpack unsigned 32-bit big endian integer (format code “N”)? Let… 2007 now but there’s no native 64-bit integer type in PHP. Let me remind that built-in “int” might be…

Post: PHP vs. BIGINT vs. float conversion caveat

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… that PHP floats are in fact doubles, i.e. double-precision 64-bit numbers. They have 52 bits for mantissa, and integer

Comment: Integers in PHP, running with scissors, and portability

Type size depending on architecture is definitely a big problem in PHP if you try to have your code working on both…’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…

Comment: PHP vs. BIGINT vs. float conversion caveat

….php.net/package/big_int It is relatively fast (given that you 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

… a quick excerpt Sometimes you need to work with big numbers in PHP (gulp). For example, sometimes 32-bit identifiers are not… 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…