Commit 0ab37e18 authored by Franck Dary's avatar Franck Dary
Browse files

Added test for overflow

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