dxf <dxfo…@gmail.com> writes:
>It's not clear to me that IEEE even talks in terms of 'representable' numbers
>which leads to the junk that GCC et al print out:
>
> 5.1 Overview
>
> "Each of the computational operations that return a numeric result specified by
> this standard shall be performed as if it first produced an intermediate result
> correct to infinite precision and with unbounded range, and then rounded that
> intermediate result, if necessary, to fit in the destination’s format"
This already says it: "if necessary". When the result is
representable in the destination's format, rounding is not necessary.
When the destination format is a string buffer with enough digits,
rounding is not necessary, and the exact value can be shown.
OTOH, almost all (as in "all but finitely many") numbers do not fit in
binary64, so for almost all numbers that you might convert from a
decimal string to a binary64 FP number, rounding happens on the
conversion. The exceptions are notable, though, e.g., all integers
<=2^53.
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: https://forth-standard.org/
EuroForth 2026 CFP: http://www.euroforth.org/ef26/cfp.html