Bug #80796 [NEW]: decbin errors out on 32-bit PHP installs with "negative" numbres
| From: | terrafrost@php.net | Date: | Wed, 24 Feb 2021 16:38:55 +0000 |
| Subject: | Bug #80796 [NEW]: decbin errors out on 32-bit PHP installs with "negative" numbres | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-232382@lists.php.net to get a copy of this message | ||
From: terrafrost
Operating system: Windows 10
PHP version: 8.0.2
Package: Math related
Bug Type: Bug
Bug description:decbin errors out on 32-bit PHP installs with "negative" numbres
Description:
------------
decbin(float(0xFFFFFFFF)) produces an error on 32-bit PHP 8 installs but
decbin(float(0x7FFFFFFF)) doesn't.
On 32-bit installs 0xFFFFFFFF is outside the range of a signed 32-bit
integer so it can't be represented as anything other than a float but
still... I wonder if maybe allowing for floats might not be a bad
idea?
This is, in particular, an issue on Raspberry Pi's.
I mean if it's intended behavior that's cool too - just seems like it
could be an oversight.
Test script:
---------------
<?php
echo decbin(floatval(0xFFFFFFFF)) . "\n"; // errors out on PHP 8; works
fine on PHP 7.4
echo decbin(floatval(0x7FFFFFFF)) . "\n"; // works fine on PHP 8 and PHP
7.4
Expected result:
----------------
11111111111111111111111111111111
Actual result:
--------------
Fatal error: Uncaught TypeError: decbin(): Argument #1 ($num) must be of
type int, float given
--
Edit bug report at https://bugs.php.net/bug.php?id=80796&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80796&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80796&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80796&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80796&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80796&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80796&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80796&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80796&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80796&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80796&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80796&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80796&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80796&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80796&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80796&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80796&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80796&r=mysqlcfg