Bug #68600 [NEW]: shift
| From: | armenhak59 at yahoo dot com | Date: | Sat, 13 Dec 2014 07:41:55 +0000 |
| Subject: | Bug #68600 [NEW]: shift | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-189047@lists.php.net to get a copy of this message | ||
From: armenhak59 at yahoo dot com
Operating system: windows 7 32 bit
PHP version: 5.5.19
Package: Compile Failure
Bug Type: Bug
Bug description:shift
Description:
------------
<?php
echo "SHIFT LEFT DO NOT WORKS RIGHT FOR NEGATIV NUMBER -1, BUT WORKS FOR
OTHER NUMBERS<br><br>";
$format = '%0' . 32 . "b<br>";
$val = -1;
echo "<br> WRONG FOR -1<br>";
printf(" val = %d String: %s = %d %s %d<br>", $val, 'res', $val,
'<<',
32);
$val = $val << 32;
printf(' val = ' . $format, $val);
echo "<br> IT MUST BE <br>";
printf('..... = ' . $format, 0);
echo "<br><br><br>FOR OTHER NUMBERS IT WORKS CORRECT:";
printf("<br><br> val = %d String: %s = %d %s %d<br>", $val,
'res',
$val, '<<', 1);
$val = $val << 1;
printf(' val = ' . $format, $val);
printf("<br><br> val = %d String: %s = %d %s %d<br>", $val,
'res',
$val, '<<', 31);
$val = $val << 31;
printf(' val = ' . $format, $val);
?>
Test script:
---------------
<?php
echo "SHIFT LEFT DO NOT WORKS RIGHT FOR NEGATIV NUMBER -1, BUT WORKS FOR
OTHER NUMBERS<br><br>";
$format = '%0' . 32 . "b<br>";
$val = -1;
echo "<br> WRONG FOR -1<br>";
printf(" val = %d String: %s = %d %s %d<br>", $val, 'res', $val,
'<<',
32);
$val = $val << 32;
printf(' val = ' . $format, $val);
echo "<br> IT MUST BE <br>";
printf('..... = ' . $format, 0);
echo "<br><br><br>FOR OTHER NUMBERS IT WORKS CORRECT:";
printf("<br><br> val = %d String: %s = %d %s %d<br>", $val,
'res',
$val, '<<', 1);
$val = $val << 1;
printf(' val = ' . $format, $val);
printf("<br><br> val = %d String: %s = %d %s %d<br>", $val,
'res',
$val, '<<', 31);
$val = $val << 31;
printf(' val = ' . $format, $val);
?>
--
Edit bug report at https://bugs.php.net/bug.php?id=68600&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=68600&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=68600&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=68600&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=68600&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=68600&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=68600&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=68600&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=68600&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=68600&r=support
Expected behavior: https://bugs.php.net/fix.php?id=68600&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=68600&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=68600&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=68600&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68600&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=68600&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=68600&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=68600&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=68600&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=68600&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=68600&r=mysqlcfg