[PATCH] Extend bitwise and modulus operators on 32-bit platforms

From: Date: Mon, 16 Mar 2009 18:00:30 +0000
Subject: [PATCH] Extend bitwise and modulus operators on 32-bit platforms
Groups: php.internals 
Request: Send a blank email to internals+get-43371@lists.php.net to get a copy of this message
Hi all, I changed the bitwise and modulus operator functions to [try to] make them more consistent with behavior on 64-bit platforms. By accepting double operands and, if necessary, returning a double, their usable range is greatly extended without running into overflow issues, etc. (Of course, at some point, double precision would be a problem, but that's not till... the trillion range/40-ish bits or so?) See also Bug #46579 (% integer overflow - no error message). That means anything like this previously only-64-bit code works as expected: var_dump(((1 << 40) | (1 << 36)) % (10000000000 >> 1));
float(3231104512)
Fairly straightforward changes after adding a couple macros... Adding zendi_convert_to_double() to the other zendi_* ones seemed to be the easiest way to handle things. And, am I right to assume that most all modern compilers have a 64-bit long type? If not, code is unchanged from before (same for 64-bit). This is mostly independent of whatever is done as far as general "double to long conversion," but it does take care of the orginal issue I had. :-) http://marc.info/?l=php-internals&m=120799720922202&w=2 Patches: http://realplain.com/php/64bit_operators.diff http://realplain.com/php/64bit_operators_5_3.diff What do you all think? Thanks, Matt

« previous php.internals (#43371) next »