I have a C function:
int64_t fn(int64_t a, int32_t b, int32_t c, int32_t d)
{
}
It is possible that it is close to INT64_MAX, but it does not overflow for the final result, for example, if b = 1, c = d = 40. However, I find it difficult to figure out how to calculate this so that I never lose data for rounding (doing the separation first) or overflow intermediate result.
If I had access to a data type large enough to fit the whole product a, b, and c, I would just do the math in that type and then truncate, but is there any way to do this without large integers
source
share