Question: I try to create unit test cases to check my table values are correct or wrong.

This is my codes

```
echo $a = 2/9;
echo "<br>".$b=0.22222222222222;

echo "<br>".gettype($a);
echo "<br>".gettype($b);
if($a==$b){
    echo "<br>". "equal";
}else echo "<br>". "Not equal";

if((string)$a==(string)$b){
    echo "<br>". "equal";
}else echo "<br>". "Not equal";

```

Why my first if condition not working? I can't find the reason. Please help me.

Answer: 
Floats are tricky, you need to limit the number of decimal points.

```
$a = 2/9;
$b=0.22222222222222;

$a = number_format($a, 9);
$b = number_format($b, 9);

echo "a = " . $a . " and b = " . $b;

echo "<br>".gettype($a);
echo "<br>".gettype($b);
if($a==$b){
    echo "<br>". "equal";
}else echo "<br>". "Not equal";

if((string)$a==(string)$b){
    echo "<br>". "equal";
}else echo "<br>". "Not equal";

```
If you have a look at the PHP documentation of [floating point numbers](http://php.net/manual/en/language.types.float.php) (which includes doubles), you'll quickly see that it's incredible difficult to compare because of the nature of floating point numbers.

> 
> So never trust floating number results to the last digit, and do not compare floating point numbers directly for equality.
> 
> 
> 

The documentation provide an example as well:

```
<?php

$a = 1.23456789;
$b = 1.23456780;
$epsilon = 0.00001;

if(abs($a-$b) < $epsilon) {
    echo "true";
}

```