[PHP-DEV] Bug #13241: round() failed elementary level math From: cnewbill <email protected>
Date: 09/10/01

From: cnewbill <email protected>
Operating system: Linux 2.4.x
PHP version: 4.0.6
PHP Bug Type: Math related
Bug description: round() failed elementary level math

[Post from PHP-DEV]

<?php

$x = 10.95;
$y = 0.70;

$e = $x*$y;

print "Discounted price = $e\n";

var_dump($e);

$z = round($e, 2);

var_dump($z);

print "Rounded Price = $z\n";

// this works grrr

$x = round(7.665, 2);

print "Working example of round = $x\n";

?>

Produces

[cnewbill <email protected> cnewbill]$ php -q t.php
Discounted price = 7.665
float(7.665)
float(7.66)
Rounded Price = 7.66
Working example of round = 7.67
[cnewbill <email protected> cnewbill]$ php -v
4.0.6

Which is wrong, it should be 7.67. If I don't do the multiplication and
simply send round 7.665 it works right!!??

Any ideas?

-Chris

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

-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>