#49112 [Opn->Bgs]: Problem with float numbers - only in one case

From: Date: Thu, 30 Jul 2009 17:12:09 +0000
Subject: #49112 [Opn->Bgs]: Problem with float numbers - only in one case
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-140498@lists.php.net to get a copy of this message
ID: 49112 Updated by: derick@php.net Reported By: marek at 3v dot ie -Status: Open +Status: Bogus Bug Type: Math related Operating System: Fedora 9 PHP Version: 5.2.10 New Comment: 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://docs.sun.com/source/806-3568/ncg_goldberg.html Thank you for your interest in PHP. . Previous Comments: ------------------------------------------------------------------------ [2009-07-30 16:56:57] marek at 3v dot ie Description: ------------ When I try to substract specific float numbers I receive a wrong result Reproduce code: --------------- echo (35.19 - 31.69 - 3.50); echo (36.19 - 31.69 - 2.50); Expected result: ---------------- 0 Actual result: -------------- -3.5527136788005E-15 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=49112&edit=1

« previous php.bugs (#140498) next »