Bug #70173 [NEW]: Precision problem in float

From: Date: Fri, 31 Jul 2015 05:53:29 +0000
Subject: Bug #70173 [NEW]: Precision problem in float
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-194849@lists.php.net to get a copy of this message
From:             rainer dot jung at kippdata dot de
Operating system: Solaris 10 Sparc
PHP version:      7.0.0beta2
Package:          *General Issues
Bug Type:         Bug
Bug description:Precision problem in float

Description:
------------
A precision problem in float makes a huge number of tests fail. It could
well be, that this is a platform specific failure (Solaris 10 Sparc, 32
Bit build).

Below you will find a test case with correct result returned from
version 5.6.11 and wrong result from 7.0.0 Beta 2.


Test script:
---------------
<?php
$var = 29000000;
var_dump($var);
$var = 290000000;
var_dump($var);
$var = 2900000000;
var_dump($var);
$var = 29000000000;
var_dump($var);
$var = 290000000000;
var_dump($var);
$var = 2900000000000;
var_dump($var);
$var = 29000000000000;
var_dump($var);
$var = 290000000000000;
var_dump($var);
$var = 2900000000000000;
var_dump($var);
?>

Expected result:
----------------
int(29000000)
int(290000000)
float(2900000000)
float(29000000000)
float(290000000000)
float(2900000000000)
float(29000000000000)
float(2.9E+14)
float(2.9E+15)


Actual result:
--------------
int(29000000)
int(290000000)
float(2899998720)
float(28999991296)
float(289999945728)
float(2899998408704)
float(28999988281344)
float(2.899999499223E+14)
float(2.8999984254812E+15)


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



Thread (16 messages)

« previous php.bugs (#194849) next »