Takashi Kato wrote:
> I just noticed that fl-least is defined positive number of least least
> decimal point however
> the SRFI says negative number of DBL_MAX. Is this mistake of SRFI text or sample
> implementation? (I can see both sides are correct so it's vague to me)
I believe that was a mistake in the text of the SRFI. Even if it wasn't,
it should be treated as a mistake because the least positive flonum is a
more useful constant than the most negative flonum.
The parenthetical's "C99 DBL_MAX and its negation" has several problems.
For one thing, the negation of DBL_MAX might not be the most negative
flonum, as SRFI 144 does not mandate IEEE-754 arithmetic or similar.
If fl-least were defined as the negation of DBL_MAX, then it would add
no information, whereas the the least positive flonum does add useful
information.
Less importantly, SRFI 144 doesn't require flonums to use double precision
so it can't possibly be correct to mention DBL_MAX without also mentioning
FLT_MAX and LDBL_MAX. I will, however, perpetuate that minor error by
considering only the double precision constants in paragraphs below.
Finally, the "Specification" section combined with the parenthetical
comment suggest fl-least is intended to have something to do with one
of the C99 constants. None of the C99 constants have anything to do
with the most negative floating point number of any precision.
Having explained why I don't think it's reasonable to interpret fl-least
as the most negative flonum, we still have to consider how we want to
interpret its specification. The C99 standard defines a DBL_MIN constant
analogous to DBL_MAX, but the C11 standard defines a different DBL_TRUE_MIN
constant. The C99 DBL_MIN constant is the minimum *normalized* positive
value of that precision. The C11 DBL_TRUE_MIN constant is the minimum
positive value of that precision, which will be smaller than DBL_MIN when
IEEE-754 arithmetic is used.
Regardless of what SRFI 144 actually says, I believe the Scheme community
will be best served by defining fl-least as the minimum positive flonum,
which is likely to coincide with the C11 constant DBL_TRUE_MIN, not with
the C99 constants DBL_MIN.
I will propose a short list of new errata for SRFI 144 later today. This
will be on that list.
Will