Re: Zero-fill right shift.
| From: | Andrea Faulds | Date: | Tue, 03 Feb 2015 14:49:27 +0000 |
| Subject: | Re: Zero-fill right shift. | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-81717@lists.php.net to get a copy of this message | ||
Hi,
> On 3 Feb 2015, at 14:43, Leigh <leight@gmail.com> wrote:
>
> On 3 February 2015 at 14:36, Andrea Faulds <ajf@ajf.me> wrote:
>> I don’t know where you got that idea. The binary ops are consistent - they aren’t
>> constrained by register size like in previous PHP versions, but they’re still completely
>> consistent.
>>
>
> php -r 'var_dump(1 << 65);'
> int(2)
>
> Rotate left gets broken.
It’s not “broken”, the behaviour is just different to account for it now being an
arbitrary-precision type. If you want to “rotate left”, bitmasking does exist.
>
>> It’s slower, yes, but that hardly matters. If people care so much about performance, why
>> use PHP?
>>
>
> If people didn't care about performance, we wouldn't have phpng, or
> any of the other work people have done to make the engine faster.
>
> Sometimes you have to make the most of what you have available.
OK, performance is not unimportant. But in most cases, arbitrary-precision integers are not going to
be a bottleneck for your web app.
Also, the bigint changes only affect you if you’re dealing with large integers anyway. If you want
to preserve the horrid float promotion behaviour, you can do so explicitly. But I think in most
cases, it’s better to trade off performance for lack of data loss.
--
Andrea Faulds
http://ajf.me/