Re: [RFC] intdiv()
| From: | Andrea Faulds | Date: | Thu, 17 Jul 2014 07:08:53 +0000 |
| Subject: | Re: [RFC] intdiv() | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-75651@lists.php.net to get a copy of this message | ||
On 17 Jul 2014, at 08:02, Zeev Suraski <zeev@zend.com> wrote:
> I think it is, given I believe it's the first time people are asking for
> this after PHP's been out for almost two decades...
> As the RFC itself suggests, you can use the current division for most use
> cases, including the ones mentioned above - they'd work in the vast
> majority of cases.
Yes, but as previously mentioned, beyond 2^52 it breaks down. What’s more worrying is the code out
there written by people obviously unaware of this, but I shouldn’t use MtGox’s incompetence as a
reason to fix PHP ;)
> I think the RFC should mention that it's already possible to do it using
> bcmath or gmp;
It’s not possible to do with bcmath or gmp within the brief of “find the quotient of the
division of two longs without requiring an extension”. Neither bcmath nor gmp is core PHP, and
neither operate on longs, though you can be silly and convert a long to a string, in bcmath’s
case, or a gmp object, in gmp’s case, then do the operation, then convert back, checking for the
two failure cases, of course.
> That said, I tend to agree that we should have something
> like that in ext/standard, so I'm actually in favor of doing it - just not
> as an operator.
Well, that’s better than nothing I suppose, but I’d still rather use something infix.
> To be honest, that operator was simply copied verbatim from Perl, back in
> the day when Perl ruled the Web world and minimizing the learning curve
> for Perl developers was an important goal. Not sure if we'd add it to the
> language had we not 'plagiarized' it from Perl…
Huh? ** was added by an RFC this year. Actually, since 5.6 isn’t out yet, it’s technically not
part of PHP yet...
--
Andrea Faulds
http://ajf.me/