Bug #67183 [Nab]: Caret (power of) in for results in infinite loop
| From: | ianbytchek at gmail dot com | Date: | Sat, 03 May 2014 09:59:55 +0000 |
| Subject: | Bug #67183 [Nab]: Caret (power of) in for results in infinite loop | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-185596@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
User updated by: ianbytchek at gmail dot com
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:
Awkwaaaaard :) thanks for pointing out.
Previous Comments:
------------------------------------------------------------------------
[2014-05-03 01:13:21] anon at anon dot anon
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).
------------------------------------------------------------------------
[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