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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Sun Jan 05 06:01:27 2025 UTC