php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55721 sprintf error
Submitted: 2011-09-18 19:21 UTC Modified: 2011-09-18 23:21 UTC
From: umka at localka dot net Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: Irrelevant OS: FreeBSD 7.2, 8.2
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: umka at localka dot net
New email:
PHP Version: OS:

 

 [2011-09-18 19:21 UTC] umka at localka dot net
Description:
------------
$a=11111111111111111111111111111111111.00";
$b=sprintf("%036.2f",$a);  // eq 11111111111111109993981897808543744.00



Test script:
---------------
$a=11111111111111111111111111111111111.00";
$b=sprintf("%036.2f",$a);  // eq 11111111111111109993981897808543744.00




Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-09-18 23:21 UTC] cataphract@php.net
-Status: Open +Status: Bogus
 [2011-09-18 23:21 UTC] cataphract@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.

If you would like to know more about "floats" and what IEEE
754 is, read this:
http://www.floating-point-gui.de/

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 04:01:34 2025 UTC