Re: [DRAFT][RFC] Big Integer Support
| From: | Andrea Faulds | Date: | Sat, 21 Jun 2014 19:48:02 +0000 |
| Subject: | Re: [DRAFT][RFC] Big Integer Support | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-75029@lists.php.net to get a copy of this message | ||
On 20 Jun 2014, at 15:58, Nikita Popov <nikita.ppv@gmail.com> wrote:
> Hey Andrea, this looks really interesting!
>
Glad you think so. :)
> Could you please submit a PR from your branch, so it's possible to review the code?
Oh, good idea. I’ll do so soon. I should note the patch is very much unfinished (it works, but
there are quite a few problems and I think I broke the math bit of ext/standard ;) and there are
some things I’m yet to implement. It also needs some tests of its own; at the moment I’ve just
fixed and removed the skip condition from a few 64-bit ones, with the reasoning that if this is
implemented right, they should act identically on 32-bit CPUs.
However, you can currently create bigints, they’re reference counted and copied-on-write
correctly, they don’t leak memory or segfault, and operations overflow correctly.
>
> Regarding the RFC text, I think you mixed up some left and right shifts. "<< 65 will
> result in zero" is probably supposed to be >> 65? And "right shifts will promote to
> bigints" probably is talking about left shifts?
>
Oops, yes. I’ll fix that right away.
> Btw, I wouldn't worry about the change in shifts larger than the integer width. Those have
> always been UB inherited from using UB of the C language. The cyclic behavior is only an
> idiosyncrasy of the x86 architecture - other ISAs like ARM (iirc) will not exhibit the behaviour.
Right. I’ll need to fix up the code so that it only does the necessary checks for cyclic behaviour
on the platforms which do it. Currently there’s no such check.
--
Andrea Faulds
http://ajf.me/