Re: Re: [fw-general] Re: [PHP-DEV] ZF 0.8.0 Unit Tests behaving different on PHP 5.2.1 and PHP 5.2.2-dev
| From: | Antony Dovgal | Date: | Tue, 17 Apr 2007 18:24:38 +0000 |
| Subject: | Re: Re: [fw-general] Re: [PHP-DEV] ZF 0.8.0 Unit Tests behaving different on PHP 5.2.1 and PHP 5.2.2-dev | ||
| References: | 1 2 3 | Groups: | php.internals php.qa |
| Request: | Send a blank email to php-qa+get-28205@lists.php.net to get a copy of this message | ||
On 04/17/2007 10:16 PM, Sebastian Nohn wrote:
Dmitry Stogov wrote:<?php $a = 6900000000; $b = $a.""; <-------------- that's the very same mistake printf("%d", $a); echo "\n"; printf("%d", $b); echo "\n"; ?> You're converting float to string and THEN trying to output as integer. My patch returns the old behaviour, though you're code is still wrong.It is bad practice to use echo $float or var_dump($float) because they depends on php.ini settings. You should use printf() of number_format() for deterministic result.
PHP 5.2.2: -1689934592 6#php -r 'printf("%d", 6900000000);' -1689934592 #php -r 'printf("%d", "6900000000");' 2147483647 #php -v PHP 5.2.2RC1 (cli) (built: Apr 16 2007 10:01:11) -- Wbr, Antony Dovgal