#43976 [Opn->Bgs]: Problem with float

From: Date: Tue, 29 Jan 2008 22:59:43 +0000
Subject: #43976 [Opn->Bgs]: Problem with float
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-121762@lists.php.net to get a copy of this message
ID: 43976 Updated by: johannes@php.net Reported By: gh-ush at gmx dot de -Status: Open +Status: Bogus Bug Type: Unknown/Other Function Operating System: Debian PHP Version: 5.2.5 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: ------------------------------------------------------------------------ [2008-01-29 21:39:57] gh-ush at gmx dot de Description: ------------ Problem with float Reproduce code: --------------- $a = 74.1; var_dump($a); echo "<hr>"; $a = $a * 100; var_dump($a); print "<hr>"; $a = (int)$a; var_dump($a); print "<hr>"; exit; Expected result: ---------------- float(74.1) --------------------- float(7410) --------------------- int(7409) Actual result: -------------- float(74.1) --------------------- float(7410) --------------------- int(7410) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43976&edit=1

« previous php.bugs (#121762) next »