Bug #13550: intval() does not round off doubles correctly

From: Date: Thu, 04 Oct 2001 23:08:52 +0000
Subject: Bug #13550: intval() does not round off doubles correctly
Groups: php.dev 
Request: Send a blank email to php-dev+get-67296@lists.php.net to get a copy of this message
From: mlemos@acm.org Operating system: Linux 2.2.18 PHP version: 4.0.6 PHP Bug Type: *Programming Data Structures Bug description: intval() does not round off doubles correctly It seems that intval does not round off double numbers like the function that prints those numbers. Try this script to see the problem. <? $decimal_places=2; $decimal_factor=pow(10.0,$decimal_places); $value='8.78'; $double=doubleval($value); $scaled=$double*$decimal_factor; $integer=intval($scaled); $round=intval(round($scaled)); var_dump($decimal_places,$decimal_factor,$value,$double,$scaled,$integer,$round); ?> -- Edit bug report at: http://bugs.php.net/?id=13550&edit=1

« previous php.dev (#67296) next »