Re: [RFC] intdiv()
| From: | Andrea Faulds | Date: | Thu, 17 Jul 2014 07:41:55 +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-75657@lists.php.net to get a copy of this message | ||
On 17 Jul 2014, at 08:17, Stas Malyshev <smalyshev@sugarcrm.com> wrote:
> Hi!
>
>> * Time (actually pretty common in web apps, though we have a DateTime
>> class)
>
> Admittedly, we're getting closer to the dreaded year 2038, but what does
> it actually mean to divide current Unix timestamp by 3 and why one would
> ever want to do this? We also have classes for real datetime calculations.
To divide by three is probably a bad example, but it’s fair to point out that anything with UNIX
timestamps would work fine with just floats as we don’t need 53 bits yet.
> Here you are onto something, but how often you paginate data sets of
> MAXINT size and need exact number of pages?
Rarely, I suspect, but it would still be nice to have a proper way of doing the division
> If you're using ints for currency, you're probably doing it wrong. If
> you're dividing currency using integer division, I don't even know what
> you are trying to do, except reenacting Office Space :)
A lot of people use ints as a poor man’s fixnum, and sometimes that’s actually the right way to
implement them. IIRC, Bitcoin is implemented using 64-bit integers internally.
> You mean image processing? If 53 bit precision is not enough there, I'm
> not even sure PHP should be doing that.
True, but again, you should still ask why PHP doesn’t support integer division in the first place.
> IMHO this is not enough for a new operator... Especially if this means
> we have to tolerate something like %/.
%/ and %% are hardly the nicest operators, no. Myself I like %% as % being one part and %% being the
other part of an integer division makes sense to me, but I can see why others might not like it.
--
Andrea Faulds
http://ajf.me/