'210010106140040100' == '210010106140040101'
Posted on
16th Feb 2014 07:03 pm by
admin
Debugging this simple line of a PHP script
Code: if($a == $b){ }
I've found that with value of
Did you know?Explore Trending and Topic pages for more stories like this.
$a = '210010106140040100' (type = string)
$b = '210010106140040101' (type = string)
the result of the comparison is TRUE
the same if i compare 2 integer
$a = 210010106140040100 (type = int)
$b = 210010106140040101 (type = int)
$a == $b ( true )
If I use the === operator
'210010106140040100' === '210010106140040101' (comparison of strings: result is FALSE)
210010106140040100 === 210010106140040101 (comparison of numbers: result is TRUE)
I think it could be caused by the fact that the string is 'like' integer, but exceed the standard size of integer number.
But the final result remain a mistery for me: I've tested some others 'big' numbers and I've found for example:
18014398509481980==18014398509481981 (true) !!!!
18014398509481982==18014398509481981 (false) !!!!
In my specific script i can handle this specific comparison using the === operator, because i can assume that the variable are string.
But i'd like to know why this happen, and i'd appreciate suggestions about how to efficiently compare 'big' integers.
Thanks!
I use PHP 5.2 with IIS
No comments posted yet
Your Answer:
Login to answer
199
53
Other forums
Simple MySQL query...
Hello,
How could I do a mysql query that does this: SELECT * WHERE date/time < 5minutes ag
Linux socket programming
Where can I find a good introduction to socket programming?
PHP Redirecting
Hello everyone. Is there a way to redirect people to pages within a statement in PHP? Since there is
Auto install
Hi I have a directory lets say "apps" that I then have more folders ie "email",
breaking a text file into paragraphs based on strings
I have a text file of email addresses that is all squished together. It looks like this:
abc
login from external site
Hi my new experience begins, Now what i am trying to do is i make three pages, login.php logout.php
need help in mysql_num_rows()
please tell me what i am doing wrong in this query. it displays this error
Code: Warning: mys
need help with date function
i have following form for date
Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Beginner PHP code help
Hi I'm new to php but if someone could please read the question below and help it would be great.
Random Number Generation And Probability
Hello, I am working on a function which has to insert data into a SQL table.
we have to suppl