php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15948 Basic Subtraction Error
Submitted: 2002-03-08 02:06 UTC Modified: 2002-03-08 02:36 UTC
From: abuckner at cicadadesign dot com Assigned:
Status: Not a bug Package: *Math Functions
PHP Version: 4.0.6 OS: Red Hat Linux 7.1
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:
MUST BE VALID
Solve the problem:
23 + 3 = ?
Subscribe to this entry?

 
 [2002-03-08 02:06 UTC] abuckner at cicadadesign dot com
This was submitted by one of our head developers.  We're using PHP/MySQL to build our customer relationship software, and this scares me.

-----------------------

The numbers should add to 0. When I echo the result I get the below:

-5.6843418860808E-14.

<?

echo 241.20 + 169.23 - 410.43;

?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-03-08 02:36 UTC] derick@php.net
This is actually not a bug, but a normal thing with floatingpoint numbers. If you want to do precise calculating, use cents, or decrease the precision in php.ini from 14 to something like 10.

Derick
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Feb 27 00:01:26 2024 UTC