RE: [PHP-DEV] 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: | Dmitry Stogov | Date: | Wed, 18 Apr 2007 06:51:06 +0000 |
| Subject: | RE: [PHP-DEV] 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 | Groups: | php.internals php.qa |
| Request: | Send a blank email to php-qa+get-28213@lists.php.net to get a copy of this message | ||
Tricky code - tricky result. Do you think php-5.1 result is perfect? :)
BTW the difference is in implementation of %G format specifier.
It seems, now it tries to produce the shortest string representation of
float (I cannot remember why), but this is not conformed to POSIX
specification
Linux man:
g,G The double argument is converted in style f or e (or F or E for
G conversions). The precision specifies the number of
signifi-
cant digits. If the precision is missing, 6 digits are
given;
if the precision is zero, it is treated as 1. Style e is
used
if the exponent from its conversion is less than -4 or
greater
than or equal to the precision. Trailing zeros are removed
from
the fractional part of the result; a decimal point appears
only
if it is followed by at least one digit.
Probably it should be fixed.
Thanks. Dmitry.
> -----Original Message-----
> From: Sebastian Nohn [mailto:sebastian@nohn.net]
> Sent: Tuesday, April 17, 2007 10:16 PM
> To: Dmitry Stogov
> Cc: 'Thomas Weidner'; 'Antony Dovgal'; 'Zend Framework
> General'; ilia@php.net; php-qa@lists.php.net; internals@lists.php.net
> Subject: Re: [PHP-DEV] 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
>
>
> Dmitry Stogov wrote:
>
> > 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
> $a = 6900000000;
> $b = $a."";
> printf("%d", $a); echo "\n";
> printf("%d", $b); echo "\n";
> ?>
>
> PHP 5.2.1:
>
> -1689934592
> 2147483647
>
> PHP 5.2.2:
>
> -1689934592
> 6
>
> - Sebastian
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>