Bug #78688 [NEW]: Invalid float serialization

From: Date: Fri, 18 Oct 2019 11:33:58 +0000
Subject: Bug #78688 [NEW]: Invalid float serialization
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-223243@lists.php.net to get a copy of this message
From:             eirik at nymedia dot no
Operating system: Linux/OSX
PHP version:      7.3.10
Package:          Scripting Engine problem
Bug Type:         Bug
Bug description:Invalid float serialization

Description:
------------
I noticed when encoding a json object that the float 440.0 was not
encoded correctly. So I looked into it, and when the float 440.0 is
constructed with the following multiplication it fails to serialize,
var_export and json_encode properly (and probably others):

$var = "4.400000" * 100;

Test script:
---------------
$var = "4.400000" * 100;
var_export($var);
print PHP_EOL;
print json_encode($var);
print PHP_EOL;
print serialize($var);
print PHP_EOL;

// Output:
// 440.00000000000006
// 440.00000000000006
// d:440.00000000000006;

Expected result:
----------------
440.0
440
d:440;

Actual result:
--------------
440.00000000000006
440.00000000000006
d:440.00000000000006;

-- 
Edit bug report at https://bugs.php.net/bug.php?id=78688&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=78688&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=78688&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=78688&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=78688&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=78688&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=78688&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=78688&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=78688&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=78688&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=78688&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78688&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=78688&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=78688&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=78688&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=78688&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=78688&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=78688&r=mysqlcfg


Thread (4 messages)

« previous php.bugs (#223243) next »