Skip to content

reduce float warnings (comparisons and implicit conversions)

Erik Schultheis requested to merge ngc92/eigen:float_eq_utility into master

This MR consists of three changes to reduce the number of warnings that would be generated due to floating point concerns:

  1. It adds new utility functions for performing exact floating point comparisons to 0 and 1. Why the extra function? Because for one, these are the most common types of exact floating point comparisons, and the ones where we usually clearly want exact comparison to happen (e.g. do I need to add this scalar/do I need to multiply with this scalar/can I ignore this term). Furthermore, having this as an extra function means we can hide generating the correctly typed 0 and 1 in their code, and enforce that the correct type is used.
  2. Replace == with equal_strict in regular code, and VERIFY(... == ...) with VERIFY_IS_EQUAL in the tests.
  3. wrote out some implicit conversions into explicit casts. This is only in the test suite.

Q: What should be the name for the comparison to 0/1 numbers? Right now I'm using is_zero_strict in analogy to equal_strict, but a more descriptive name (maybe) could also be is_exactly_zero (this is more how I would read this out aloud in an if, for example).

Merge request reports