php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70954 Wrong Calculation
Submitted: 2015-11-22 15:08 UTC Modified: 2015-11-22 20:43 UTC
From: sukram230799 at outlook dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.6.15 OS: Window 10
Private report: No CVE-ID: None
 [2015-11-22 15:08 UTC] sukram230799 at outlook dot com
Description:
------------
---
From manual page: http://www.php.net/index
---

PHP is calculating wrong or inacurate.

Test script:
---------------
echo(272.19-273.15);

Expected result:
----------------
-0.96

Actual result:
--------------
-0.95999999999998

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-11-22 20:43 UTC] requinix@php.net
-Status: Open +Status: Not a bug -Type: Documentation Problem +Type: Bug
 [2015-11-22 20:43 UTC] requinix@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.

If you would like to know more about "floats" and what IEEE
754 is, read this:
http://www.floating-point-gui.de/

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 15:01:31 2024 UTC