note 68468 deleted from language.types.float by betz

From: Date: Fri, 28 Jul 2006 09:35:08 +0000
Subject: note 68468 deleted from language.types.float by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-115294@lists.php.net to get a copy of this message
Note Submitter: TAS ---- An update regarding the james dot cridland at virginradio dot co dot uk note below, I recently tried his formula using PHP 5 and it is necessary to specify the integer precision when using the round function, otherwise the output will be 0. <? echo round((69.1-floor(69.1))); ?> // prints 0 <? echo round((69.1-floor(69.1)), 1); ?> // prints 0.1 Also, it appears that "small numbers" include everything up to 64.0. So that <? echo (63.1-floor(63.1)); ?> will print 0.1 and <? echo (64.0-floor(64.0)); ?> will print 0, but <? echo round(64.1-floor(64.1)); ?> will print 0.099999999999994.

« previous php.notes (#115294) next »