Page 1 of 1

is there any value which can break the following code

Posted: Fri Mar 02, 2007 3:34 am
by dude81
Hi,

I've the following case where $number1 and number2 which can also be a float value in which case values after decimal can go upto 10 to 15 digits. Can PHP5 handle such a float value. If so, does any value which doesnot fall in any of the following range can break the logic written below. -30 to + 30 for number1 and -100 to +100 for number2 .

Code: Select all

if(($number1 >= -30 && $number2 >= -100)&&($number1 <= 30 && $number2 <= 100)){
echo "Nothing broke the value";
  
}
I've tested most cases. But still I've some apprhensions about the logic

Posted: Fri Mar 02, 2007 8:01 am
by feyd
Shift the logic around to group $number1 and $number2 together. Since everything is logical ands, you can lose the grouping parentheses too.

If you need to keep the precision high, use bcmath.