Skip to content
Snippets Groups Projects
Commit 0ab37e18 authored by Franck Dary's avatar Franck Dary
Browse files

Added test for overflow

parent 38bfb975
No related branches found
No related tags found
No related merge requests found
...@@ -12,8 +12,8 @@ float util::long2float(long l) ...@@ -12,8 +12,8 @@ float util::long2float(long l)
long util::float2long(float f) long util::float2long(float f)
{ {
float res = f * util::float2longScale; float res = f * util::float2longScale;
if (f != 0 and res / f != util::float2longScale) if (f != 0 and std::round(res / f) != std::round(util::float2longScale))
util::myThrow(fmt::format("Float '{}' is too big to be converted to long", f)); util::error(fmt::format("Float '{}' is too big to be converted to long ({}!={})", f, res/f, util::float2longScale));
return res; return res;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment