lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] Is DBL_MAX "adjacent" to infinity?


From: Greg Chicares
Subject: Re: [lmi] Is DBL_MAX "adjacent" to infinity?
Date: Fri, 24 Mar 2017 23:51:06 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0

On 2017-03-24 20:31, Vadim Zeitlin wrote:
> On Fri, 24 Mar 2017 19:36:44 +0000 Greg Chicares <address@hidden> wrote:
[...]
> GC> 
> https://www.securecoding.cert.org/confluence/display/c/FLP34-C.+Ensure+that+floating-point+conversions+are+within+range+of+the+new+type
[...]
> GC> signals an error if the value to be converted is
> GC>  - out of range (determined by computing its logarithm), or
> GC>  - subnormal
> GC> but does not check for NaN...so their advice seems unreliable.
> 
>  It's a bit hard to argue that NaN is "within range" (for any value of
> "range"), so their rules does seem to be incomplete. But it doesn't really
> invalidate the rest of it.

Why refuse to convert a subnormal value to integer? C99 [6.3.1.4/1] says
to truncate (which eliminates the subnormality) and then check whether
the integer part is representable in the integral part; if not, then and
only then is it UB. But the integer part is zero, always representable,
and UB cannot occur. Or have I misunderstood the meaning of this test
  (f_a != 0.0F && fabsf(f_a) < FLT_MIN))
to check whether 'f_a' is convertible to integer without UB?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]