I know that due to precision errors, a float
varibale should be checked to equal a value always with some tolerance. But what's is that even the case if I manually set the float
variable to 0.0f
?
For example there is a function returning a distance.
float distance()
{
float value;
if(/* ... */)
{
// ...
return value;
}
else return 0.0f;
}
Can I cast the result to bool safely?
if(distance())
{
// ...
}