|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27199 intval changes value on one particular number
Submitted: 2004-02-10 00:33 UTC Modified: 2004-02-10 05:32 UTC
From: ribarra at innox dot com dot mx Assigned:
Status: Not a bug Package: *Math Functions
PHP Version: 4.3.4 OS: Linux Mandrake 9.2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: ribarra at innox dot com dot mx
New email:
PHP Version: OS:


 [2004-02-10 00:33 UTC] ribarra at innox dot com dot mx
The following code should output exactly the same number in both echo cases but it doesn't. However, multiply the number by 1000 instead of the 100 on the first line and everything will work fine.

Reproduce code:
        $test = (642 + 0.56) * 100;
        echo $test . "\n";
        $test = intval ($test);
        echo $test;

Expected result:

Actual result:

Very weird, I have only seen it happen with this particular case.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-10 05:32 UTC]
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-2024 The PHP Group
All rights reserved.
Last updated: Wed Feb 28 07:01:28 2024 UTC