php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30903 (int) doesn't work as expected
Submitted: 2004-11-26 10:28 UTC Modified: 2004-11-26 10:34 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: ndesmet at matedex dot be Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.0.2 OS: windows 2000
Private report: No CVE-ID: None
 [2004-11-26 10:28 UTC] ndesmet at matedex dot be
Description:
------------
Problem with truncate function.

Reproduce code:
---------------
print (       ((4.06*75)+0.5) );
print("<BR>");
print ( (int) ((4.06*75)+0.5) );

Expected result:
----------------
305
305

Actual result:
--------------
305
304

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-11-26 10:34 UTC] derick@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.
 
Thank you for your interest in PHP.

.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 27 03:01:30 2024 UTC