I am confusing the fact that I am asking PHPUnit quite a lot. I wrote the fibonacci number. But in the case of 100, I wrote below.
http:
I expect this to return TRUE. This failed.
http://www.php.net/manual/en/language.types.float.php
I realized: "never compare with equality." and so how to do it? In the end, I compare to_string with each other. How to compare a large number in PHP?
http:
I can smell it like a bad smell. But I do not know a better way. Please tell me how do you say this?
====
php > $a = 354224848179261915075;
php > echo $a;
3.5422484817926E+20
php > $b = 3.5422484817926E+20;
php > echo $b;
3.5422484817926E+20
php > echo ($a == $b) ? 'TRUE' : 'FALSE';
FALSE
php > echo gmp_cmp($a, $b);
PHP Warning: gmp_cmp(): Unable to convert variable to GMP - wrong type in php shell code on line 1
php > echo (strval($a) == strval($b)) ? 'TRUE' : 'FALSE';
TRUE
====
environment
$ uname -a
Linux localhost.localdomain 2.6.33.6-147.2.4.fc13.x86_64
$ php --version
PHP 5.3.3 (cli) (built: Jul 22 2010 15:57:00)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
source
share