My roommate just came up with a question.
Why in php (maybe other languages as well) floor($foo)
and (int)$foo
is 7?
$foo = (0.7 + 0.1) * 10;
var_dump(
$foo,
floor($foo),
(int)$foo,
ceil($foo),
is_infinite($foo),
is_finite($foo));
result
float(8)
float(7)
int(7)
float(8)
bool(false)
bool(true)
Notice that $foo
is not an infinite number.
From answers I can see that everyone says that it is actually x.(9)
But what is reason behind number being x.(9)
and not actual x as it should be in real life?