Why two float variables with PHP_INT_MAX values are same unless one of them is added with value greater than 1025
问题 <?php $x=PHP_INT_MAX; echo ((float)($x+1026)==(float)($x))?'EQUAL':'Not Equal'; I know floating point arithmetic is not exact and $x and $x+1 are so close together that they are rounded to the same floating point value and it shows the output as EQUAL if you use any number between 1 and 1025 but its only after you use value beyond 1025 it will start giving output as 'Not Equal'. I want to know why? What's the reason behind it? Why only after 1025? 回答1: With float, your assumption $x == $x + 1