Re: Beware of round() function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 24 Mar 2008 13:10:17 -0600, Kirk.Johnson@xxxxxxxxxxx wrote:
> Beware: round() apparently has changed its behavior from PHP 4. For
> certain special numbers that seem to be multiples of 100,000, the return
> value is in exponential format, rather than the usual decimal format.
Some
> of these special values are 1200000, 1400000, 2300000, which are returned
> as 1.2E+6, 1.4E+6, etc. You can generate your own list of these special
> numbers using this code:
> 
> <?php
> for( $tmp = 0, $i = 0; $i < 100; $i++ ) {
>     $tmp += 100000;
>     echo round($tmp),"\n";
> }
> ?>

Use (int)round($tmp) to get integer format.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux