On 18 Jul 2014, at 04:39, Tjerk Meesters tjerk.meest...@gmail.com wrote:
This makes it more complicated because a language change requires 2/3
majority while a new function requires 50% + 1.
To make things simpler - and I believe it had been proposed before - the
main vote should include
On 17 Jul 2014, at 04:23, Sara Golemon poll...@php.net wrote:
Do we need a new operator for that? It feels un-php to me, and the
kind of problem bigint objects should be meant to solve. On the other
hand, having $a/$b != $a/$b (Off by more than 100 in this instance).
But back on the first
On 17 Jul 2014, at 01:11, Bishop Bettini bis...@php.net wrote:
As another contender, how about:
$x = 242 %/ 7;
$x %/= 13;
The % reflects the relationship to modulus, while the / reflects the division
effect. I think %/ looks worse, but I think it seems more apropos.
I also quite
-Original Message-
From: Andrea Faulds [mailto:a...@ajf.me]
Sent: Wednesday, July 16, 2014 6:15 PM
To: bis...@php.net
Cc: PHP internals
Subject: Re: [PHP-DEV] [RFC] intdiv()
The RFC has been updated to v0.2. It now proposes a %% operator for
integer
division (with corresponding
-Original Message-
From: Kris Craig [mailto:kris.cr...@gmail.com]
Sent: Thursday, July 17, 2014 6:02 AM
To: Andrea Faulds
Cc: Stas Malyshev; PHP internals
Subject: Re: [PHP-DEV] [RFC] intdiv()
On Tue, Jul 15, 2014 at 5:13 AM, Andrea Faulds a...@ajf.me wrote:
Perhaps the RFC could
On 17 Jul 2014, at 07:29, Zeev Suraski z...@zend.com wrote:
From debating whether it's worth it to add a new function for an
not-so-commonly-used-operation-to-say-the-least, we're now seriously
considering adding a new language level operator? Really?
Is it *really* not that common? I can
Hi Andrea,
On Thu, Jul 17, 2014 at 8:44 AM, Andrea Faulds a...@ajf.me wrote:
On 17 Jul 2014, at 07:29, Zeev Suraski z...@zend.com wrote:
From debating whether it's worth it to add a new function for an
not-so-commonly-used-operation-to-say-the-least, we're now seriously
considering adding a
On 17 Jul 2014, at 07:56, Pierre Joye pierre@gmail.com wrote:
The rare cases where I had to do that, I relied on bcmath or gmp. Yes,
I needed some extra ops to actually achieve what this RFC proposes but
it is good enough. The new ops overloading for extension simplifies
that a lot as
-Original Message-
From: Andrea Faulds [mailto:a...@ajf.me]
Sent: Thursday, July 17, 2014 9:44 AM
To: Zeev Suraski
Cc: bis...@php.net; PHP internals
Subject: Re: [PHP-DEV] [RFC] intdiv()
On 17 Jul 2014, at 07:29, Zeev Suraski z...@zend.com wrote:
From debating whether it's
On 17 Jul 2014, at 08:02, Zeev Suraski z...@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
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
-Original Message-
From: Andrea Faulds [mailto:a...@ajf.me]
Sent: Thursday, July 17, 2014 10:09 AM
To: Zeev Suraski
Cc: bis...@php.net; PHP internals
Subject: Re: [PHP-DEV] [RFC] intdiv()
On 17 Jul 2014, at 08:02, Zeev Suraski z...@zend.com wrote:
I think it is, given I believe
On 17/07/14 04:23, Sara Golemon wrote:
Wow. I just finally understood what your RFC was going for. I thought
you were trying to cover the case where ($a%$b)==0, but you're not,
you're trying to do truncated integer division regardless of
remainder. I also missed the fact that div_function
On 17 Jul 2014, at 08:19, Zeev Suraski z...@zend.com wrote:
PHP's not Perl. Let's keep it that way please…
I don't think it makes sense to add a
specialized integer division operator when we do have a different division
operator, and I don't think other dynamic languages have such an
On 17/07/14 08:02, Zeev Suraski 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
On 17 Jul 2014, at 08:17, Stas Malyshev smalys...@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
On Thu, Jul 17, 2014 at 2:25 AM, Sara Golemon poll...@php.net wrote:
On Wed, Jul 16, 2014 at 8:15 AM, Andrea Faulds a...@ajf.me wrote:
Nikita Popov doesn’t seem to be a fan of the %% syntax, so it may be
subject to change, though I think it’s the best I’ve heard so far. ;)
Nor am I.
On 17 Jul 2014, at 10:24, Nikita Popov nikita@gmail.com wrote:
This is already what is currently happening, see
http://lxr.php.net/xref/PHP_TRUNK/Zend/zend_operators.c#1067.
Andreas proposal is only useful in the case that the numbers don't divide
exactly and you need
On Thu, Jul 17, 2014 at 6:31 AM, Andrea Faulds a...@ajf.me wrote:
On 17 Jul 2014, at 10:24, Nikita Popov nikita@gmail.com wrote:
This is already what is currently happening, see
http://lxr.php.net/xref/PHP_TRUNK/Zend/zend_operators.c#1067.
Andreas proposal is only useful in the
On Fri, Jul 18, 2014 at 10:47 AM, Kris Craig kris.cr...@gmail.com wrote:
On Thu, Jul 17, 2014 at 6:31 AM, Andrea Faulds a...@ajf.me wrote:
On 17 Jul 2014, at 10:24, Nikita Popov nikita@gmail.com wrote:
This is already what is currently happening, see
On Thu, Jul 17, 2014 at 8:39 PM, Tjerk Meesters tjerk.meest...@gmail.com
wrote:
On Fri, Jul 18, 2014 at 10:47 AM, Kris Craig kris.cr...@gmail.com wrote:
On Thu, Jul 17, 2014 at 6:31 AM, Andrea Faulds a...@ajf.me wrote:
On 17 Jul 2014, at 10:24, Nikita Popov nikita@gmail.com wrote:
On Fri, Jul 18, 2014 at 12:04 PM, Kris Craig kris.cr...@gmail.com wrote:
On Thu, Jul 17, 2014 at 8:39 PM, Tjerk Meesters tjerk.meest...@gmail.com
wrote:
On Fri, Jul 18, 2014 at 10:47 AM, Kris Craig kris.cr...@gmail.com
wrote:
On Thu, Jul 17, 2014 at 6:31 AM, Andrea Faulds a...@ajf.me
On Thu, Jul 17, 2014 at 9:18 PM, Tjerk Meesters tjerk.meest...@gmail.com
wrote:
On Fri, Jul 18, 2014 at 12:04 PM, Kris Craig kris.cr...@gmail.com wrote:
On Thu, Jul 17, 2014 at 8:39 PM, Tjerk Meesters tjerk.meest...@gmail.com
wrote:
On Fri, Jul 18, 2014 at 10:47 AM, Kris Craig
On 16 Jul 2014, at 02:51, Bishop Bettini bis...@php.net wrote:
TL;DR -- I agree with the principal but want implemented as the infix
operator %% with a test for PHP_INT_MIN %% -1 === false (and a E_WARNING).
The RFC has been updated to v0.2. It now proposes a %% operator for integer
division
As another contender, how about:
$x = 242 %/ 7;
$x %/= 13;
The % reflects the relationship to modulus, while the / reflects the
division effect. I think %/ looks worse, but I think it seems more apropos.
On Jul 16, 2014 11:15 AM, Andrea Faulds a...@ajf.me wrote:
On 16 Jul 2014, at 02:51,
On Wed, Jul 16, 2014 at 8:15 AM, Andrea Faulds a...@ajf.me wrote:
Nikita Popov doesn’t seem to be a fan of the %% syntax, so it may be subject
to change, though I think it’s the best I’ve heard so far. ;)
Nor am I. Here's a thought though: How about just making / return int
when there's no
Hi Sara,
On Thu, Jul 17, 2014 at 8:25 AM, Sara Golemon poll...@php.net wrote:
On Wed, Jul 16, 2014 at 8:15 AM, Andrea Faulds a...@ajf.me wrote:
Nikita Popov doesn’t seem to be a fan of the %% syntax, so it may be
subject to change, though I think it’s the best I’ve heard so far. ;)
Nor am
On Wed, Jul 16, 2014 at 6:51 PM, Tjerk Meesters
tjerk.meest...@gmail.com wrote:
Just out of curiosity, does the compiler optimise it into something like
this?
if (a % b) {
return a / b;
} else {
return (double)a / b;
}
Ya know what? I feel dumb. FP division is a whole separate
On July 17, 2014 at 3:17 AM Sara Golemon poll...@php.net wrote:
All that said, *I* think the tradeoff of an extra idivq in the
(probably more common) remainder case is worth it in the interest
keeping PHP's syntax simple.
What are you suggesting you do for an integer division, then? ($a -
On Wed, Jul 16, 2014 at 7:34 PM, Andrea Faulds a...@ajf.me wrote:
What are you suggesting you do for an integer division, then? ($a - ($a %
$b)) /
$ b? The division operator already returns an integer. Or should I just use
intdiv()?
It does, but it returns the float truncated result of
On Tue, Jul 15, 2014 at 5:13 AM, Andrea Faulds a...@ajf.me wrote:
On 15 Jul 2014, at 06:50, Kris Craig kris.cr...@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
On Wed, Jul 16, 2014 at 7:34 PM, Andrea Faulds a...@ajf.me wrote:
What are you suggesting you do for an integer division, then? ($a - ($a %
$b)) /
$ b? The division operator already returns an integer. Or should I just use
intdiv()?
Wow. I just finally understood what your RFC was going for.
Hi all,
On Thu, Jul 17, 2014 at 12:23 PM, Sara Golemon poll...@php.net wrote:
On Wed, Jul 16, 2014 at 7:34 PM, Andrea Faulds a...@ajf.me wrote:
What are you suggesting you do for an integer division, then? ($a - ($a
% $b)) /
$ b? The division operator already returns an integer. Or should
On 15/07/14 06:17, Stas Malyshev wrote:
Both of those are likely not to be installed on most systems. Why do
Why not? bcmath is in core since forever and has no external
requirements, gmp builds practically everywhere too. AFAIR all distros
have it.
Taking this in isolation is wrong ...
It is
On 15 Jul 2014, at 03:31, Bishop Bettini bis...@php.net wrote:
I need some education. Can you elaborate on the specific situations where
integer division would be used without other functions from bcmath or gmp?
I see in the RFC you mention seconds to hh:mm and index to rows/cols, but can
On 15 Jul 2014, at 06:50, Kris Craig kris.cr...@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
On 15 Jul 2014, at 08:06, Lester Caine les...@lsces.co.uk wrote:
Taking this in isolation is wrong ...
It is essentially linked up with all of the discussion on '64bit'
processing. What seems to be ignored so far is the simple 'bigint'
value. Limiting 32 bit systems to only support 32 bit
On 15 Jul 2014, at 06:17, Stas Malyshev smalys...@sugarcrm.com wrote:
Why not? bcmath is in core since forever and has no external
requirements, gmp builds practically everywhere too. AFAIR all distros
have it.
Partly practicality, partly principle. A barebones installation of PHP may not
Hi Andrea,
On Tue, Jul 15, 2014 at 11:10 AM, Yasuo Ohgaki yohg...@ohgaki.net wrote:
On Tue, Jul 15, 2014 at 9:14 AM, Andrea Faulds a...@ajf.me wrote:
PHP currently lacks a way to do integer division. You can floor or int
cast a floating-point division, but beyond 53-bits that produces the
On 15 Jul 2014, at 23:12, Yasuo Ohgaki yohg...@ohgaki.net wrote:
If we are going to have integer arithmetics, it may be better to have full
set of operators/functions
https://bugs.php.net/bug.php?id=30701
I’d rather not go to that length, but if someone wants to do that, they may.
Hi Andrea,
TL;DR -- I agree with the principal but want implemented as the infix
operator %% with a test for PHP_INT_MIN %% -1 === false (and a E_WARNING).
As a user, I could implement intdiv and get the same functionality as
proposed:
function intdiv($n, $d) { return (int)($n / $d); }
On 16 Jul 2014, at 02:51, Bishop Bettini bis...@php.net wrote:
Hi Andrea,
TL;DR -- I agree with the principal but want implemented as the infix
operator %% with a test for PHP_INT_MIN %% -1 === false (and a E_WARNING).
%% is perhaps the only good non-keyword syntax choice. I like that.
Good evening again,
PHP currently lacks a way to do integer division. You can floor or int cast a
floating-point division, but beyond 53-bits that produces the wrong result:
$ sapi/cli/php -r 'var_dump((int)(PHP_INT_MAX / 3));'
int(3074457345618258432)
Furthermore, using a floating-point
Hi!
It elaborates a little more, so I’d suggest reading it first. What
are your thoughts? I think this is a simple and obvious addition.
INT_MAX is kind of an edge case, if you need arbitrary-length precision
you can always use gmp or bcmath. I'm not sure this one-off use case
that is already
On 15 Jul 2014, at 01:58, Stas Malyshev smalys...@sugarcrm.com wrote:
INT_MAX is kind of an edge case,
It’s just an obvious example, integers beyond 2^53 fulfill this.
if you need arbitrary-length precision
you can always use gmp or bcmath.
I’m not asking for arbitrary-length precision,
Hi Andrea,
On Tue, Jul 15, 2014 at 9:14 AM, Andrea Faulds a...@ajf.me wrote:
PHP currently lacks a way to do integer division. You can floor or int
cast a floating-point division, but beyond 53-bits that produces the wrong
result:
$ sapi/cli/php -r 'var_dump((int)(PHP_INT_MAX / 3));'
Hi Andrea,
I need some education. Can you elaborate on the specific situations where
integer division would be used without other functions from bcmath or gmp?
I see in the RFC you mention seconds to hh:mm and index to rows/cols, but
can you give some actual before and after samples? Like this
Hi!
Both of those are likely not to be installed on most systems. Why do
Why not? bcmath is in core since forever and has no external
requirements, gmp builds practically everywhere too. AFAIR all distros
have it.
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
--
On Mon, Jul 14, 2014 at 10:17 PM, Stas Malyshev smalys...@sugarcrm.com
wrote:
Hi!
Both of those are likely not to be installed on most systems. Why do
Why not? bcmath is in core since forever and has no external
requirements, gmp builds practically everywhere too. AFAIR all distros
have
49 matches
Mail list logo