note 68469 deleted from language.types.float by danbrown
| From: | danbrown@php.net | Date: | Sat, 02 Feb 2013 15:12:09 +0000 |
| Subject: | note 68469 deleted from language.types.float by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-193501@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.