Different Values for intval(float)

From: Date: Sat, 18 Feb 2006 15:36:56 +0000
Subject: Different Values for intval(float)
Groups: php.general 
Request: Send a blank email to php-general+get-230689@lists.php.net to get a copy of this message
Consider the following code: $BB = -2181087916; $AA = (int)$BB; $AA = intval($BB); On some systems, $AA will be int(-2147483648), which is actually consistent with the documentation. On most systems, however, $AA will be int(2113879380), which is the same value truncated at 32 bits. I actually need the latter behavior, as it needs to duplicate Delphi code, which, like C, behaves the same way. This is encryption code that does a bunch of calculations on signed 32-bit numbers and ignores any overflows. Any ideas how I can do this?

« previous php.general (#230689) next »