mardi 1 septembre 2020

C2296: '|': illegal, left operand has type 'float'

I am trying to compare, in a clean and FAST way (by logic) if three variables are 0, they are all floating point numbers, IEEE 754.

float x;
float y;
float z;

if(((x | y | z) == 0.0f)) { ... }

But, I keep getting:

main.cpp(15): error C2296: '|': illegal, left operand has type 'float'
main.cpp(15): error C2297: '|': illegal, right operand has type 'float'
main.cpp(18): error C2296: '|': illegal, left operand has type 'float'
main.cpp(18): error C2297: '|': illegal, right operand has type 'float'

I read something about,

std::numeric_limits<T>::is_iec559
std::numeric_limits<float>::epsilon()
std::fabs()

and Epsilon 10^−7

Aucun commentaire:

Enregistrer un commentaire