I have a list of floats and need to find out if at least one of them is negative (or positive, both works). Example could be to check a list of dot products to find out if a point is behind any of a list of planes.
A straightforward approach is to work iteratively.
if( 0 >= firstValue )
return true;
else if( 0 >= secondValue )
return true;
...
return false;
But this requires a lot of if clauses. Is there a formula to aggregate the values and check for the existence of at least a single negative/positive value? It would be ok to treat Zero as a negative or positive number.
If it is not possible, is there an explanation/proof why it cannot be done?
Aucun commentaire:
Enregistrer un commentaire