mercredi 24 janvier 2018

Floating point value equality with integral

This issue fundementally comes down to 2 lines, the 1st line will output 1.

std::cout << sqrt(pow(b->x - a->x, 2) + pow(b->y - a->y, 2) + pow(b->z - a->z, 2)) << std::endl;

Yet the 2nd line will output 0, how is this possible?

std::cout << (sqrt(pow(b->x - a->x, 2) + pow(b->y - a->y, 2) + pow(b->z - a->z, 2)) == 1) << std::endl;

Aucun commentaire:

Enregistrer un commentaire