'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
weird problem
last time, i did post a topic concerning why my page sometime will load as blank page when using IE.
How to schedule the a job?
Hi,
I have prepared a task ( i.e. a procedure is prepare the file and send the same to con
PHP switch function help
Hi, I am trying to create a search function for a directory website. On the search function on html
compile php5 with DOM
Hi,
I can't manage to compile php 5.3.0 from source on Windows to include DOM,
in spite of
Help? Need help on project with templates involving mysql and php.
I'm having a hard time explaining what I want but basically here is what I have in place:
-Da
C problem struct and string
Hi guys,
This is my first post and I'm hoping the experts here can help me solve my problem.<
User input in to variable
Hi all,
I'm sure this is very easy but I'm having another brain freeze!
At the end of
help with database debug pls
Parse error: syntax error, unexpected T_ELSE in /home/content/m/e/s/mesick/html/students/05/php/chec
WORDPRESS - Multiple Loops Only Going to One Post?
I have various pages with multiple loops and i need them to be individual to all other categories.
MySQL noob question
hi guys
I have a simple mysql table set up, along the lines of
Col 1 - Col 2 - Date_l