php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27685 floating point?
Submitted: 2004-03-24 19:12 UTC Modified: 2004-03-24 19:22 UTC
From: ymlee at ibcenter dot co dot kr Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 4.3.4 OS: linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ymlee at ibcenter dot co dot kr
New email:
PHP Version: OS:

 

 [2004-03-24 19:12 UTC] ymlee at ibcenter dot co dot kr
Description:
------------
$a=33.6;
$b=84.7;
$c=118.3;

$d=$a+$b-$c;

echo $d;

the answer should 0.
but result is 1.4210854715202E-14.

it is strange!!!

Reproduce code:
---------------
$a=33.6;
$b=84.7;
$c=118.3;

$d=$a+$b-$c;

echo $d;


Expected result:
----------------
0

Actual result:
--------------
1.4210854715202E-14


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-24 19:22 UTC] abies@php.net
Floating point values have a limited precision. Hence a value might 
not have the same string representation after any processing. That also
includes writing a floating point value in your script and directly 
printing it without any mathematical operations.
 
Thank you for your interest in PHP.

. 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 27 10:01:30 2024 UTC