'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
using variables in another page
I have a test database set up on localhost. I have a form that I can type a name into, hit the butto
DataTable Help Required
Hi all I am creating an app that utilises and MS Access back end and queries it quite a bit at vario
Error when call dll from oracle
Hi all, please help me!
I have dll write C language, I want call it from oracle procedur
PHP Login
Hey!
I got this shopcart code online, am trying to modify it but am getting an error when i try a
bind error during socket programming
i am kinda new to socket programming. wrote the below code for a server. but getting the bind error
how to get different value in second view of webdynpro?
hello guys,
In ABAP webdynpro I am trying to create one application having two views.
Not loading image
When this function gets loaded it doesn't load the image just trying to figure out why.
Code:
simple ping code
been searchin the site/web and found code thats simple but doesnt work.
I have a personal we
Help with echo()
I'm having some problems with this code:
Code: echo '
<A HREF="jav
redirect standard error and assert (how to?)
How do you redirect standard error and assert?
---
(Why? I am creating an web app and