[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.2.0 (rc7) now available
- From: Tony Finch <dot@...>
- Date: Fri, 9 Dec 2011 17:46:25 +0000
Patrick Rapin <toupie300@gmail.com> wrote:
>
> Maybe "broken" is not the correct word. It seems more to be "imprecise".
> Is there any C specification that says that pow(2., 4.) - 64. shall be
> *exactly* zero ?
C89 does not have precise requirements for floating point arithmetic. C99
is the same except when "An implementation that defines __STDC_IEC_559__
shall conform to the specifications in this annex" i.e, annex F. IEC 559
is an alias for IEEE 754-1985.
IEEE 754 says "Except where stated otherwise, every operation shall be
performed as if it first produced an intermediate result correct to
infinite precision and with unbounded range, and then rounded that result
according to one of the attributes in this clause."
This implies that "broken" is exactly the right word to describe the
problem pow(). However 754-1985 does not specify a pow() function.
754-2008 recommends it, rather than requiring it like the basic arithmetic
ops. Still it would be a very bad implementation that didn't follow the
general requirement for all floating point functions.
Tony.
--
f.anthony.n.finch <dot@dotat.at> http://dotat.at/
Forth, Tyne, Dogger: West or northwest 6 to gale 8, decreasing 5 for a time in
Forth and Tyne. Rough or very rough. Squally wintry showers. Good,
occasionally poor.