From:             exploringbinary at gmail dot com
Operating system: Windows
PHP version:      5.2.8
PHP Bug Type:     Math related
Bug description:  printf of floating point variable prints maximum of 40 
decimal places

Description:
------------
printf will not print more than 40 decimal places, even if the format
specifier asks for more. For example, 

<?php
 $value = 0.00000000000000011102230246251565404236316680908203125; //
2^-53
 printf ("%1.53f",$value); // Prints only 40 decimal places:
0.0000000000000001110223024625156540423632
 ?> 

Contrast this with javascript:
<script type="text/javascript">
  var value = 0.00000000000000011102230246251565404236316680908203125; //
2^-53
  var result = value.toFixed(53);
  document.write (result); // Prints all 53 decimal places
</script>

I reported a similar bug in Visual Studio, which Microsoft acknowledged as
an error:
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=329278


Reproduce code:
---------------
<?php
 $value = 0.00000000000000011102230246251565404236316680908203125; //
2^-53
 printf ("%1.53f",$value); // Prints only 40 decimal places:
0.0000000000000001110223024625156540423632
 ?>

Expected result:
----------------
I expect to see all 53 decimal places printed:
0.00000000000000011102230246251565404236316680908203125

Actual result:
--------------
Only 40 decimal places are printed:
0.0000000000000001110223024625156540423632

-- 
Edit bug report at http://bugs.php.net/?id=47168&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=47168&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=47168&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=47168&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=47168&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=47168&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=47168&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=47168&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=47168&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=47168&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=47168&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=47168&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=47168&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=47168&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=47168&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=47168&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=47168&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=47168&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=47168&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=47168&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=47168&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=47168&r=mysqlcfg

Reply via email to