tcpdump mailing list archives

Re: POSIX and float rounding


From: Guy Harris <gharris () sonic net>
Date: Thu, 19 Mar 2026 17:28:02 -0700

On Mar 19, 2026, at 4:52 PM, Denis Ovsienko <denis () ovsienko info> wrote:

Are you saying that fesetround() cannot solve this problem reliably?

It could solve it reliably *if* you choose a rounding mode *other* than round-to-nearest; I don't think the other modes 
have the problem of "which of 0 and 1 is nearest to .5?"

Unfortunately, fesetround(), prior to C23, doesn't offer a way to tell the floating-point environment how to break the 
tie, as it offers no choice between different flavors of round-to-nearest. C23 distinguishes between FE_TONEAREST, 
which is specified as being roundTiesToEven, and an *optional* FE_TONEARESTFROMZERO, which is specified as 
roundTiesToAway.
_______________________________________________
tcpdump-workers mailing list -- tcpdump-workers () lists tcpdump org
To unsubscribe send an email to tcpdump-workers-leave () lists tcpdump org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s


Current thread: