[Cfp-interest 2100] Re: number classification macros, fpclassify and normal numbers

Vincent Lefevre vincent at vinc17.net
Mon Aug 16 07:49:45 PDT 2021


On 2021-08-16 15:21:59 +0100, Mike Cowlishaw wrote:
> > On 2021-08-13 15:08:03 -0600, Fred J. Tydeman wrote:
> > > The 32-bit decimal FP has 7 versions of the value 1:
> > > 0000001e0
> > > 0000010e-1
> > > 0000100e-2
> > > 0001000e-3
> > > 0010000e-4
> > > 0100000e-5
> > > 1000000e-6
> > > 
> > > Only the value with a leading non-zero digit is normalized.
> > > So, the other six are unnormals.  But, they should be considered 
> > > normal floating-point numbers.
> > 
> > OK. So it seems that in C17, such unnormalized floating-point 
> > numbers are regarded like the normalized floating-point 
> > numbers with the same numerical value,
> 
> No, because the exponent is preserved in the appropriate way when an
> arithmetic operation is effected.  2.40 and 2.4 are not the same (although
> mathematically they compare equal, of course).
> 
> See http://speleotrove.com/decimal/decifaq1.html#tzeros for rationale.

OK, but that's out of the scope of ISO C17. From its point of view,
what matters is the numerical value, not its representation, and it
doesn't specify the representation of the result. For instance,
concerning the + operator, the standard doesn't say anything about
normalization. Only for printf-like functions, there is an explicit
mention of the normalized vs unnormalized representation.

-- 
Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


More information about the Cfp-interest mailing list