Re: [PHP] strange behavior, when converting float to int

[email protected] (Philip Thompson)
Newsgroups php.general
Message-ID <[email protected]>
On May 6, 2008, at 1:38 AM, Maxim Antonov wrote:

> Hi, all!
>
> Is this a bug?
>
> max@maximus:~$ /usr/bin/php 1.php
> 45
> 45
> float(46)
>
>
> max@maximus:~$ /usr/bin/php -v
> PHP 5.3.0-dev (cli) (built: Apr  4 2008 11:37:33)
> Copyright (c) 1997-2008 The PHP Group
> Zend Engine v2.3.0, Copyright (c) 1998-2008 Zend Technologies
>
>
> max@maximus:~$ cat 1.php
> <?php
> $i = 10.35 + 20.76 + 5.80 + 5.80 + 3.29;
> echo (int)$i;
> echo "\n";
> echo intval($i);
> echo "\n";
> var_dump($i);
>
> max@maximus:~$


I got the same results. I'm not exactly sure what's happening, but I'd  
be curious to see if there's anyone else who can shed some light.

PHP Version 5.2.4.

~Philip
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.