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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ndesmet at matedex dot be
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 19:00:01 2026 UTC