Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

C23 _Decimal64 etc

131 views
Skip to first unread message

Thiago Adams

unread,
Sep 22, 2022, 10:09:15 AM9/22/22
to
Decimal floating point types were added into C23.

I was wondering.. how it will be implemented by c23 compilers?
Is it already supported in x86 / x64 / arm?

or it is a kind of emulation?

Bart

unread,
Sep 22, 2022, 12:24:05 PM9/22/22
to
Probably it will be emulation just like those precise N-bit types.

AFAIK x64 doesn't support those 64-bit/128-bit decimal types, and from
reading about the format months back, it looks horrendous to do in software.

I think, if your translator has to provide emulations, then you have
your work cut out. But I believe some of these features will be optional.

Thiago Adams

unread,
Sep 22, 2022, 1:44:33 PM9/22/22
to
On Thursday, September 22, 2022 at 1:24:05 PM UTC-3, Bart wrote:
> On 22/09/2022 15:09, Thiago Adams wrote:
> > Decimal floating point types were added into C23.
> >
> > I was wondering.. how it will be implemented by c23 compilers?
> > Is it already supported in x86 / x64 / arm?
> >
> > or it is a kind of emulation?
> Probably it will be emulation just like those precise N-bit types.
>
> AFAIK x64 doesn't support those 64-bit/128-bit decimal types, and from
> reading about the format months back, it looks horrendous to do in software.

I guess people requiring this..were already using some lib like in c99
https://www.intel.com/content/www/us/en/developer/articles/tool/intel-decimal-floating-point-math-library.html



Keith Thompson

unread,
Sep 22, 2022, 2:30:11 PM9/22/22
to
Decimal floating types are optional in C23.

Presumably they'll be implemented in hardware for targets that
support them, or in emulation or not at all for targets that don't.

gcc already supports decimal floating-point on some targets. A quick
test indicates that it generates function calls for _Decimal64 addition,
for example. I don't know the details. From the gcc manual:

As an extension, GNU C supports decimal floating types as defined in
the N1312 draft of ISO/IEC WDTR24732. Support for decimal floating
types in GCC will evolve as the draft technical report changes.
Calling conventions for any target might also change. Not all
targets support decimal floating types.

--
Keith Thompson (The_Other_Keith) Keith.S.T...@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

David Brown

unread,
Sep 22, 2022, 5:03:32 PM9/22/22
to
On 22/09/2022 18:23, Bart wrote:
> On 22/09/2022 15:09, Thiago Adams wrote:
>> Decimal floating point types were added into C23.
>>
>> I was wondering.. how it will be implemented by c23 compilers?
>> Is it already supported in x86 / x64 / arm?
>>
>> or it is a kind of emulation?
>
> Probably it will be emulation just like those precise N-bit types.
>

The point of the N-bit types is not as a general sized type for use in
general coding. They are intended for use in specific hardware which
has support for the size. A prime candidate is programmable logic, when
bit sizes of 9-bit, 18-bit, 36-bit and 72-bit are very common in DSP
accelerator blocks. When coding for such targets, you are going to want
specific types that match these sizes. Having such support standardised
makes live easier for everyone.

(I know very little about the decimal floating point types and support.)

Richard Damon

unread,
Sep 22, 2022, 7:10:56 PM9/22/22
to
On 9/22/22 2:29 PM, Keith Thompson wrote:
> Thiago Adams <thiago...@gmail.com> writes:
>> Decimal floating point types were added into C23.
>>
>> I was wondering.. how it will be implemented by c23 compilers?
>> Is it already supported in x86 / x64 / arm?
>>
>> or it is a kind of emulation?
>
> Decimal floating types are optional in C23.
>
> Presumably they'll be implemented in hardware for targets that
> support them, or in emulation or not at all for targets that don't.
>
> gcc already supports decimal floating-point on some targets. A quick
> test indicates that it generates function calls for _Decimal64 addition,
> for example. I don't know the details. From the gcc manual:
>
> As an extension, GNU C supports decimal floating types as defined in
> the N1312 draft of ISO/IEC WDTR24732. Support for decimal floating
> types in GCC will evolve as the draft technical report changes.
> Calling conventions for any target might also change. Not all
> targets support decimal floating types.
>

The key point is that decimal floating point isn't that hard to
implement in software. It is just slightly harder than binary floating
point on hardware that doesn't support that.

The extra difficulty is mostly "shifting" by powers of 10 instead of 2.

Bart

unread,
Sep 22, 2022, 8:20:01 PM9/22/22
to
It would be if designed properly. But not the Decimal64 type as
described here:

https://en.wikipedia.org/wiki/Decimal64_floating-point_format

It is horrible. You would spend most of the time trying to disentangle
what is what. Look for example at those groups of 10-bit 'declets'.

It's probably OK if someone else makes the effort to implement it in
hardware. But not as it is.

Richard Damon

unread,
Sep 22, 2022, 11:42:30 PM9/22/22
to
The version with the 10-bit declets is a variant, (Densely packed
Decimal), it tends to be more commonly done in the Binary Integer
significand format, where the mantisa is one "binary" number, with a
scale factor of a power of 10.

> It's probably OK if someone else makes the effort to implement it in
> hardware. But not as it is.

Yes, The Densely packed format is likely much more prone to being
implemented in hardware only.

Michael S

unread,
Sep 23, 2022, 5:50:08 AM9/23/22
to
DPD is intended for HW implementations.
Software implementation are expected to use BID.

> It's probably OK if someone else makes the effort to implement it in
> hardware. But not as it is.

Under given constrains of fitting into 64 bits decimal64 in BID encoding
is not horrible at all.
Software implementation could to be rather fast on modern 64-bit processors.

Intel's reference library implementation from 15+ plus years ago is slow
not because it should be, but probably because it was done in hurry and
never improved after that.

The real problem with IEEE decimal64 is completely different.
It's just not useful.
For accountants it's o.k. for input/output but does not have enough of
precision to hold intermediate results. In theory, higher precision
could be used when needed, but that defeats the primary purpose
of decimal floating-point, which is to make life of accountants simpler.
So, the part of accountants that wants their lives simpler (and got
brains) will use decimal128 from start to finish. Bigger fraction
of accountants will continue to use fix-point and ignore decimal
FP as too innovative and breaking existing practices.
And the rest of the world is happy with binary and never wanted
decimal to start with.

So, no place for decimal64 in the world, as I understand it, except
possibly, as a storage format for big missives of financial
data. But even in this role zipped decimal128 can probably do
at least as well if not better.



Thomas David Rivers

unread,
Sep 30, 2022, 4:31:39 PM9/30/22
to
It is implemented in hardware on the z/Architecture, and our
compilers have natively supported that for many years.

We also have compilers that support it for x86 machines (both
32-bit and 64-bit) using the IBM DPD format. Since it's not
native to the hardware those are supported via runtime functions.

- Dave Rivers -

--
riv...@dignus.com Work: (919) 676-0847
Get your mainframe programming tools at http://www.dignus.com
0 new messages