Skip to content

Commit

Permalink
🐛 use fuzzy comparison for floating point in const evaluation equalit…
Browse files Browse the repository at this point in the history
…y check

Signed-off-by: burgholzer <burgholzer@me.com>
  • Loading branch information
burgholzer committed Jan 21, 2025
1 parent 31b3d64 commit 3ebd48a
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <cstddef>
#include <cstdint>
#include <limits>
#include <memory>
#include <optional>
#include <string>
Expand Down Expand Up @@ -65,7 +66,8 @@ struct ConstEvalValue {
case ConstUint:
return std::get<0>(value) == std::get<0>(rhs.value);
case ConstFloat:
return std::get<1>(value) == std::get<1>(rhs.value);
return std::abs(std::get<1>(value) - std::get<1>(rhs.value)) <

Check warning on line 69 in include/mqt-core/ir/parsers/qasm3_parser/passes/ConstEvalPass.hpp

View workflow job for this annotation

GitHub Actions / 🇨‌ Lint / 🚨 Lint

include/mqt-core/ir/parsers/qasm3_parser/passes/ConstEvalPass.hpp:69:19 [misc-include-cleaner]

no header providing "std::abs" is directly included
std::numeric_limits<double>::epsilon() * 1024;
case ConstBool:
return std::get<2>(value) == std::get<2>(rhs.value);
}
Expand Down

0 comments on commit 3ebd48a

Please sign in to comment.