bug comparison in PHP

php do not be able to compare large int and float reliably.


$val1 = 0.2; $val2 = 0.2;
if($val1 < $val2){ echo 'it is true';}

one workaround for equal comparison is to cast the value to string type.


comparison of float value in PHP

Advertisements

Published by

paragasu

Different. In a good way

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s