Bug #67183 [Com]: Caret (power of) in for results in infinite loop

From: Date: Sat, 03 May 2014 01:13:22 +0000
Subject: Bug #67183 [Com]: Caret (power of) in for results in infinite loop
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-185590@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67183&edit=1

 ID:                 67183
 Comment by:         anon at anon dot anon
 Reported by:        ianbytchek at gmail dot com
 Summary:            Caret (power of) in for results in infinite loop
 Status:             Not a bug
 Type:               Bug
 Package:            *General Issues
 Operating System:   OSX
 PHP Version:        5.5.12
 Block user comment: N
 Private report:     N

 New Comment:

Caret isn't "power of", it's xor. 2^10 is 8, not 1024. If you want
1024, use 1<<10 or pow(2, 10).


Previous Comments:
------------------------------------------------------------------------
[2014-05-02 20:23:23] requinix@php.net

Yup, that's precedence.

http://www.php.net/manual/en/language.operators.precedence.php

------------------------------------------------------------------------
[2014-05-02 20:17:58] ianbytchek at gmail dot com

Description:
------------
This doesn't work.

for ($i = 0; $i < 2 ^ 10; $i++) {
    echo $i;
}

This does.

for ($i = 0; $i < (2 ^ 10); $i++) {
    echo $i;
}

Is it actually a bug or is that how op precedence is expected to work here?

Test script:
---------------
for ($i = 0; $i < 2 ^ 10; $i++) {
    echo $i;
}



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=67183&edit=1


Thread (4 messages)

« previous php.bugs (#185590) next »