ID:               21769
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
-Status:           Open
+Status:           Bogus
 Bug Type:         Math related
 Operating System: Solaris 7
 PHP Version:      4.3.0
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

http://www.php.net/manual/en/language.types.float.php


Previous Comments:
------------------------------------------------------------------------

[2003-01-20 03:48:54] [EMAIL PROTECTED]

<?
$a=4.31;
$b=5;
$m=$a*$b ;
$res=21.55 ;

$v1=round(4.31*5,1);
$v2=round($m,1) ;
$v3=round($a*$b,1) ;
$v4=round($res,1) ;

$vbiz=round($a*$b,2) ;

$r=$v2-$v1 ;
$r2=$v3-$v1 ;
$r3=$res-$m ;

print ("<b>a=-$a-  b=-$b-  m=$a*$b=-$m- and res=$res")  ."-<br></b>" ;
print ("v1=round(4.31 * 5 , 1)=-$v1-  -") . round($v1,1) ."-<br>" ;
print ("v2=round(m, 1)=-$v2-  -") . round($v2,1) ."-<br>" ;
print ("v3=round(a*b , 1)=-$v3-  -") . round($v3,1) ."-<br>" ;
print ("v4=round(res , 1)=-$v4-  -") . round($v4,1) ."-<br>" ;
print ("expected round by 2 round... <br>") ;
print ("vbiz=round($a*$b ,2)=$vbiz -- and round($vbiz, 1)=") .
round($vbiz,1) ."<br><br>" ;

print ("r=$v2-$v1=$r -good-<br>") ;
print ("r2=$v3-$v1=$r2 -good-<br>") ;
print ("unexpected result... <br>") ;
print ("r3=$res-$m=$r3 -Huh ?-<br>") ;

?>


will give that output

a=-4.31- b=-5- m=4.31*5=-21.55- and res=21.55-
v1=round(4.31 * 5 , 1)=-21.5- -21.5-
v2=round(m, 1)=-21.5- -21.5-
v3=round(a*b , 1)=-21.5- -21.5-
v4=round(res , 1)=-21.6- -21.6-
expected round by 2 round...
vbiz=round(4.31*5 ,2)=21.55 -- and round(21.55, 1)=21.6

r=21.5-21.5=0 -good-
r2=21.5-21.5=0 -good-
unexpected result...
r3=21.55-21.55=3.5527136788005E-15 -Huh ?-


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=21769&edit=1

Reply via email to