4 ms·
That's a legitimate question. It's just floating-point jargon. Here's what it means: > I’m well aware of banker’s rounding, and rounding up, and round down, an
by thxg 4y ago
That's a legitimate question. It's just floating-point jargon. Here's what it means:
> I’m well aware of banker’s rounding, and rounding up, and round down, and rounding towards zero, and rounding towards signed infinity, etc.
MPFR supports most of those rounding modes you mentioned:
https://www.mpfr.org/mpfr-current/mpfr.html#Rounding https://www.mpfr.org/mpfr-current/mpfr.html#Rounding
> But “correct” as a formal modifier is new to me
It just means that once you select a rounding mode, it is guaranteed (modulo bugs) to give you the correct answer rounded according to your selected rounding mode.
At first one can think: "obviously, who wants incorrect rounding?". And indeed all recent floating-point hardware implements correct rounding... But only for 32- or 64-bit floats, and only for addition, subtraction, multiplication and division.
By contrast, most libc/libm implementations do not have correct rounding for transcendental functions (cos, sin, tan, exp, log, etc.). There are some exceptions (Rlibm, CRlibm).
MPFR implements correct rounding
- at any bit width and
- for all transcendental functions.
- gnulinux 4y agoIn a big application, wouldn't rounding to a random direction (a feature GNU MP supports) be the most accurate probabilistically? If you round up or down all your numbers and you perform a lot of arithmetic operations, you create a lot of bias.
- pertymcpert 4y agoMaybe, but having random "accurate" behavior in a program is generally worse than being incorrect all of the time.
- klyrs 4y agoConsider the logarithm. In almost any interval, rounding down will be more accurate than rounding up the majority of the time -- so random rounding will bias you away from an accurate result. Random rounding can be a good idea, but it's not always a good idea. Random rounding is an okay default, but having fine-grain control over rounding direction is vastly superior to always sticking to the default. For another example, interval arithmetic is a really cool approach to keeping an eye on your accuracy. There, you want to round your upper bounds up, and round your lower bounds down.