Home > Archive > PHP Questions and Answers > April 2007 > Re: [PHP-DEV] ZF 0.8.0 Unit Tests behaving different on PHP 5.2.1
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: [PHP-DEV] ZF 0.8.0 Unit Tests behaving different on PHP 5.2.1
|
|
| Sebastian Nohn 2007-04-17, 6:57 pm |
| Antony Dovgal wrote:
> On 04/17/2007 10:16 PM, Sebastian Nohn 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.
>
>
> #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)
$ ./php -v
PHP 5.2.2RC2-dev (cli) (built: Apr 17 2007 20:12:31)
$ cat ~/test.php
<?php
$a = 6900000000;
$b = "6900000000";
$c = $a."";
$d = (string)$a;
printf("%d", $a); echo "\n";
printf("%d", $b); echo "\n";
printf("%d", $c); echo "\n";
printf("%d", $d); echo "\n";
?>
sh-3.1$ ./php ~/test.php
-1689934592
2147483647
6
6
Best regards,
Sebastian Nohn
--
Sebastian Nohn · Wolfstraße 29 · 53111 Bonn · Germany
+49-170-4718105 · http://nohn.net/ · sebastian@nohn.net
http://pgpkeys.pca.dfn.de:11371/pks...arch=0xD47D55E0
| |
| Antony Dovgal 2007-04-17, 6:57 pm |
| On 04/17/2007 10:37 PM, Sebastian Nohn wrote:
$a = 6900000000;
$b = "6900000000";
$c = $a."";
$d = (string)$a;
[color=darkred]
--
Wbr,
Antony Dovgal
| |
| Sebastian Nohn 2007-04-17, 6:57 pm |
| Sebastian Nohn wrote:
> $c = $a."";
> $d = (string)$a;
Forget that.
- Sebastian
|
|
|
|
|