Created
January 7, 2009 10:12
-
-
Save hipertracker/44238 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# PHP does not recognize long int. | |
# It recognize only signed int32. | |
var_dump(is_float(pow(2,30))); # false | |
var_dump(is_float(pow(2,31))); # true (sic!) | |
# Even if PHP keep long int internaly as floats, | |
# it displays them in inconsistent way: | |
print pow(2,31)."\n"; # 2147483648 | |
var_dump(pow(2,31)); | |
print pow(2,39)."\n"; # 549755813888 ... WTF? | |
var_dump(pow(2,39)); # float(549755813888) | |
print pow(2,40)."\n"; # 1.09951162778E+12 | |
var_dump(pow(2,40)); # float(1.09951162778E+12) | |
# But do really floats are always floats? It depends :P | |
var_dump(-2147483648); # float(-2147483648) | |
# but | |
var_dump(-2147483647 - 1); # int(-2147483648) | |
var_dump(-PHP_INT_MAX -1); # int(-2147483648) | |
# so THE SAME number may be int or float. If it is not schizofrenic, | |
# it is maybe php fuzzy logic :P | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment