|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #63673 Bug in number_format
Submitted: 2012-12-03 09:08 UTC Modified: 2012-12-03 09:10 UTC
From: lorenavva at gmail dot com Assigned:
Status: Not a bug Package: Testing related
PHP Version: Irrelevant OS: number_format
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:
Solve the problem:
50 - 24 = ?
Subscribe to this entry?

 [2012-12-03 09:08 UTC] lorenavva at gmail dot com
Dears developer:

I have the next problem with function number_format. I understand thar number_format do a high round. I am write one case where there is bug:
Original Number --> Number with round

However in this case there isnĀ“t bug:
Original Number --> Number with round
Could you help me, please?

Best Regards

From manual page:

Test script:
$sql = "SELECT * FROM access_subv_abona WHERE borrado = 0";
	$rs_abonada =mysql_query($sql);
	for($i=0; $i<mysql_num_rows($rs_abonada);$i++)			
	if(mysql_result($rs_abonada,$i, "subvencion_concedida") >0){
	$datos_expediente=consultaSimple("expedientes","id=".intval(mysql_result($rs_abonada,$i,"id_expediente"))." and borrado=0");
$subvencion_total= $datos_expediente['subvencion_concedida'];
$subvencion_abonada = number_format(0.5* $subvencion_total,2,'.','')+number_format(0.25* $subvencion_total,2,'.',''); 	
$subvencion_abonada_bd= mysql_result($rs_abonada,$i,"subvencion_abonada");
$ajuste_abono=($subvencion_abonada_bd- $subvencion_abonada);							print_r((0.25* $subvencion_total)."--".number_format((0.25* $subvencion_total),2,'.','')."<br>");			print_r($subvencion_abonada_bd."--".$subvencion_abonada."<br>");



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-12-03 09:10 UTC]
-Status: Open +Status: Not a bug
 [2012-12-03 09:10 UTC]
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:

Thank you for your interest in PHP.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 12 22:01:29 2024 UTC