Round-to-even without modifying rounding mode?

Matt Turner mattst88@gmail.com
Thu Feb 5 19:52:00 GMT 2015


The rint() family of functions with the rounding mode set to
FE_TONEAREST is the only libc function I can find that will do
round-to-even. round() rounds half away from zero.

By setting various rounding modes rint() can do floor/ceil/trunc, but
there doesn't seem to be function that simply does round-to-even. Is
there one I've missed?

Alternatively, the reservations I have about setting the rounding mode
come from vague ideas about high costs involved with doing so and
potential problems from changing the rounding mode in a library. Are
either of these concerns valid, or should I simply save and restore
the rounding mode around a call to rint() to get round-to-even
behavior?



More information about the Libc-help mailing list