Re: [PHP-DEV] [RFC] Integer Semantics

[email protected] (Dmitry Stogov)
Newsgroups php.internals
Message-ID <CA+9eiLvWM+59axpfMJFnqU69AV1w7Ui55FJr1RDxPqGhk8vfPA@mail.gmail.com>
On Wed, Aug 20, 2014 at 1:20 PM, Andrea Faulds <[email protected]> wrote:

>
> On 20 Aug 2014, at 06:52, Dmitry Stogov <[email protected]> wrote:
>
> > 1) INF conversion to zero seems wrong. May be +INF should be converted
> to MAX_LONG and -INF to MIN_LONG?
>
> I think of Infinity as more of an error value than an actual number. Not
> using MAX_LONG and MIN_LONG means it casts to the same value matter how
> large the integer type is, and it happens to be what JavaScript casts
> Infinity to. There’s also the fringe benefit that 1/0’s result in PHP,
> FALSE, casts to zero, as Infinity now would also, which is the standard
> IEEE 754 result for 1/0.
>
> > 3) a bit unrelated, but it also may make sense to introduce a logical
> right shift operator (>>> in Java)
>

The difference between "arithmetic" and "logical" shift is sign propagation.

0x10000000 >> 1 == 0x11000000

0x10000000 >>> 1 == 0x01000000

In C the same >> operator perform "arithmetic" shift for signed numbers and
"logical" shift for unsigned.

Thanks. Dmitry.



>
> How would that function?
> --
> Andrea Faulds
> http://ajf.me/
>
>
>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.