Use std::round() to handle fractions correctly.
main
Kevin Backhouse 3 years ago
parent 5d5354edee
commit 15328aaa9f
No known key found for this signature in database
GPG Key ID: 9DD01852EE40366E

@ -13,6 +13,7 @@
#include <cstring>
#include <iomanip>
#include <map>
#include <cmath>
// *****************************************************************************
// namespace extensions
@ -1251,7 +1252,7 @@ class ValueType : public Value {
const auto v = value_.at(n);
if (static_cast<decltype(v)>(std::numeric_limits<I>::min()) <= v &&
v <= static_cast<decltype(v)>(std::numeric_limits<I>::max())) {
return static_cast<I>(v);
return static_cast<I>(std::round(v));
} else {
return 0;
}

Binary file not shown.
Loading…
Cancel
Save