[math] iround / llround with rounding error
Hello all, we want to use iround / llround without exception handling. This is possible with the 'user_error' option and override a 'user_rounding_error' function. We want to return numeric_limits<int>::max() or numeric_limits<__int64>::max() if the rounding overflows over the maximum integer domain. This is then problematic since the 'user_rounding_error' has a template argument only for its source type (e.g. float / double), but not for its target type (i.e. int / __int64). We can ofc do the check before calling iround / llround, but this check would then executed be twice for the normal non overflow case. Anyone idea?
we want to use iround / llround without exception handling. This is possible with the 'user_error' option and override a 'user_rounding_error' function.
We want to return numeric_limits<int>::max() or numeric_limits<__int64>::max() if the rounding overflows over the maximum integer domain. This is then problematic since the 'user_rounding_error' has a template argument only for its source type (e.g. float / double), but not for its target type (i.e. int / __int64).
We can ofc do the check before calling iround / llround, but this check would then executed be twice for the normal non overflow case.
This looks like a bug in our design frankly, I'll try and figure out how to
fix this, in the mean time, you could simply implement your own versions of
these since they're basically trivial wrappers around "round" which does all
the work:
template
participants (2)
-
gast128
-
John Maddock