Re: [RFC] intdiv()

From: Date: Tue, 15 Jul 2014 12:13:08 +0000
Subject: Re: [RFC] intdiv()
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-75534@lists.php.net to get a copy of this message
On 15 Jul 2014, at 06:50, Kris Craig <kris.craig@gmail.com> wrote: > While a practical argument can certainly be made that existing solutions can fit the examples > OP cited, I don't think that takes away from the underlying principle of the argument: That > there's no reason *not* to include a basic integer division in PHP. It's never made sense > to me why it wasn't included. Rather than an intdiv() function, though, I wonder if an > operator would be a better approach. Some languages I've seen that use / as the division > operator will use a \ as the integer division operator. We use \ for namespaces, and Python 3’s // obviously can’t be used, so I might suggest Pascal’s div operator: $minutes = ($s div 60) % 60; Failing that, div() as a built-in function much like pow() is: $minutes = div($s, 60) % 60; -- Andrea Faulds http://ajf.me/

« previous php.internals (#75534) next »