|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9292 Odd behavior adding negative numbers.
Submitted: 2001-02-15 21:10 UTC Modified: 2001-02-15 21:30 UTC
From: jdj at darkside dot dynup dot net Assigned:
Status: Closed Package: Math related
PHP Version: 4.0.4pl1 OS: Linux, *BSD, no clue about win32
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
22 - 19 = ?
Subscribe to this entry?

 [2001-02-15 21:10 UTC] jdj at darkside dot dynup dot net
Ok guys.. I've looked everywhere and cannot find an explanation
for this behavior.  Could you guys explain it? :)

This script returns the same thing on 4.0.4p1 and 4.0.3p1.

/* Anything less than 3.2/-0.32 exhibits this behavior.  Anything above it doesn't */
$x = 0.1 * 3.2;
$y = -0.32;

$a = $x - $y;
$b = $x + $y;


I can increase the 3.2 and the -0.32 and the return is sane.. everything I've tried below 3.2 returns this oddity.
Output from above script..
0.32    -0.32

0.64    5.5511151231258E-17

Any clues?


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-15 21:30 UTC] jdj at darkside dot dynup dot net
Nevermind.. it's just the nature of the beast ;)
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Dec 03 02:01:26 2023 UTC