'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
if else problem, help please
i have this script that i made only i try to also put in a if else for for some reason the script is
Create or replace package is ending ORA-21700
Database 9.2.0., patch 8 (9.2.0.8.0).
I trying run
create or replace package ....etc.
Strange PHP/mySQL error ... am I just tired?
Code: <?
## CONNECT TO DB FUNCTION!
function ConnectTo($db2con)
{
$hostNam
1,000 select boxes with 100 options?!
I have 1 drop down select box with 1,000 options.
In some case, there will be 100+ of the
Transport data between itab and textfield on ALV event
Hallo,
I have a ALV Grid ( cl_gui_alv_grid ) and I also have hotspot click event with a h
Displaying data from MySql a different way
Hi all,
I'm pretty new to php and MySql and have hit a problem.
I am able to display data
mysql select query problem
how can i select multiple fields from multiple table in one query like
i have table name t1 a
Using real time in php
I'm very average at PHP and im looking to introduce time to something on my site.
Its a sports si
post to self
Trying to get my form to submit to itself. However I am also trying to use an image for my submit bu
pull content
I have an existing page, domain/adverts.php which has a good PR. I've just rebuilt my site and the n