php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25290 printf produces incorrect result
Submitted: 2003-08-28 07:35 UTC Modified: 2003-08-28 10:14 UTC
From: oli_pla at hotmail dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.3.3 OS: Windows 2000/XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
41 - 11 = ?
Subscribe to this entry?

 
 [2003-08-28 07:35 UTC] oli_pla at hotmail dot com
Description:
------------
For some particular values, printf('%.2f',$val) gives incorrect results on Windows 2000 and XP. The behaviour is that a digit is one unit too low. For instance, with 813.54, you get 803.54, and 349.61 becomes 348.61.

On Windows 98 or Linux, the problem doesn't appear.

I'm aware it may be a bug in Microsoft's C runtime, in which case it wouldn't be a PHP problem. But it would be interesting to be sure...

Reproduce code:
---------------
printf('%.2f',813.54);

Expected result:
----------------
813.54

Actual result:
--------------
803.54

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-28 10:14 UTC] sniper@php.net
Maybe you're mixing some old dlls with news ones (PHP related). This works just fine for me on XP.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 16 03:01:28 2024 UTC