3 ms·
That's a huge stretch. Integer arithmetic is perfectly portable. Defined operations have bit-exact defined results, reproducible on any platform. In contrast,
by telendram 8y ago
That's a huge stretch.
Integer arithmetic is perfectly portable. Defined operations have bit-exact defined results, reproducible on any platform.
In contrast, the result of basic floating point operations is not.
You may live in a world were you use a single cpu type, and a single OS, and a single compiler, in which case, it might appear to you as defined.
But anyone involved in some portability across multiple systems know how improbable it is to rely on floating point for anything exact. Actually, don't. ever.
For anything which requires exact results, use integer instead.
- olliej 8y agoNo floating point is exact and consistent and incredibly well defined. Floating point is not exact but neither are integers. Floating point is 100% deterministic. Things that differ: bit wise representation for non-ieee formats. Things that don’t differ: numeric result. Basically for any arithmetic operation, with a given significand and exponent size in some rounding mode, there is a single correct result. Different implementations do not produce different results.