[Cfp-interest 1644] Re: C++ floating-point work

David Olsen dolsen at nvidia.com
Wed Jun 17 07:41:35 PDT 2020


Thank you, Mike, for pointing out that a binary format can be a subset of a decimal format.  I will have to change at least that sentence in my paper, though I haven't decided yet what I will say.  For the set of values of a binary type to be a subset of the set of values of a decimal type, the decimal type has to be bigger.  _Float64 and _Decimal64 are disjoint.  But _Float32 is (I assume, I haven't verified) a subset of _Decimal64.

Do decimal floating-point types have representations for infinity and NaN?

What does the C standard have to say about conversions between binary and decimal arithmetic types?  If I remember correctly, the usual arithmetic conversions don't allow them to be mixed during arithmetic, saying it is undefined behavior.  Are there implicit conversions from binary to decimal and vice versa in other contexts?

--
David Olsen
NVIDIA HPC Compiler Team


-----Original Message-----
From: Paul Zimmermann <Paul.Zimmermann at inria.fr> 
Sent: Tuesday, June 16, 2020 1:10 AM
To: Mike Cowlishaw <mfc at speleotrove.com>
Cc: David Olsen <dolsen at nvidia.com>; cfp-interest at ucbtest.org
Subject: Re: [Cfp-interest 1639] Re: C++ floating-point work

External email: Use caution opening links or attachments


       Dear Mike,

> From: "Mike Cowlishaw" <mfc at speleotrove.com>
> Date: Mon, 15 Jun 2020 19:47:19 +0100
>
> Hi David, thanks for posting this!   I just took a quick skim through
> P1467R4.html ; one sentence caught my eye:
>
>     When an implementation supports both binary and decimal 
> floating-point, the conversion ranks of a binary type and a decimal 
> type will always be unordered, because neither type’s set of values 
> will be a subset of the other due to the different radixes.
>
> This is not right; binary floating-point types can always be a subset 
> of appropriate decimal floating-point types because the latter have a 
> base of
> 5*2 (in C/C++ notation), so you can make an exact conversion using the 
> same number of digits.  Decimal floating-point-types, however, cannot 
> be converted exactly to binary types (in general) because of that power of five.
>
> See http://speleotrove.com/decimal/decifaq1.html for some of the 
> background, rationale, etc.

maybe the sentence was only considering numbers representable in the corresponding format. For example 10^16+2 is representable in binary64 but not in decimal64. For two formats of the same bit-width I guess a counting argument can prove that you cannot have inclusion, except if the sets of representable numbers are the same (modulo the number of encodings of NaN).

Best regards,
Paul




More information about the Cfp-interest mailing list