Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Nuclear war can ruin your whole compile." -- Karl Lehenbauer


devel / comp.arch / Extended double precision decimal floating point

SubjectAuthor
* Extended double precision decimal floating pointrobf...@gmail.com
+* Re: Extended double precision decimal floating pointTerje Mathisen
|`* Re: Extended double precision decimal floating pointBGB
| `* Re: Extended double precision decimal floating pointTerje Mathisen
|  `* Re: Extended double precision decimal floating pointBGB
|   `* Re: Extended double precision decimal floating pointrobf...@gmail.com
|    `* Re: Extended double precision decimal floating pointIvan Godard
|     `* Re: Extended double precision decimal floating pointThomas Koenig
|      `* Re: Extended double precision decimal floating pointBGB
|       +* Re: Extended double precision decimal floating pointIvan Godard
|       |+* Re: Extended double precision decimal floating pointMitchAlsup
|       ||`* Re: Extended double precision decimal floating pointBGB
|       || `* Re: Extended double precision decimal floating pointTerje Mathisen
|       ||  `- Re: Extended double precision decimal floating pointBGB
|       |+- Re: Extended double precision decimal floating pointBGB
|       |+- Re: Extended double precision decimal floating pointMichael S
|       |`* Re: Extended double precision decimal floating pointTerje Mathisen
|       | `* Re: Extended double precision decimal floating pointJohn Levine
|       |  `- Re: Extended double precision decimal floating pointIvan Godard
|       `- Re: Extended double precision decimal floating pointTerje Mathisen
`* Re: Extended double precision decimal floating pointMichael S
 +* Re: Extended double precision decimal floating pointJohn Levine
 |`* Re: Extended double precision decimal floating pointMichael S
 | `* Re: Extended double precision decimal floating pointJohn Levine
 |  +* Re: Extended double precision decimal floating pointStefan Monnier
 |  |+- Re: Extended double precision decimal floating pointMitchAlsup
 |  |`* Re: Extended double precision decimal floating pointrobf...@gmail.com
 |  | `* Re: Extended double precision decimal floating pointMitchAlsup
 |  |  +* Re: Extended double precision decimal floating pointIvan Godard
 |  |  |`- Re: Extended double precision decimal floating pointMitchAlsup
 |  |  +- Re: Extended double precision decimal floating pointBGB
 |  |  `* Re: Extended double precision decimal floating pointThomas Koenig
 |  |   `* Re: Extended double precision decimal floating pointMichael S
 |  |    +- Re: Extended double precision decimal floating pointTerje Mathisen
 |  |    `- Re: Extended double precision decimal floating pointThomas Koenig
 |  `* Re: Extended double precision decimal floating pointEricP
 |   `* Re: Financial arithmetic, was Extended double precision decimal floating pointJohn Levine
 |    `- Re: Financial arithmetic, was Extended double precision decimalTerje Mathisen
 +- Re: Extended double precision decimal floating pointTerje Mathisen
 `* Re: Extended double precision decimal floating pointQuadibloc
  `* Re: Extended double precision decimal floating pointBGB
   `* Re: Extended double precision decimal floating pointQuadibloc
    `* Re: Extended double precision decimal floating pointMitchAlsup
     +* Re: Extended double precision decimal floating pointIvan Godard
     |+* Re: Extended double precision decimal floating pointJohn Levine
     ||`- Re: Extended double precision decimal floating pointThomas Koenig
     |+* Re: Extended double precision decimal floating pointMitchAlsup
     ||`* Re: Extended double precision decimal floating pointIvan Godard
     || +* Re: Extended double precision decimal floating pointMichael S
     || |`- Re: Extended double precision decimal floating pointIvan Godard
     || `* Re: Extended double precision decimal floating pointMitchAlsup
     ||  `- Re: Extended double precision decimal floating pointIvan Godard
     |`* Re: Extended double precision decimal floating pointAnton Ertl
     | `* Re: Extended double precision decimal floating pointmac
     |  +- Re: Extended double precision decimal floating pointAnton Ertl
     |  `* Re: Extended double precision decimal floating pointQuadibloc
     |   `- Re: Extended double precision decimal floating pointQuadibloc
     +* Re: Extended double precision decimal floating pointQuadibloc
     |+- Re: Extended double precision decimal floating pointrobf...@gmail.com
     |+* Re: Extended double precision decimal floating pointAnton Ertl
     ||`* Re: IBM features, Extended double precision decimal floating pointJohn Levine
     || +* Re: IBM features, Extended double precision decimal floating pointJohn Dallman
     || |`- Re: IBM features, Extended double precision decimal floating pointQuadibloc
     || +* Re: IBM features, Extended double precision decimal floating pointThomas Koenig
     || |+* Re: IBM features, Extended double precision decimal floating pointrobf...@gmail.com
     || ||+* Re: IBM features, Extended double precision decimal floating pointMitchAlsup
     || |||`- Re: IBM features, Extended double precision decimal floating pointJohn Levine
     || ||+- Re: IBM features, Extended double precision decimal floating pointBGB
     || ||`- Re: IBM features, Extended double precision decimal floating pointThomas Koenig
     || |`* Re: IBM features, Extended double precision decimal floating pointJohn Levine
     || | `* Re: IBM features, Extended double precision decimal floating pointThomas Koenig
     || |  +- Re: IBM features, Extended double precision decimal floating pointBGB
     || |  `* Re: IBM features, Extended double precision decimal floating pointJohn Levine
     || |   `- Re: IBM features, Extended double precision decimal floating pointThomas Koenig
     || `* Re: IBM features, Extended double precision decimal floating pointAnton Ertl
     ||  `* Re: IBM features, Extended double precision decimal floating pointMitchAlsup
     ||   +* Re: IBM features, Extended double precision decimal floating pointAnton Ertl
     ||   |`- Re: IBM features, Extended double precision decimal floating pointThomas Koenig
     ||   `* Re: IBM features, Extended double precision decimal floating pointEricP
     ||    `- Re: IBM features, Extended double precision decimal floating pointEricP
     |+* Re: Extended double precision decimal floating pointIvan Godard
     ||+* Re: Extended double precision decimal floating pointMitchAlsup
     |||`* Re: Extended double precision decimal floating pointIvan Godard
     ||| +- Re: Extended double precision decimal floating pointMitchAlsup
     ||| `- Re: Extended double precision decimal floating pointQuadibloc
     ||`- Re: Extended double precision decimal floating pointThomas Koenig
     |`- Re: Extended double precision decimal floating pointMitchAlsup
     `* Re: Extended double precision decimal floating pointTerje Mathisen
      +* Re: Extended double precision decimal floating pointrobf...@gmail.com
      |+* Re: Extended double precision decimal floating pointIvan Godard
      ||`- Re: Extended double precision decimal floating pointMitchAlsup
      |+- Re: Extended double precision decimal floating pointTerje Mathisen
      |+- Re: Extended double precision decimal floating pointEricP
      |`- Re: Extended double precision decimal floating pointMitchAlsup
      +* Re: Extended double precision decimal floating pointMitchAlsup
      |`- Re: Extended double precision decimal floating pointBGB
      `* Re: Extended double precision decimal floating pointStefan Monnier
       `* Re: Extended double precision decimal floating pointTerje Mathisen
        `* Re: Extended double precision decimal floating pointStefan Monnier
         +* Re: Extended double precision decimal floating pointMitchAlsup
         |`* Re: Extended double precision decimal floating pointMichael S
         `* Re: Extended double precision decimal floating pointTerje Mathisen

Pages:12345
Extended double precision decimal floating point

<d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24829&group=comp.arch#24829

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a0c:d7cb:0:b0:444:2b27:80d3 with SMTP id g11-20020a0cd7cb000000b004442b2780d3mr1748476qvj.57.1650585572265;
Thu, 21 Apr 2022 16:59:32 -0700 (PDT)
X-Received: by 2002:a05:6830:1057:b0:605:4e91:dbeb with SMTP id
b23-20020a056830105700b006054e91dbebmr818238otp.185.1650585571963; Thu, 21
Apr 2022 16:59:31 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Thu, 21 Apr 2022 16:59:31 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=2607:fea8:1dde:6a00:dd52:c4e1:6095:2b94;
posting-account=QId4bgoAAABV4s50talpu-qMcPp519Eb
NNTP-Posting-Host: 2607:fea8:1dde:6a00:dd52:c4e1:6095:2b94
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com>
Subject: Extended double precision decimal floating point
From: robfi...@gmail.com (robf...@gmail.com)
Injection-Date: Thu, 21 Apr 2022 23:59:32 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 19
 by: robf...@gmail.com - Thu, 21 Apr 2022 23:59 UTC

Thinking of using the following for decimal floating-point:
|Sign 1| Exponent 9|Significand 70|
It is an 80-bit format so called extended double-precision.
Double precision is just barely adequate, extended double precision feels safer.
Groups of ten bits are needed to represent numbers in densely-packed-decimal format. 70 bits gives 21 significant digits.
The exponent is a power of ten represented as a binary number, so a nine-bit exponent has a good range (-255 to +256) considerably more than a binary exponent of the same size.
I have also been considering the following format which has 20 significant digits and a larger exponent, but packs digits in two different formats.
|Sign 1| Exponent 12|Lead digits 7|Significand 60|

The extended double format appeals to me because the hardware is quite a bit smaller than quad precision. I suppose I could use the quad precision format but only implement extended double precision in hardware. The least significant digits would be out to lunch and the exponent would not come close to full use.

Re: Extended double precision decimal floating point

<t3tmrd$m06$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24830&group=comp.arch#24830

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!aioe.org!10O9MudpjwoXIahOJRbDvA.user.46.165.242.91.POSTED!not-for-mail
From: terje.ma...@tmsw.no (Terje Mathisen)
Newsgroups: comp.arch
Subject: Re: Extended double precision decimal floating point
Date: Fri, 22 Apr 2022 09:52:12 +0200
Organization: Aioe.org NNTP Server
Message-ID: <t3tmrd$m06$1@gioia.aioe.org>
References: <d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="22534"; posting-host="10O9MudpjwoXIahOJRbDvA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101
Firefox/68.0 SeaMonkey/2.53.11.1
X-Notice: Filtered by postfilter v. 0.9.2
 by: Terje Mathisen - Fri, 22 Apr 2022 07:52 UTC

robf...@gmail.com wrote:
> Thinking of using the following for decimal floating-point: |Sign 1|
> Exponent 9|Significand 70| It is an 80-bit format so called extended
> double-precision. Double precision is just barely adequate, extended
> double precision feels safer. Groups of ten bits are needed to
> represent numbers in densely-packed-decimal format. 70 bits gives 21
> significant digits. The exponent is a power of ten represented as a
> binary number, so a nine-bit exponent has a good range (-255 to +256)
> considerably more than a binary exponent of the same size. I have
> also been considering the following format which has 20 significant
> digits and a larger exponent, but packs digits in two different
> formats. |Sign 1| Exponent 12|Lead digits 7|Significand 60|
>
> The extended double format appeals to me because the hardware is
> quite a bit smaller than quad precision. I suppose I could use the
> quad precision format but only implement extended double precision in
> hardware. The least significant digits would be out to lunch and the
> exponent would not come close to full use.
>
What about having a hybrid, i.e. HW for the easy cases and fall back to
sw emulation for larger/higher precision inputs?

All this is presumably NOT speed critical, right?

Terje

--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"

Re: Extended double precision decimal floating point

<t3trjp$t04$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24831&group=comp.arch#24831

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: cr88...@gmail.com (BGB)
Newsgroups: comp.arch
Subject: Re: Extended double precision decimal floating point
Date: Fri, 22 Apr 2022 04:13:27 -0500
Organization: A noiseless patient Spider
Lines: 95
Message-ID: <t3trjp$t04$1@dont-email.me>
References: <d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com>
<t3tmrd$m06$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 22 Apr 2022 09:13:29 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="be9ff9f2e1df237c9e5eae2cfb7cad5c";
logging-data="29700"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/59+DMcngUOCKBEjyJ1ud+"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.8.0
Cancel-Lock: sha1:0jDGMsEvhMf4ELGsm3SKHwhGNqY=
In-Reply-To: <t3tmrd$m06$1@gioia.aioe.org>
Content-Language: en-US
 by: BGB - Fri, 22 Apr 2022 09:13 UTC

On 4/22/2022 2:52 AM, Terje Mathisen wrote:
> robf...@gmail.com wrote:
>> Thinking of using the following for decimal floating-point: |Sign 1|
>> Exponent 9|Significand 70| It is an 80-bit format so called extended
>> double-precision. Double precision is just barely adequate, extended
>> double precision feels safer. Groups of ten bits are needed to
>> represent numbers in densely-packed-decimal format. 70 bits gives 21
>> significant digits. The exponent is a power of ten represented as a
>> binary number, so a nine-bit exponent has a good range (-255 to +256)
>> considerably more than a binary exponent of the same size. I have
>> also been considering the following format which has 20 significant
>> digits and a larger exponent, but packs digits in two different
>> formats. |Sign 1| Exponent 12|Lead digits 7|Significand 60|
>>
>> The extended double format appeals to me because the hardware is
>> quite a bit smaller than quad precision. I suppose I could use the
>> quad precision format but only implement extended double precision in
>> hardware. The least significant digits would be out to lunch and the
>> exponent would not come close to full use.
>>
> What about having a hybrid, i.e. HW for the easy cases and fall back to
> sw emulation for larger/higher precision inputs?
>
> All this is presumably NOT speed critical, right?
>

I remain skeptical of the general-purpose viability of Decimal Floating
Point.

Binary FP is "already bad enough", and decimal FP is in nearly every way
worse, with the sole exceptions being:
Allows for slightly more efficient conversion to/from ASCII;
Can mimic controlled decimal rounding behavior...
But:
More complicated to deal with in hardware;
Will almost invariably be worse WRT cost and timing.

You don't just have an adder chain, now you got an adder chain trying to
fake doing decimal arithmetic.

One would have an FPU that is both more expensive and fundamentally more
expensive than a binary FPU.

....

However, these use-cases could be done better/cheaper via Packed BCD or
similar. Say, one treats a 64-bit number as 16 Packed BCD digits, with a
few special ops for ADD/SUB/CMP (*)/... with BCD numbers.
Also, with this approach one can use bit-shifts on decimal numbers.

*: For unsigned, one could use a normal integer compare. However, signed
integer and 10s complement would not cross over at the same point (well,
unless one is happy with it being asymmetric; then one can reuse signed
integer compare).

One would lose a few digits with Packed BCD vs DPD, but probably not a
huge loss.

Also, BCD seems to map up better with how decimal is handled in both
COBOL and SQL (eg: they will define the number of digits before and
after the decimal point), which is presumably where most of its use-case
would reside.

Well, oh well, in my case, I have an FPU:
Does Binary64 OK (FADD/FSUB/FMUL).
Had wanted a 96-bit format (128b in storage),
but, it makes FPU cost and timing more of an issue...
Recently added FDIV/FSQRT (sorta...).
... but its performance is basically a boat anchor ...

Generally, Binary32 and Binary16 see a lot more use than Binary96
probably would.

For many cases where Binary16 is used, one can also get away with a
cheaper "FDIV", namely approximating Rs/Rt with integer (Rs-Rt+Bias). I
am left to also wonder about the possibility of using a dynamic lookup
and LERPed bias, though in my testing it seems that getting the dynamic
bias be all that much more accurate than a constant bias is easier said
than done (probably still need to figure out which bits to use as
inputs; dynamic bias based on the high mantissa bits seems to work OK
with approximating a reciprocals/RCP, but falls short when it comes to DIV).

....

> Terje
>

Re: Extended double precision decimal floating point

<t3u085$1165$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24832&group=comp.arch#24832

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!aioe.org!10O9MudpjwoXIahOJRbDvA.user.46.165.242.91.POSTED!not-for-mail
From: terje.ma...@tmsw.no (Terje Mathisen)
Newsgroups: comp.arch
Subject: Re: Extended double precision decimal floating point
Date: Fri, 22 Apr 2022 12:32:36 +0200
Organization: Aioe.org NNTP Server
Message-ID: <t3u085$1165$1@gioia.aioe.org>
References: <d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com>
<t3tmrd$m06$1@gioia.aioe.org> <t3trjp$t04$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="33989"; posting-host="10O9MudpjwoXIahOJRbDvA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101
Firefox/68.0 SeaMonkey/2.53.11.1
X-Notice: Filtered by postfilter v. 0.9.2
 by: Terje Mathisen - Fri, 22 Apr 2022 10:32 UTC

BGB wrote:
> On 4/22/2022 2:52 AM, Terje Mathisen wrote:
>> robf...@gmail.com wrote:
>>> Thinking of using the following for decimal floating-point: |Sign 1|
>>> Exponent 9|Significand 70| It is an 80-bit format so called extended
>>> double-precision. Double precision is just barely adequate, extended
>>> double precision feels safer. Groups of ten bits are needed to
>>> represent numbers in densely-packed-decimal format. 70 bits gives 21
>>> significant digits. The exponent is a power of ten represented as a
>>> binary number, so a nine-bit exponent has a good range (-255 to +256)
>>> considerably more than a binary exponent of the same size. I have
>>> also been considering the following format which has 20 significant
>>> digits and a larger exponent, but packs digits in two different
>>> formats. |Sign 1| Exponent 12|Lead digits 7|Significand 60|
>>>
>>> The extended double format appeals to me because the hardware is
>>> quite a bit smaller than quad precision. I suppose I could use the
>>> quad precision format but only implement extended double precision in
>>> hardware. The least significant digits would be out to lunch and the
>>> exponent would not come close to full use.
>>>
>> What about having a hybrid, i.e. HW for the easy cases and fall back
>> to sw emulation for larger/higher precision inputs?
>>
>> All this is presumably NOT speed critical, right?
>>
>
> I remain skeptical of the general-purpose viability of Decimal Floating
> Point.

It is almost by definition NOT general-purpose.
>
>
> Binary FP is "already bad enough", and decimal FP is in nearly every way
> worse, with the sole exceptions being:
>   Allows for slightly more efficient conversion to/from ASCII;
>   Can mimic controlled decimal rounding behavior...
> But:
>   More complicated to deal with in hardware;
>   Will almost invariably be worse WRT cost and timing.
>
> You don't just have an adder chain, now you got an adder chain trying to
> fake doing decimal arithmetic.
>
> One would have an FPU that is both more expensive and fundamentally more
> expensive than a binary FPU.
>

Yeah.

It is fun though to figure out how to implement the binary-encoded
decimal option, this is where you end up having decimal scaling being
the only real problem/bottleneck, but you can do a lot using tables of
pre-calcuated reciprocals of powers of 5.

Michael S is the comp.arch resident guru of these things. :-)

> ...
>
>
> However, these use-cases could be done better/cheaper via Packed BCD or
> similar. Say, one treats a 64-bit number as 16 Packed BCD digits, with a
> few special ops for ADD/SUB/CMP (*)/... with BCD numbers.
> Also, with this approach one can use bit-shifts on decimal numbers.
>
> *: For unsigned, one could use a normal integer compare. However, signed
> integer and 10s complement would not cross over at the same point (well,
> unless one is happy with it being asymmetric; then one can reuse signed
> integer compare).
>
>
> One would lose a few digits with Packed BCD vs DPD, but probably not a
> huge loss.

AFAIK, all DPD-encoded decimal fp units starts operations by unpacking
the 10-bit chunks into 3 BCD digits.

That is at least the most obvious way to implement it, particularly
because the DPD encoding was chosen to allow very easy packing/unpacking
ops, cheap enough that you can easily have 10 of them in parallel.
>
> Also, BCD seems to map up better with how decimal is handled in both
> COBOL and SQL (eg: they will define the number of digits before and
> after the decimal point), which is presumably where most of its use-case
> would reside.

Right.

Terje

--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"

Re: Extended double precision decimal floating point

<t3urj9$4ou$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24833&group=comp.arch#24833

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: cr88...@gmail.com (BGB)
Newsgroups: comp.arch
Subject: Re: Extended double precision decimal floating point
Date: Fri, 22 Apr 2022 13:19:19 -0500
Organization: A noiseless patient Spider
Lines: 181
Message-ID: <t3urj9$4ou$1@dont-email.me>
References: <d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com>
<t3tmrd$m06$1@gioia.aioe.org> <t3trjp$t04$1@dont-email.me>
<t3u085$1165$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 22 Apr 2022 18:19:21 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="be9ff9f2e1df237c9e5eae2cfb7cad5c";
logging-data="4894"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/c8oupwAhksKvbEfayhAG+"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.8.0
Cancel-Lock: sha1:puthB1/17DW1iiLBXmY8R3KlSMM=
In-Reply-To: <t3u085$1165$1@gioia.aioe.org>
Content-Language: en-US
 by: BGB - Fri, 22 Apr 2022 18:19 UTC

On 4/22/2022 5:32 AM, Terje Mathisen wrote:
> BGB wrote:
>> On 4/22/2022 2:52 AM, Terje Mathisen wrote:
>>> robf...@gmail.com wrote:
>>>> Thinking of using the following for decimal floating-point: |Sign 1|
>>>> Exponent 9|Significand 70| It is an 80-bit format so called extended
>>>> double-precision. Double precision is just barely adequate, extended
>>>> double precision feels safer. Groups of ten bits are needed to
>>>> represent numbers in densely-packed-decimal format. 70 bits gives 21
>>>> significant digits. The exponent is a power of ten represented as a
>>>> binary number, so a nine-bit exponent has a good range (-255 to +256)
>>>> considerably more than a binary exponent of the same size. I have
>>>> also been considering the following format which has 20 significant
>>>> digits and a larger exponent, but packs digits in two different
>>>> formats. |Sign 1| Exponent 12|Lead digits 7|Significand 60|
>>>>
>>>> The extended double format appeals to me because the hardware is
>>>> quite a bit smaller than quad precision. I suppose I could use the
>>>> quad precision format but only implement extended double precision in
>>>> hardware. The least significant digits would be out to lunch and the
>>>> exponent would not come close to full use.
>>>>
>>> What about having a hybrid, i.e. HW for the easy cases and fall back
>>> to sw emulation for larger/higher precision inputs?
>>>
>>> All this is presumably NOT speed critical, right?
>>>
>>
>> I remain skeptical of the general-purpose viability of Decimal
>> Floating Point.
>
> It is almost by definition NOT general-purpose.
>>
>>
>> Binary FP is "already bad enough", and decimal FP is in nearly every
>> way worse, with the sole exceptions being:
>>    Allows for slightly more efficient conversion to/from ASCII;
>>    Can mimic controlled decimal rounding behavior...
>> But:
>>    More complicated to deal with in hardware;
>>    Will almost invariably be worse WRT cost and timing.
>>
>> You don't just have an adder chain, now you got an adder chain trying
>> to fake doing decimal arithmetic.
>>
>> One would have an FPU that is both more expensive and fundamentally
>> more expensive than a binary FPU.
>>
>
> Yeah.
>
> It is fun though to figure out how to implement the binary-encoded
> decimal option, this is where you end up having decimal scaling being
> the only real problem/bottleneck, but you can do a lot using tables of
> pre-calcuated reciprocals of powers of 5.
>
> Michael S is the comp.arch resident guru of these things. :-)
>

OK.

If one unpacks to BCD as an intermediate though, it becomes a
simpler/cheaper "shift by a multiple of 4 bits".

>> ...
>>
>>
>> However, these use-cases could be done better/cheaper via Packed BCD
>> or similar. Say, one treats a 64-bit number as 16 Packed BCD digits,
>> with a few special ops for ADD/SUB/CMP (*)/... with BCD numbers.
>> Also, with this approach one can use bit-shifts on decimal numbers.
>>
>> *: For unsigned, one could use a normal integer compare. However,
>> signed integer and 10s complement would not cross over at the same
>> point (well, unless one is happy with it being asymmetric; then one
>> can reuse signed integer compare).
>>
>>
>> One would lose a few digits with Packed BCD vs DPD, but probably not a
>> huge loss.
>
> AFAIK, all DPD-encoded decimal fp units starts operations by unpacking
> the 10-bit chunks into 3 BCD digits.
>
> That is at least the most obvious way to implement it, particularly
> because the DPD encoding was chosen to allow very easy packing/unpacking
> ops, cheap enough that you can easily have 10 of them in parallel.

This part is probably true at least. One could maybe have a converter op
that converts between 15 packed BCD digits, and DPD (50 bits).

If one excludes the combination field, this could almost match up with
the Decimal64 format. Could almost treat the last-digit (via the
combination field) as a special case.

Would almost make more sense though if the exponent and combination
field were in a different order, say:
Sgn.Exp8.Comb5.Fra50
In which case the converter op could be treated as:
15 digits in 50 bits.
16 digits in 55 bits.
Or, maybe also:
Sgn.Exp9.BCD1.Fra50

Which while losing 1 bit on the exponent range, is "less convoluted".

This could maybe make sense if one were implementing it mostly in
software using hardware Packed BCD and converter ops, which is probably
a cheaper option if compared with actually trying to do it directly in
hardware.

One could maybe skip the DPD part, and do a format like:
Sgn.Exp15.Fra112 (28 digit)
Or:
Sgn.Exp11.Fra116 (29 digit)
With the fraction as Packed BCD.

In this case, all one really needs to deal with effectively it in
software is some BCD helper ops.

I guess one could debate whether it would be better to go the route of
special ADD/SUB ops for BCD, or use the ALU as normal and then use a
"fixup ops".

Eg:
ADD R4, R5, R6 | CLRT //Clear SR.T
DAA R6 //Fixup BCD, treat SR.T as carry.
Or:
SUB R4, R5, R6 | CLRT //Clear SR.T
DAS R6 //Fixup BCD, treat SR.T as borrow.

This dedicated DAA/DAS route likely using less LUTs.

Dealing with 128-bits of BCD:
ADDX R4, R6, R8
CLRT
DAA R8
DAA R9

....

I could add these to BJX2, in theory, just not sure of a strong use-case
at the moment.

Less sure how multiply and divide would work, likely a pretty slow
option involving long multiply/divide, and another post fixup op likely
for dealing with multiplying a BCD number by a single BCD digit.

Could probably work, would be pretty slow, and would likely need "early
out" cases to deal with the rest of the digits being zeroes.

>>
>> Also, BCD seems to map up better with how decimal is handled in both
>> COBOL and SQL (eg: they will define the number of digits before and
>> after the decimal point), which is presumably where most of its
>> use-case would reside.
>
> Right.
>

Yeah, this is a thing:
Binary FP: Pretty much everywhere, lots of use-cases.
BCD: COBOL and SQL and similar.
Decimal FP: ?... ('finances' or something, *)

*: Except, here, you can't really auto-normalize (this would break the
rounding rules), so would only likely matter in "overflow" cases, but
these would likely break the rounding rules anyways (in the rare event
that a balance gets so big that it can no longer be contained).

One can argue, maybe an incorrectly rounded value is better than one
which overflows, but this is mostly sweeping the issue under the rug.

Re: Extended double precision decimal floating point

<aeef3da0-5f71-4cba-942e-0b99479e58f1n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24836&group=comp.arch#24836

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:6214:d0b:b0:446:59c7:8390 with SMTP id 11-20020a0562140d0b00b0044659c78390mr6222223qvh.41.1650692813633;
Fri, 22 Apr 2022 22:46:53 -0700 (PDT)
X-Received: by 2002:a05:6808:11ca:b0:2d9:a01a:488b with SMTP id
p10-20020a05680811ca00b002d9a01a488bmr8372458oiv.214.1650692813387; Fri, 22
Apr 2022 22:46:53 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Fri, 22 Apr 2022 22:46:53 -0700 (PDT)
In-Reply-To: <t3urj9$4ou$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2607:fea8:1dde:6a00:a1a8:72a8:f243:7cf5;
posting-account=QId4bgoAAABV4s50talpu-qMcPp519Eb
NNTP-Posting-Host: 2607:fea8:1dde:6a00:a1a8:72a8:f243:7cf5
References: <d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com>
<t3tmrd$m06$1@gioia.aioe.org> <t3trjp$t04$1@dont-email.me>
<t3u085$1165$1@gioia.aioe.org> <t3urj9$4ou$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <aeef3da0-5f71-4cba-942e-0b99479e58f1n@googlegroups.com>
Subject: Re: Extended double precision decimal floating point
From: robfi...@gmail.com (robf...@gmail.com)
Injection-Date: Sat, 23 Apr 2022 05:46:53 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 194
 by: robf...@gmail.com - Sat, 23 Apr 2022 05:46 UTC

On Friday, April 22, 2022 at 2:19:24 PM UTC-4, BGB wrote:
> On 4/22/2022 5:32 AM, Terje Mathisen wrote:
> > BGB wrote:
> >> On 4/22/2022 2:52 AM, Terje Mathisen wrote:
> >>> robf...@gmail.com wrote:
> >>>> Thinking of using the following for decimal floating-point: |Sign 1|
> >>>> Exponent 9|Significand 70| It is an 80-bit format so called extended
> >>>> double-precision. Double precision is just barely adequate, extended
> >>>> double precision feels safer. Groups of ten bits are needed to
> >>>> represent numbers in densely-packed-decimal format. 70 bits gives 21
> >>>> significant digits. The exponent is a power of ten represented as a
> >>>> binary number, so a nine-bit exponent has a good range (-255 to +256)
> >>>> considerably more than a binary exponent of the same size. I have
> >>>> also been considering the following format which has 20 significant
> >>>> digits and a larger exponent, but packs digits in two different
> >>>> formats. |Sign 1| Exponent 12|Lead digits 7|Significand 60|
> >>>>
> >>>> The extended double format appeals to me because the hardware is
> >>>> quite a bit smaller than quad precision. I suppose I could use the
> >>>> quad precision format but only implement extended double precision in
> >>>> hardware. The least significant digits would be out to lunch and the
> >>>> exponent would not come close to full use.
> >>>>
> >>> What about having a hybrid, i.e. HW for the easy cases and fall back
> >>> to sw emulation for larger/higher precision inputs?
> >>>
> >>> All this is presumably NOT speed critical, right?
> >>>
> >>
> >> I remain skeptical of the general-purpose viability of Decimal
> >> Floating Point.
> >
> > It is almost by definition NOT general-purpose.
> >>
> >>
> >> Binary FP is "already bad enough", and decimal FP is in nearly every
> >> way worse, with the sole exceptions being:
> >> Allows for slightly more efficient conversion to/from ASCII;
> >> Can mimic controlled decimal rounding behavior...
> >> But:
> >> More complicated to deal with in hardware;
> >> Will almost invariably be worse WRT cost and timing.
> >>
> >> You don't just have an adder chain, now you got an adder chain trying
> >> to fake doing decimal arithmetic.
> >>
> >> One would have an FPU that is both more expensive and fundamentally
> >> more expensive than a binary FPU.
> >>
> >
> > Yeah.
> >
> > It is fun though to figure out how to implement the binary-encoded
> > decimal option, this is where you end up having decimal scaling being
> > the only real problem/bottleneck, but you can do a lot using tables of
> > pre-calcuated reciprocals of powers of 5.
> >
> > Michael S is the comp.arch resident guru of these things. :-)
> >
> OK.
>
> If one unpacks to BCD as an intermediate though, it becomes a
> simpler/cheaper "shift by a multiple of 4 bits".
> >> ...
> >>
> >>
> >> However, these use-cases could be done better/cheaper via Packed BCD
> >> or similar. Say, one treats a 64-bit number as 16 Packed BCD digits,
> >> with a few special ops for ADD/SUB/CMP (*)/... with BCD numbers.
> >> Also, with this approach one can use bit-shifts on decimal numbers.
> >>
> >> *: For unsigned, one could use a normal integer compare. However,
> >> signed integer and 10s complement would not cross over at the same
> >> point (well, unless one is happy with it being asymmetric; then one
> >> can reuse signed integer compare).
> >>
> >>
> >> One would lose a few digits with Packed BCD vs DPD, but probably not a
> >> huge loss.
> >
> > AFAIK, all DPD-encoded decimal fp units starts operations by unpacking
> > the 10-bit chunks into 3 BCD digits.
> >
> > That is at least the most obvious way to implement it, particularly
> > because the DPD encoding was chosen to allow very easy packing/unpacking
> > ops, cheap enough that you can easily have 10 of them in parallel.
> This part is probably true at least. One could maybe have a converter op
> that converts between 15 packed BCD digits, and DPD (50 bits).
>
> If one excludes the combination field, this could almost match up with
> the Decimal64 format. Could almost treat the last-digit (via the
> combination field) as a special case.
>
> Would almost make more sense though if the exponent and combination
> field were in a different order, say:
> Sgn.Exp8.Comb5.Fra50
> In which case the converter op could be treated as:
> 15 digits in 50 bits.
> 16 digits in 55 bits.
> Or, maybe also:
> Sgn.Exp9.BCD1.Fra50
>
> Which while losing 1 bit on the exponent range, is "less convoluted".
>
>
> This could maybe make sense if one were implementing it mostly in
> software using hardware Packed BCD and converter ops, which is probably
> a cheaper option if compared with actually trying to do it directly in
> hardware.
>
>
> One could maybe skip the DPD part, and do a format like:
> Sgn.Exp15.Fra112 (28 digit)
> Or:
> Sgn.Exp11.Fra116 (29 digit)
> With the fraction as Packed BCD.
>
>
> In this case, all one really needs to deal with effectively it in
> software is some BCD helper ops.
>
> I guess one could debate whether it would be better to go the route of
> special ADD/SUB ops for BCD, or use the ALU as normal and then use a
> "fixup ops".
>
> Eg:
> ADD R4, R5, R6 | CLRT //Clear SR.T
> DAA R6 //Fixup BCD, treat SR.T as carry.
> Or:
> SUB R4, R5, R6 | CLRT //Clear SR.T
> DAS R6 //Fixup BCD, treat SR.T as borrow.
>
> This dedicated DAA/DAS route likely using less LUTs.
>
>
> Dealing with 128-bits of BCD:
> ADDX R4, R6, R8
> CLRT
> DAA R8
> DAA R9
>
> ...
>
>
> I could add these to BJX2, in theory, just not sure of a strong use-case
> at the moment.
>
> Less sure how multiply and divide would work, likely a pretty slow
> option involving long multiply/divide, and another post fixup op likely
> for dealing with multiplying a BCD number by a single BCD digit.
>
> Could probably work, would be pretty slow, and would likely need "early
> out" cases to deal with the rest of the digits being zeroes.
> >>
> >> Also, BCD seems to map up better with how decimal is handled in both
> >> COBOL and SQL (eg: they will define the number of digits before and
> >> after the decimal point), which is presumably where most of its
> >> use-case would reside.
> >
> > Right.
> >
> Yeah, this is a thing:
> Binary FP: Pretty much everywhere, lots of use-cases.
> BCD: COBOL and SQL and similar.
> Decimal FP: ?... ('finances' or something, *)
>
>
> *: Except, here, you can't really auto-normalize (this would break the
> rounding rules), so would only likely matter in "overflow" cases, but
> these would likely break the rounding rules anyways (in the rare event
> that a balance gets so big that it can no longer be contained).
>
> One can argue, maybe an incorrectly rounded value is better than one
> which overflows, but this is mostly sweeping the issue under the rug.

> What about having a hybrid, i.e. HW for the easy cases and fall back
> to sw emulation for larger/higher precision inputs?

A hybrid approach is good. I was going to trap to software for things like
divide and square root. While having ADD, SUB, MUL, CMP in hardware.
Whether it is in hardware or software should be invisible to the program.

Performance is less critical than having decimal numbers to deal with. But
there can be quite a performance boost by having some of it processed in
hardware.

15 digits available with double precision may not be quite enough once one
uses several digits to maintain rounding. Using quad or even triple precision
is a bit ridiculous though. I happen to like the extended double, 80-bit,
format but there is no standard one for decimal floats AFAIK? An 82-bit format
like the Itanium is tempting, but a multiple of 8 or 16 bits is easier to work with.
I could probably live with a 72-bit format, giving 18 digits plus 11 bits exponent,
and one sign bit. But I think it is better to work with an even multiple of bytes.


Click here to read the complete article
Re: Extended double precision decimal floating point

<t40o6j$oub$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24837&group=comp.arch#24837

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: iva...@millcomputing.com (Ivan Godard)
Newsgroups: comp.arch
Subject: Re: Extended double precision decimal floating point
Date: Sat, 23 Apr 2022 04:33:39 -0700
Organization: A noiseless patient Spider
Lines: 203
Message-ID: <t40o6j$oub$1@dont-email.me>
References: <d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com>
<t3tmrd$m06$1@gioia.aioe.org> <t3trjp$t04$1@dont-email.me>
<t3u085$1165$1@gioia.aioe.org> <t3urj9$4ou$1@dont-email.me>
<aeef3da0-5f71-4cba-942e-0b99479e58f1n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 23 Apr 2022 11:33:39 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="4ebe3cb4dc571f85fe22169309ba735c";
logging-data="25547"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ksFeY66Vr/pk50ObnX3/1"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.8.0
Cancel-Lock: sha1:7NZJte/cFXhLvexGVaFZhzdi0dA=
In-Reply-To: <aeef3da0-5f71-4cba-942e-0b99479e58f1n@googlegroups.com>
Content-Language: en-US
 by: Ivan Godard - Sat, 23 Apr 2022 11:33 UTC

On 4/22/2022 10:46 PM, robf...@gmail.com wrote:
> On Friday, April 22, 2022 at 2:19:24 PM UTC-4, BGB wrote:
>> On 4/22/2022 5:32 AM, Terje Mathisen wrote:
>>> BGB wrote:
>>>> On 4/22/2022 2:52 AM, Terje Mathisen wrote:
>>>>> robf...@gmail.com wrote:
>>>>>> Thinking of using the following for decimal floating-point: |Sign 1|
>>>>>> Exponent 9|Significand 70| It is an 80-bit format so called extended
>>>>>> double-precision. Double precision is just barely adequate, extended
>>>>>> double precision feels safer. Groups of ten bits are needed to
>>>>>> represent numbers in densely-packed-decimal format. 70 bits gives 21
>>>>>> significant digits. The exponent is a power of ten represented as a
>>>>>> binary number, so a nine-bit exponent has a good range (-255 to +256)
>>>>>> considerably more than a binary exponent of the same size. I have
>>>>>> also been considering the following format which has 20 significant
>>>>>> digits and a larger exponent, but packs digits in two different
>>>>>> formats. |Sign 1| Exponent 12|Lead digits 7|Significand 60|
>>>>>>
>>>>>> The extended double format appeals to me because the hardware is
>>>>>> quite a bit smaller than quad precision. I suppose I could use the
>>>>>> quad precision format but only implement extended double precision in
>>>>>> hardware. The least significant digits would be out to lunch and the
>>>>>> exponent would not come close to full use.
>>>>>>
>>>>> What about having a hybrid, i.e. HW for the easy cases and fall back
>>>>> to sw emulation for larger/higher precision inputs?
>>>>>
>>>>> All this is presumably NOT speed critical, right?
>>>>>
>>>>
>>>> I remain skeptical of the general-purpose viability of Decimal
>>>> Floating Point.
>>>
>>> It is almost by definition NOT general-purpose.
>>>>
>>>>
>>>> Binary FP is "already bad enough", and decimal FP is in nearly every
>>>> way worse, with the sole exceptions being:
>>>> Allows for slightly more efficient conversion to/from ASCII;
>>>> Can mimic controlled decimal rounding behavior...
>>>> But:
>>>> More complicated to deal with in hardware;
>>>> Will almost invariably be worse WRT cost and timing.
>>>>
>>>> You don't just have an adder chain, now you got an adder chain trying
>>>> to fake doing decimal arithmetic.
>>>>
>>>> One would have an FPU that is both more expensive and fundamentally
>>>> more expensive than a binary FPU.
>>>>
>>>
>>> Yeah.
>>>
>>> It is fun though to figure out how to implement the binary-encoded
>>> decimal option, this is where you end up having decimal scaling being
>>> the only real problem/bottleneck, but you can do a lot using tables of
>>> pre-calcuated reciprocals of powers of 5.
>>>
>>> Michael S is the comp.arch resident guru of these things. :-)
>>>
>> OK.
>>
>> If one unpacks to BCD as an intermediate though, it becomes a
>> simpler/cheaper "shift by a multiple of 4 bits".
>>>> ...
>>>>
>>>>
>>>> However, these use-cases could be done better/cheaper via Packed BCD
>>>> or similar. Say, one treats a 64-bit number as 16 Packed BCD digits,
>>>> with a few special ops for ADD/SUB/CMP (*)/... with BCD numbers.
>>>> Also, with this approach one can use bit-shifts on decimal numbers.
>>>>
>>>> *: For unsigned, one could use a normal integer compare. However,
>>>> signed integer and 10s complement would not cross over at the same
>>>> point (well, unless one is happy with it being asymmetric; then one
>>>> can reuse signed integer compare).
>>>>
>>>>
>>>> One would lose a few digits with Packed BCD vs DPD, but probably not a
>>>> huge loss.
>>>
>>> AFAIK, all DPD-encoded decimal fp units starts operations by unpacking
>>> the 10-bit chunks into 3 BCD digits.
>>>
>>> That is at least the most obvious way to implement it, particularly
>>> because the DPD encoding was chosen to allow very easy packing/unpacking
>>> ops, cheap enough that you can easily have 10 of them in parallel.
>> This part is probably true at least. One could maybe have a converter op
>> that converts between 15 packed BCD digits, and DPD (50 bits).
>>
>> If one excludes the combination field, this could almost match up with
>> the Decimal64 format. Could almost treat the last-digit (via the
>> combination field) as a special case.
>>
>> Would almost make more sense though if the exponent and combination
>> field were in a different order, say:
>> Sgn.Exp8.Comb5.Fra50
>> In which case the converter op could be treated as:
>> 15 digits in 50 bits.
>> 16 digits in 55 bits.
>> Or, maybe also:
>> Sgn.Exp9.BCD1.Fra50
>>
>> Which while losing 1 bit on the exponent range, is "less convoluted".
>>
>>
>> This could maybe make sense if one were implementing it mostly in
>> software using hardware Packed BCD and converter ops, which is probably
>> a cheaper option if compared with actually trying to do it directly in
>> hardware.
>>
>>
>> One could maybe skip the DPD part, and do a format like:
>> Sgn.Exp15.Fra112 (28 digit)
>> Or:
>> Sgn.Exp11.Fra116 (29 digit)
>> With the fraction as Packed BCD.
>>
>>
>> In this case, all one really needs to deal with effectively it in
>> software is some BCD helper ops.
>>
>> I guess one could debate whether it would be better to go the route of
>> special ADD/SUB ops for BCD, or use the ALU as normal and then use a
>> "fixup ops".
>>
>> Eg:
>> ADD R4, R5, R6 | CLRT //Clear SR.T
>> DAA R6 //Fixup BCD, treat SR.T as carry.
>> Or:
>> SUB R4, R5, R6 | CLRT //Clear SR.T
>> DAS R6 //Fixup BCD, treat SR.T as borrow.
>>
>> This dedicated DAA/DAS route likely using less LUTs.
>>
>>
>> Dealing with 128-bits of BCD:
>> ADDX R4, R6, R8
>> CLRT
>> DAA R8
>> DAA R9
>>
>> ...
>>
>>
>> I could add these to BJX2, in theory, just not sure of a strong use-case
>> at the moment.
>>
>> Less sure how multiply and divide would work, likely a pretty slow
>> option involving long multiply/divide, and another post fixup op likely
>> for dealing with multiplying a BCD number by a single BCD digit.
>>
>> Could probably work, would be pretty slow, and would likely need "early
>> out" cases to deal with the rest of the digits being zeroes.
>>>>
>>>> Also, BCD seems to map up better with how decimal is handled in both
>>>> COBOL and SQL (eg: they will define the number of digits before and
>>>> after the decimal point), which is presumably where most of its
>>>> use-case would reside.
>>>
>>> Right.
>>>
>> Yeah, this is a thing:
>> Binary FP: Pretty much everywhere, lots of use-cases.
>> BCD: COBOL and SQL and similar.
>> Decimal FP: ?... ('finances' or something, *)
>>
>>
>> *: Except, here, you can't really auto-normalize (this would break the
>> rounding rules), so would only likely matter in "overflow" cases, but
>> these would likely break the rounding rules anyways (in the rare event
>> that a balance gets so big that it can no longer be contained).
>>
>> One can argue, maybe an incorrectly rounded value is better than one
>> which overflows, but this is mostly sweeping the issue under the rug.
>
>> What about having a hybrid, i.e. HW for the easy cases and fall back
>> to sw emulation for larger/higher precision inputs?
>
> A hybrid approach is good. I was going to trap to software for things like
> divide and square root. While having ADD, SUB, MUL, CMP in hardware.
> Whether it is in hardware or software should be invisible to the program.
>
> Performance is less critical than having decimal numbers to deal with. But
> there can be quite a performance boost by having some of it processed in
> hardware.
>
> 15 digits available with double precision may not be quite enough once one
> uses several digits to maintain rounding. Using quad or even triple precision
> is a bit ridiculous though. I happen to like the extended double, 80-bit,
> format but there is no standard one for decimal floats AFAIK? An 82-bit format
> like the Itanium is tempting, but a multiple of 8 or 16 bits is easier to work with.
> I could probably live with a 72-bit format, giving 18 digits plus 11 bits exponent,
> and one sign bit. But I think it is better to work with an even multiple of bytes.
>
>


Click here to read the complete article
Re: Extended double precision decimal floating point

<t40q7n$48b$1@newsreader4.netcologne.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24838&group=comp.arch#24838

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd4-f179-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch
Subject: Re: Extended double precision decimal floating point
Date: Sat, 23 Apr 2022 12:08:23 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <t40q7n$48b$1@newsreader4.netcologne.de>
References: <d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com>
<t3tmrd$m06$1@gioia.aioe.org> <t3trjp$t04$1@dont-email.me>
<t3u085$1165$1@gioia.aioe.org> <t3urj9$4ou$1@dont-email.me>
<aeef3da0-5f71-4cba-942e-0b99479e58f1n@googlegroups.com>
<t40o6j$oub$1@dont-email.me>
Injection-Date: Sat, 23 Apr 2022 12:08:23 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd4-f179-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd4:f179:0:7285:c2ff:fe6c:992d";
logging-data="4363"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Sat, 23 Apr 2022 12:08 UTC

Ivan Godard <ivan@millcomputing.com> schrieb:

> A (the?) significant use for decimal is Numeric in DBMSs and COBOL.
> That's 33 digits IIRC. The COBOL committee spent quite a lot of time
> with the IFFF-754 committee (I was a IEEE member) before the last IEEE
> standard, to make sure that the IEEE decimal would be big enough for
> real uses in commerce: numbers like the world GDP expressed in
> Zimbabwean Dollars to the mil.

POWER has 16 digits with long DFP, 34 with DFP Extended (128 bits).

World GDP was around 80,934,771,028,340 (for 2017?) so 14 digits.
In 2009, before one of the re-valuations, a Zimbabwean Dollar
was 300,000,000,000,000 to the US dollar (according to Wikipedia),
15 digits. So... it would fit, but just about.

Re: Extended double precision decimal floating point

<8f909c18-cfe1-4748-8478-543bac50fdbbn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24839&group=comp.arch#24839

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ac8:578c:0:b0:2f1:ed92:39a9 with SMTP id v12-20020ac8578c000000b002f1ed9239a9mr7188441qta.300.1650735391650;
Sat, 23 Apr 2022 10:36:31 -0700 (PDT)
X-Received: by 2002:a54:4f83:0:b0:324:f58f:4b95 with SMTP id
g3-20020a544f83000000b00324f58f4b95mr2938354oiy.4.1650735391457; Sat, 23 Apr
2022 10:36:31 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Sat, 23 Apr 2022 10:36:31 -0700 (PDT)
In-Reply-To: <d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a0d:6fc2:55b0:ca00:4866:39ee:13d9:1f18;
posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 2a0d:6fc2:55b0:ca00:4866:39ee:13d9:1f18
References: <d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8f909c18-cfe1-4748-8478-543bac50fdbbn@googlegroups.com>
Subject: Re: Extended double precision decimal floating point
From: already5...@yahoo.com (Michael S)
Injection-Date: Sat, 23 Apr 2022 17:36:31 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 30
 by: Michael S - Sat, 23 Apr 2022 17:36 UTC

On Friday, April 22, 2022 at 2:59:33 AM UTC+3, robf...@gmail.com wrote:
> Thinking of using the following for decimal floating-point:
> |Sign 1| Exponent 9|Significand 70|
> It is an 80-bit format so called extended double-precision.
> Double precision is just barely adequate, extended double precision feels safer.
> Groups of ten bits are needed to represent numbers in densely-packed-decimal format. 70 bits gives 21 significant digits.
> The exponent is a power of ten represented as a binary number, so a nine-bit exponent has a good range (-255 to +256) considerably more than a binary exponent of the same size.
> I have also been considering the following format which has 20 significant digits and a larger exponent, but packs digits in two different formats.
> |Sign 1| Exponent 12|Lead digits 7|Significand 60|
>
> The extended double format appeals to me because the hardware is quite a bit smaller than quad precision. I suppose I could use the quad precision format but only implement extended double precision in hardware. The least significant digits would be out to lunch and the exponent would not come close to full use.

The sanest option is to implement nothing in HW.
Quad-precision DFP is easy to implement in software in way that is only small integer factor slower than IBM's hardware.
And double-precision DFP, while easy to be made quite a lot faster in HW, than in SW, does not look useful.

As to your idea of non-standard intermediate precision, I propose t forget about it as fast as you can.

Re: Extended double precision decimal floating point

<t41g1s$14hv$1@gal.iecc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24840&group=comp.arch#24840

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!not-for-mail
From: joh...@taugh.com (John Levine)
Newsgroups: comp.arch
Subject: Re: Extended double precision decimal floating point
Date: Sat, 23 Apr 2022 18:20:44 -0000 (UTC)
Organization: Taughannock Networks
Message-ID: <t41g1s$14hv$1@gal.iecc.com>
References: <d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com> <8f909c18-cfe1-4748-8478-543bac50fdbbn@googlegroups.com>
Injection-Date: Sat, 23 Apr 2022 18:20:44 -0000 (UTC)
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970";
logging-data="37439"; mail-complaints-to="abuse@iecc.com"
In-Reply-To: <d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com> <8f909c18-cfe1-4748-8478-543bac50fdbbn@googlegroups.com>
Cleverness: some
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: johnl@iecc.com (John Levine)
 by: John Levine - Sat, 23 Apr 2022 18:20 UTC

According to Michael S <already5chosen@yahoo.com>:
>The sanest option is to implement nothing in HW.
>Quad-precision DFP is easy to implement in software in way that is only small integer factor slower than IBM's hardware.
>And double-precision DFP, while easy to be made quite a lot faster in HW, than in SW, does not look useful.

What he said. The only use for DFP is to get consistent decimal precision and rounding.

In my youth I had to implement bond yield and price functions, e.g., if you pay $97 for
a bond with a face value of $100, that pays 3% paid semiannually, and that matures
four years, six months, and 15 days from now, what is the effective yield to maturity?
(Answer: 3.73%)

The correct answer is not the one that is mathematically most precise,
it's the one that matches the answer that everyone else gets using a
360 day synthetic calendar and cent rounding. I did it on a 286 with
binary IEEE FP and it would have been a lot easier with decimal FP.
These calculations are important (imagine the amounts all multiplied
by a million) but there aren't all that many of them.

--
Regards,
John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies",
Please consider the environment before reading this e-mail. https://jl.ly

Re: Extended double precision decimal floating point

<d09babe7-ef1a-43f9-a619-f2adddf766e1n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24841&group=comp.arch#24841

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a37:9442:0:b0:699:fd32:bc7d with SMTP id w63-20020a379442000000b00699fd32bc7dmr6230093qkd.615.1650742039769;
Sat, 23 Apr 2022 12:27:19 -0700 (PDT)
X-Received: by 2002:aca:a88d:0:b0:323:57d:d03c with SMTP id
r135-20020acaa88d000000b00323057dd03cmr6852591oie.217.1650742039536; Sat, 23
Apr 2022 12:27:19 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Sat, 23 Apr 2022 12:27:19 -0700 (PDT)
In-Reply-To: <t41g1s$14hv$1@gal.iecc.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a0d:6fc2:55b0:ca00:4866:39ee:13d9:1f18;
posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 2a0d:6fc2:55b0:ca00:4866:39ee:13d9:1f18
References: <d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com>
<8f909c18-cfe1-4748-8478-543bac50fdbbn@googlegroups.com> <t41g1s$14hv$1@gal.iecc.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d09babe7-ef1a-43f9-a619-f2adddf766e1n@googlegroups.com>
Subject: Re: Extended double precision decimal floating point
From: already5...@yahoo.com (Michael S)
Injection-Date: Sat, 23 Apr 2022 19:27:19 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 43
 by: Michael S - Sat, 23 Apr 2022 19:27 UTC

On Saturday, April 23, 2022 at 9:20:47 PM UTC+3, John Levine wrote:
> According to Michael S <already...@yahoo.com>:
> >The sanest option is to implement nothing in HW.
> >Quad-precision DFP is easy to implement in software in way that is only small integer factor slower than IBM's hardware.
> >And double-precision DFP, while easy to be made quite a lot faster in HW, than in SW, does not look useful.
> What he said. The only use for DFP is to get consistent decimal precision and rounding.
>
> In my youth I had to implement bond yield and price functions, e.g., if you pay $97 for
> a bond with a face value of $100, that pays 3% paid semiannually, and that matures
> four years, six months, and 15 days from now, what is the effective yield to maturity?
> (Answer: 3.73%)
>

Let's see if I understand a formula used by "everybody else". In Matlab/Octave
x=10000
for k=1:9 x = round(x*1.015) end
yield = (x / 9700)^(1/4.5)
Or should 15 days play a role as well?

> The correct answer is not the one that is mathematically most precise,
> it's the one that matches the answer that everyone else gets using a
> 360 day synthetic calendar and cent rounding. I did it on a 286 with
> binary IEEE FP and it would have been a lot easier with decimal FP.

If I understood the formula correctly then I don't see how double-precision DFP
will help to get the same result.
Now, with quad-precision DFP you will probably get the same result, but only
because there were only 9 iterations and 9*3digts = 27 digits < 34 digits.
With 12 or more iterations you wouldn't be that lucky.

> These calculations are important (imagine the amounts all multiplied
> by a million) but there aren't all that many of them.
>

And anyway DFP is only a little more likely to match the rules than BFP.
The sane way is, of course, to change the rules toward radical simplification.
Nowadays, I'd say, just allow to do all intermediate calculations in octal-precision
BFP, with rounding to the nearest. Then round the outcome to whatever old rules
prescribe.

> --
> Regards,
> John Levine, jo...@taugh.com, Primary Perpetrator of "The Internet for Dummies",
> Please consider the environment before reading this e-mail. https://jl.ly

Re: Extended double precision decimal floating point

<t41k9p$f0a$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24842&group=comp.arch#24842

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!aioe.org!10O9MudpjwoXIahOJRbDvA.user.46.165.242.91.POSTED!not-for-mail
From: terje.ma...@tmsw.no (Terje Mathisen)
Newsgroups: comp.arch
Subject: Re: Extended double precision decimal floating point
Date: Sat, 23 Apr 2022 21:33:13 +0200
Organization: Aioe.org NNTP Server
Message-ID: <t41k9p$f0a$1@gioia.aioe.org>
References: <d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com>
<8f909c18-cfe1-4748-8478-543bac50fdbbn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="15370"; posting-host="10O9MudpjwoXIahOJRbDvA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101
Firefox/68.0 SeaMonkey/2.53.11.1
X-Notice: Filtered by postfilter v. 0.9.2
 by: Terje Mathisen - Sat, 23 Apr 2022 19:33 UTC

Michael S wrote:
> On Friday, April 22, 2022 at 2:59:33 AM UTC+3, robf...@gmail.com
> wrote:
>> Thinking of using the following for decimal floating-point: |Sign
>> 1| Exponent 9|Significand 70| It is an 80-bit format so called
>> extended double-precision. Double precision is just barely
>> adequate, extended double precision feels safer. Groups of ten bits
>> are needed to represent numbers in densely-packed-decimal format.
>> 70 bits gives 21 significant digits. The exponent is a power of ten
>> represented as a binary number, so a nine-bit exponent has a good
>> range (-255 to +256) considerably more than a binary exponent of
>> the same size. I have also been considering the following format
>> which has 20 significant digits and a larger exponent, but packs
>> digits in two different formats. |Sign 1| Exponent 12|Lead digits
>> 7|Significand 60|
>>
>> The extended double format appeals to me because the hardware is
>> quite a bit smaller than quad precision. I suppose I could use the
>> quad precision format but only implement extended double precision
>> in hardware. The least significant digits would be out to lunch and
>> the exponent would not come close to full use.
>
> The sanest option is to implement nothing in HW. Quad-precision DFP
> is easy to implement in software in way that is only small integer
> factor slower than IBM's hardware. And double-precision DFP, while
> easy to be made quite a lot faster in HW, than in SW, does not look
> useful.

This would be my own first choice as well, but I've always been much
more of a SW than HW guy. :-)
>
> As to your idea of non-standard intermediate precision, I propose t
> forget about it as fast as you can.
>
Yeah, probably best unless this is for something highly specific, not to
be deployed anywhere else.

Terje

--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"

Re: Extended double precision decimal floating point

<t41kdg$sgn$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24843&group=comp.arch#24843

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: cr88...@gmail.com (BGB)
Newsgroups: comp.arch
Subject: Re: Extended double precision decimal floating point
Date: Sat, 23 Apr 2022 14:35:09 -0500
Organization: A noiseless patient Spider
Lines: 105
Message-ID: <t41kdg$sgn$1@dont-email.me>
References: <d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com>
<t3tmrd$m06$1@gioia.aioe.org> <t3trjp$t04$1@dont-email.me>
<t3u085$1165$1@gioia.aioe.org> <t3urj9$4ou$1@dont-email.me>
<aeef3da0-5f71-4cba-942e-0b99479e58f1n@googlegroups.com>
<t40o6j$oub$1@dont-email.me> <t40q7n$48b$1@newsreader4.netcologne.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 23 Apr 2022 19:35:12 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="eb9de859d54b7067bc622565fc916b7d";
logging-data="29207"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX195euco/AFVN7LYERcpsrM3"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.8.0
Cancel-Lock: sha1:4E1X9wzNCkcafH91HCHTKBYB+K0=
In-Reply-To: <t40q7n$48b$1@newsreader4.netcologne.de>
Content-Language: en-US
 by: BGB - Sat, 23 Apr 2022 19:35 UTC

On 4/23/2022 7:08 AM, Thomas Koenig wrote:
> Ivan Godard <ivan@millcomputing.com> schrieb:
>
>> A (the?) significant use for decimal is Numeric in DBMSs and COBOL.
>> That's 33 digits IIRC. The COBOL committee spent quite a lot of time
>> with the IFFF-754 committee (I was a IEEE member) before the last IEEE
>> standard, to make sure that the IEEE decimal would be big enough for
>> real uses in commerce: numbers like the world GDP expressed in
>> Zimbabwean Dollars to the mil.
>
> POWER has 16 digits with long DFP, 34 with DFP Extended (128 bits).
>
> World GDP was around 80,934,771,028,340 (for 2017?) so 14 digits.
> In 2009, before one of the re-valuations, a Zimbabwean Dollar
> was 300,000,000,000,000 to the US dollar (according to Wikipedia),
> 15 digits. So... it would fit, but just about.

I suspect there are reasons why the Decimal crowd was mostly going for
128-bit formats...

As for whether or not it makes much sense for a hardware FPU is more
debatable.

Even for something like DBMS or COBOL, probably only a small part of the
total time is likely to be spent on decimal arithmetic, and
traditionally DBMS's are mostly IO bound anyways, ...

There is another possibility:
3x 32-bit, each encoding 000000000..999999999 (as integer numbers);
Last 32-bit number holds sign and exponent.

IIRC, the MS decimal format worked something like this.
I suspect this was mostly because they were optimizing for a software
implementation.

I had also at one point considered possibly using something like this on
BJX2, before mostly deciding to stick with Binary128 floating-point
(software-only for now).

FWIW: Doing Binary128 in software is one of the major use-cases for the
128-bit 'ALUX' extension.

As an experiment, I have gone and added/defined a few BCD instructions
for BJX2.

Had originally tried adding DAA/DAS style ops, but then realized that
they would have a fatal flaw, namely an inability to add things like
9999+9999 and get the correct result, because the way they were
implemented on x86 would only work if adding 2 digits at a time
(otherwise, one would also need to generate and stash an extra 16
carry-bits somewhere).

Instead needed to switch over to dedicated BCDADC/BCDSBB instructions,
which effectively handle both parts at the same time (via their own
dedicated adder).

Internally, the BCDSBB is basically just BCDADC but with 9s complement
and the carry-bit inverted.

Was only adding the ADC/SBB variants, because I don't think these would
be used enough to justify ADD/SUB forms in practice, nor on spending 3R
encodings on this.

These instructions will also be "Lane 1 only".

So, for example, adding two 32-digit BCD numbers would look like:
MOV R4, R2
MOV R5, R3
CLRT
BCDADC R5, R2
BCDADC R6, R3

Hid initially tried direct chaining the adders here, but this blew out
timing pretty hard. I am now using carry-select, still fiddling with
timing (I don't yet have this able to pass timing).

Adding two 64-bit numbers is already high-latency, adding extra LUTs in
front of it doesn't really help on this front.

Seems to add a cost of around 1 kLUT, more than I would have hoped, ...

Because it updates SR.T, can't currently put it on the "MUL" path (this
path would give it another clock-cycle to work with; 1c throughput 3c
latency). I had put it on the ALU-1 path, which forces it to have the
same latency as 64-bit ADD/SUB (1c throughput, 2c latency).

Could be done, would require adding logic to allow the MUL path to
update SR.T (and/or add another dedicated status flag for this purpose,
such as an 'A' flag, which would also probably be better from a timing
POV, given how tied up SR.T is with everything else going on in the core).

As for whether this is viable, dunno...

Could maybe make more sense if it were more likely to be used more than
"hardly ever".

Re: Extended double precision decimal floating point

<t41la7$3hp$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24844&group=comp.arch#24844

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: iva...@millcomputing.com (Ivan Godard)
Newsgroups: comp.arch
Subject: Re: Extended double precision decimal floating point
Date: Sat, 23 Apr 2022 12:50:31 -0700
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <t41la7$3hp$1@dont-email.me>
References: <d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com>
<t3tmrd$m06$1@gioia.aioe.org> <t3trjp$t04$1@dont-email.me>
<t3u085$1165$1@gioia.aioe.org> <t3urj9$4ou$1@dont-email.me>
<aeef3da0-5f71-4cba-942e-0b99479e58f1n@googlegroups.com>
<t40o6j$oub$1@dont-email.me> <t40q7n$48b$1@newsreader4.netcologne.de>
<t41kdg$sgn$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 23 Apr 2022 19:50:31 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="4ebe3cb4dc571f85fe22169309ba735c";
logging-data="3641"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19DwnGhRdW/cLyu2pBPmEFF"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.8.0
Cancel-Lock: sha1:IMsZiCa6/pkEL+fgOtujzeeAeDo=
In-Reply-To: <t41kdg$sgn$1@dont-email.me>
Content-Language: en-US
 by: Ivan Godard - Sat, 23 Apr 2022 19:50 UTC

On 4/23/2022 12:35 PM, BGB wrote:
> On 4/23/2022 7:08 AM, Thomas Koenig wrote:
>> Ivan Godard <ivan@millcomputing.com> schrieb:
>>
>>> A (the?) significant use for decimal is Numeric in DBMSs and COBOL.
>>> That's 33 digits IIRC. The COBOL committee spent quite a lot of time
>>> with the IFFF-754 committee (I was a IEEE member) before the last IEEE
>>> standard, to make sure that the IEEE decimal would be big enough for
>>> real uses in commerce: numbers like the world GDP expressed in
>>> Zimbabwean Dollars to the mil.
>>
>> POWER has 16 digits with long DFP, 34 with DFP Extended (128 bits).
>>
>> World GDP was around 80,934,771,028,340 (for 2017?) so 14 digits.
>> In 2009, before one of the re-valuations, a Zimbabwean Dollar
>> was 300,000,000,000,000 to the US dollar (according to Wikipedia),
>> 15 digits.  So... it would fit, but just about.
>
>
> I suspect there are reasons why the Decimal crowd was mostly going for
> 128-bit formats...
>
> As for whether or not it makes much sense for a hardware FPU is more
> debatable.
>
> Even for something like DBMS or COBOL, probably only a small part of the
> total time is likely to be spent on decimal arithmetic, and
> traditionally DBMS's are mostly IO bound anyways, ...

Commercial work is throughput oriented. When we were defining the IEEE
decimal revision we got some numbers from Oracle: IIRC, 40% of CPU
cycles were in decimal emulation routines. Terje - does that match your
memory?

Re: Extended double precision decimal floating point

<5d02036c-33d1-4881-b681-be99a64fcfden@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24845&group=comp.arch#24845

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:620a:2886:b0:699:bab7:ae78 with SMTP id j6-20020a05620a288600b00699bab7ae78mr6195414qkp.618.1650745543171;
Sat, 23 Apr 2022 13:25:43 -0700 (PDT)
X-Received: by 2002:a05:6870:61d4:b0:df:b74:8de5 with SMTP id
b20-20020a05687061d400b000df0b748de5mr4412800oah.37.1650745542976; Sat, 23
Apr 2022 13:25:42 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Sat, 23 Apr 2022 13:25:42 -0700 (PDT)
In-Reply-To: <t41la7$3hp$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:5117:fee5:9e17:6cb7;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:5117:fee5:9e17:6cb7
References: <d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com>
<t3tmrd$m06$1@gioia.aioe.org> <t3trjp$t04$1@dont-email.me>
<t3u085$1165$1@gioia.aioe.org> <t3urj9$4ou$1@dont-email.me>
<aeef3da0-5f71-4cba-942e-0b99479e58f1n@googlegroups.com> <t40o6j$oub$1@dont-email.me>
<t40q7n$48b$1@newsreader4.netcologne.de> <t41kdg$sgn$1@dont-email.me> <t41la7$3hp$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5d02036c-33d1-4881-b681-be99a64fcfden@googlegroups.com>
Subject: Re: Extended double precision decimal floating point
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Sat, 23 Apr 2022 20:25:43 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 37
 by: MitchAlsup - Sat, 23 Apr 2022 20:25 UTC

On Saturday, April 23, 2022 at 2:50:34 PM UTC-5, Ivan Godard wrote:
> On 4/23/2022 12:35 PM, BGB wrote:
> > On 4/23/2022 7:08 AM, Thomas Koenig wrote:
> >> Ivan Godard <iv...@millcomputing.com> schrieb:
> >>
> >>> A (the?) significant use for decimal is Numeric in DBMSs and COBOL.
> >>> That's 33 digits IIRC. The COBOL committee spent quite a lot of time
> >>> with the IFFF-754 committee (I was a IEEE member) before the last IEEE
> >>> standard, to make sure that the IEEE decimal would be big enough for
> >>> real uses in commerce: numbers like the world GDP expressed in
> >>> Zimbabwean Dollars to the mil.
> >>
> >> POWER has 16 digits with long DFP, 34 with DFP Extended (128 bits).
> >>
> >> World GDP was around 80,934,771,028,340 (for 2017?) so 14 digits.
> >> In 2009, before one of the re-valuations, a Zimbabwean Dollar
> >> was 300,000,000,000,000 to the US dollar (according to Wikipedia),
> >> 15 digits. So... it would fit, but just about.
> >
> >
> > I suspect there are reasons why the Decimal crowd was mostly going for
> > 128-bit formats...
> >
> > As for whether or not it makes much sense for a hardware FPU is more
> > debatable.
> >
> > Even for something like DBMS or COBOL, probably only a small part of the
> > total time is likely to be spent on decimal arithmetic, and
> > traditionally DBMS's are mostly IO bound anyways, ...
<
> Commercial work is throughput oriented. When we were defining the IEEE
> decimal revision we got some numbers from Oracle: IIRC, 40% of CPU
> cycles were in decimal emulation routines. Terje - does that match your
> memory?
<
This 40% would vary massively if the base CPU had decimal instructions
(like IBM 360) versus if it had nothing (MIPS) versus if it had only a trifling
(x86).

Re: Extended double precision decimal floating point

<t41ofh$rqn$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24846&group=comp.arch#24846

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: cr88...@gmail.com (BGB)
Newsgroups: comp.arch
Subject: Re: Extended double precision decimal floating point
Date: Sat, 23 Apr 2022 15:44:30 -0500
Organization: A noiseless patient Spider
Lines: 110
Message-ID: <t41ofh$rqn$1@dont-email.me>
References: <d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com>
<t3tmrd$m06$1@gioia.aioe.org> <t3trjp$t04$1@dont-email.me>
<t3u085$1165$1@gioia.aioe.org> <t3urj9$4ou$1@dont-email.me>
<aeef3da0-5f71-4cba-942e-0b99479e58f1n@googlegroups.com>
<t40o6j$oub$1@dont-email.me> <t40q7n$48b$1@newsreader4.netcologne.de>
<t41kdg$sgn$1@dont-email.me> <t41la7$3hp$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 23 Apr 2022 20:44:33 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="eb9de859d54b7067bc622565fc916b7d";
logging-data="28503"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+jDSB03tjdVaj4RnQbFPX+"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.8.0
Cancel-Lock: sha1:Kqu/3E+mQ+Xt76IR+qGJ6/JAfd0=
In-Reply-To: <t41la7$3hp$1@dont-email.me>
Content-Language: en-US
 by: BGB - Sat, 23 Apr 2022 20:44 UTC

On 4/23/2022 2:50 PM, Ivan Godard wrote:
> On 4/23/2022 12:35 PM, BGB wrote:
>> On 4/23/2022 7:08 AM, Thomas Koenig wrote:
>>> Ivan Godard <ivan@millcomputing.com> schrieb:
>>>
>>>> A (the?) significant use for decimal is Numeric in DBMSs and COBOL.
>>>> That's 33 digits IIRC. The COBOL committee spent quite a lot of time
>>>> with the IFFF-754 committee (I was a IEEE member) before the last IEEE
>>>> standard, to make sure that the IEEE decimal would be big enough for
>>>> real uses in commerce: numbers like the world GDP expressed in
>>>> Zimbabwean Dollars to the mil.
>>>
>>> POWER has 16 digits with long DFP, 34 with DFP Extended (128 bits).
>>>
>>> World GDP was around 80,934,771,028,340 (for 2017?) so 14 digits.
>>> In 2009, before one of the re-valuations, a Zimbabwean Dollar
>>> was 300,000,000,000,000 to the US dollar (according to Wikipedia),
>>> 15 digits.  So... it would fit, but just about.
>>
>>
>> I suspect there are reasons why the Decimal crowd was mostly going for
>> 128-bit formats...
>>
>> As for whether or not it makes much sense for a hardware FPU is more
>> debatable.
>>
>> Even for something like DBMS or COBOL, probably only a small part of
>> the total time is likely to be spent on decimal arithmetic, and
>> traditionally DBMS's are mostly IO bound anyways, ...
>
> Commercial work is throughput oriented. When we were defining the IEEE
> decimal revision we got some numbers from Oracle: IIRC, 40% of CPU
> cycles were in decimal emulation routines. Terje - does that match your
> memory?

I guess it could make sense then, but then one has to answer whether DFP
is the answer, or whether plain BCD would be good enough.

Though, this would imply though that these sorts of use-cases are no
longer primarily IO bound?...

BCD is at least cheaper to support in hardware than full-hardware DFP,
and would be "a lot closer" than also running code to deal with
individual decimal digits.

Admittedly though, I am still having some timing issues with my attempt
at adding BCD ops.

Basic logic is along the lines of, per-digit (A+B):
If doing SUB, do 9's complement on B (4b->4b remapping);
Do D=A+B+Ci (5b intermediate, should map to a CARRY4);
Run it though a 5b 'case' block, to map to 5b Digit+Carry.
The case block uses fewer LUTs than an "if(D>9)D=D+6;" or similar.

This is then ganged up in groups of 4 digits (daisy-chained), with each
group having versions for a carry-in of 0 and 1, and a carry-out bit.

For result, gather up carry bits, then select groups for the output
value (as in a normal integer adder).

However, latency seems to be a bit worse than in a normal integer adder.

To be more useful for implementing DFP, would likely also need
instructions doing the packing/unpacking for DPD<->BCD.

This packing/unpacking part should (probably) be a little easier.

....

I guess a related mystery would be if it could make sense to support BCD
types as a C language extension.

Say:
__bcd64 //64-bit, 16 digits
__bcd128 //128-bit, 32 digits

Printing them could almost be done by reusing the normal hexadecimal
printing, except that signed values would require special support to
print as, say, "-1" rather than "9999999999999999" or similar...

Simple case is to only natively define them here as unsigned types.

Less obvious how the casting should work.

Functionally, it would make more sense to treat them as part of the SIMD
tower rather than the main number tower.
This would mean:
__bcd128 v0;
__int128 v1;
v1=(__int128)((__m128)v0); //raw bit copy
v1=(__int128)v0; //likely a runtime call or similar.

....

It is likely that whether BCD support exists in C would be independent
of whether BCD instructions exist in the ISA (as with the other types,
if there is not an HW instruction for it, it will handle it by calling a
runtime function).

Doing "cost effective" conversion would probably be feeding digits, 2 at
a time, through lookup tables or similar.

Re: Extended double precision decimal floating point

<74c6cac1-d852-4419-9a0d-6583b57f5bc3n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24847&group=comp.arch#24847

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:620a:2902:b0:69e:b906:7078 with SMTP id m2-20020a05620a290200b0069eb9067078mr6478294qkp.717.1650747211957;
Sat, 23 Apr 2022 13:53:31 -0700 (PDT)
X-Received: by 2002:a9d:64da:0:b0:605:54e5:f67c with SMTP id
n26-20020a9d64da000000b0060554e5f67cmr4002674otl.268.1650747211740; Sat, 23
Apr 2022 13:53:31 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Sat, 23 Apr 2022 13:53:31 -0700 (PDT)
In-Reply-To: <t41la7$3hp$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a0d:6fc2:55b0:ca00:4866:39ee:13d9:1f18;
posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 2a0d:6fc2:55b0:ca00:4866:39ee:13d9:1f18
References: <d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com>
<t3tmrd$m06$1@gioia.aioe.org> <t3trjp$t04$1@dont-email.me>
<t3u085$1165$1@gioia.aioe.org> <t3urj9$4ou$1@dont-email.me>
<aeef3da0-5f71-4cba-942e-0b99479e58f1n@googlegroups.com> <t40o6j$oub$1@dont-email.me>
<t40q7n$48b$1@newsreader4.netcologne.de> <t41kdg$sgn$1@dont-email.me> <t41la7$3hp$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <74c6cac1-d852-4419-9a0d-6583b57f5bc3n@googlegroups.com>
Subject: Re: Extended double precision decimal floating point
From: already5...@yahoo.com (Michael S)
Injection-Date: Sat, 23 Apr 2022 20:53:31 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 34
 by: Michael S - Sat, 23 Apr 2022 20:53 UTC

On Saturday, April 23, 2022 at 10:50:34 PM UTC+3, Ivan Godard wrote:
> On 4/23/2022 12:35 PM, BGB wrote:
> > On 4/23/2022 7:08 AM, Thomas Koenig wrote:
> >> Ivan Godard <iv...@millcomputing.com> schrieb:
> >>
> >>> A (the?) significant use for decimal is Numeric in DBMSs and COBOL.
> >>> That's 33 digits IIRC. The COBOL committee spent quite a lot of time
> >>> with the IFFF-754 committee (I was a IEEE member) before the last IEEE
> >>> standard, to make sure that the IEEE decimal would be big enough for
> >>> real uses in commerce: numbers like the world GDP expressed in
> >>> Zimbabwean Dollars to the mil.
> >>
> >> POWER has 16 digits with long DFP, 34 with DFP Extended (128 bits).
> >>
> >> World GDP was around 80,934,771,028,340 (for 2017?) so 14 digits.
> >> In 2009, before one of the re-valuations, a Zimbabwean Dollar
> >> was 300,000,000,000,000 to the US dollar (according to Wikipedia),
> >> 15 digits. So... it would fit, but just about.
> >
> >
> > I suspect there are reasons why the Decimal crowd was mostly going for
> > 128-bit formats...
> >
> > As for whether or not it makes much sense for a hardware FPU is more
> > debatable.
> >
> > Even for something like DBMS or COBOL, probably only a small part of the
> > total time is likely to be spent on decimal arithmetic, and
> > traditionally DBMS's are mostly IO bound anyways, ...
> Commercial work is throughput oriented. When we were defining the IEEE
> decimal revision we got some numbers from Oracle: IIRC, 40% of CPU
> cycles were in decimal emulation routines. Terje - does that match your
> memory?

I wouldn't believe Oracle when they say that the sun rises in the east.

Re: Extended double precision decimal floating point

<t41p9p$24fj$1@gal.iecc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24848&group=comp.arch#24848

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!not-for-mail
From: joh...@taugh.com (John Levine)
Newsgroups: comp.arch
Subject: Re: Extended double precision decimal floating point
Date: Sat, 23 Apr 2022 20:58:33 -0000 (UTC)
Organization: Taughannock Networks
Message-ID: <t41p9p$24fj$1@gal.iecc.com>
References: <d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com> <8f909c18-cfe1-4748-8478-543bac50fdbbn@googlegroups.com> <t41g1s$14hv$1@gal.iecc.com> <d09babe7-ef1a-43f9-a619-f2adddf766e1n@googlegroups.com>
Injection-Date: Sat, 23 Apr 2022 20:58:33 -0000 (UTC)
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970";
logging-data="70131"; mail-complaints-to="abuse@iecc.com"
In-Reply-To: <d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com> <8f909c18-cfe1-4748-8478-543bac50fdbbn@googlegroups.com> <t41g1s$14hv$1@gal.iecc.com> <d09babe7-ef1a-43f9-a619-f2adddf766e1n@googlegroups.com>
Cleverness: some
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: johnl@iecc.com (John Levine)
 by: John Levine - Sat, 23 Apr 2022 20:58 UTC

According to Michael S <already5chosen@yahoo.com>:
>> In my youth I had to implement bond yield and price functions, e.g., if you pay $97 for
>> a bond with a face value of $100, that pays 3% paid semiannually, and that matures
>> four years, six months, and 15 days from now, what is the effective yield to maturity?
>>
>
>Let's see if I understand a formula used by "everybody else". In Matlab/Octave
>x=10000
>for k=1:9 x = round(x*1.015) end
>yield = (x / 9700)^(1/4.5)
>Or should 15 days play a role as well?

You bought the bond at a discount, so the $3 difference from par is
amortized over the time from when you bought it to when it's redeemed,
as part of the yield. There's also the detail that bond interest is
paid in arrears, so you are getting a payment in half a month, but
11/12 of that interest belongs to the person you bought the bond from
and was included in the price you paid, so only 1/12 of that first
payment counts toward the yield.

The actual formula is quite complex and I don't know it off the top of
my head.

>And anyway DFP is only a little more likely to match the rules than BFP.

It's a lot more likely when the formula specifies penny rounding.

>The sane way is, of course, to change the rules toward radical simplification.

Indeed, but we're several centuries too late.

--
Regards,
John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies",
Please consider the environment before reading this e-mail. https://jl.ly

Re: Extended double precision decimal floating point

<t41pc9$2v7$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24849&group=comp.arch#24849

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: cr88...@gmail.com (BGB)
Newsgroups: comp.arch
Subject: Re: Extended double precision decimal floating point
Date: Sat, 23 Apr 2022 15:59:50 -0500
Organization: A noiseless patient Spider
Lines: 63
Message-ID: <t41pc9$2v7$1@dont-email.me>
References: <d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com>
<t3tmrd$m06$1@gioia.aioe.org> <t3trjp$t04$1@dont-email.me>
<t3u085$1165$1@gioia.aioe.org> <t3urj9$4ou$1@dont-email.me>
<aeef3da0-5f71-4cba-942e-0b99479e58f1n@googlegroups.com>
<t40o6j$oub$1@dont-email.me> <t40q7n$48b$1@newsreader4.netcologne.de>
<t41kdg$sgn$1@dont-email.me> <t41la7$3hp$1@dont-email.me>
<5d02036c-33d1-4881-b681-be99a64fcfden@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 23 Apr 2022 20:59:53 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="eb9de859d54b7067bc622565fc916b7d";
logging-data="3047"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+To5EeXlvis0RqEWVsEUeA"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.8.0
Cancel-Lock: sha1:1DuMQKBBzdOYDTNa4nRHr3Zr7/w=
In-Reply-To: <5d02036c-33d1-4881-b681-be99a64fcfden@googlegroups.com>
Content-Language: en-US
 by: BGB - Sat, 23 Apr 2022 20:59 UTC

On 4/23/2022 3:25 PM, MitchAlsup wrote:
> On Saturday, April 23, 2022 at 2:50:34 PM UTC-5, Ivan Godard wrote:
>> On 4/23/2022 12:35 PM, BGB wrote:
>>> On 4/23/2022 7:08 AM, Thomas Koenig wrote:
>>>> Ivan Godard <iv...@millcomputing.com> schrieb:
>>>>
>>>>> A (the?) significant use for decimal is Numeric in DBMSs and COBOL.
>>>>> That's 33 digits IIRC. The COBOL committee spent quite a lot of time
>>>>> with the IFFF-754 committee (I was a IEEE member) before the last IEEE
>>>>> standard, to make sure that the IEEE decimal would be big enough for
>>>>> real uses in commerce: numbers like the world GDP expressed in
>>>>> Zimbabwean Dollars to the mil.
>>>>
>>>> POWER has 16 digits with long DFP, 34 with DFP Extended (128 bits).
>>>>
>>>> World GDP was around 80,934,771,028,340 (for 2017?) so 14 digits.
>>>> In 2009, before one of the re-valuations, a Zimbabwean Dollar
>>>> was 300,000,000,000,000 to the US dollar (according to Wikipedia),
>>>> 15 digits. So... it would fit, but just about.
>>>
>>>
>>> I suspect there are reasons why the Decimal crowd was mostly going for
>>> 128-bit formats...
>>>
>>> As for whether or not it makes much sense for a hardware FPU is more
>>> debatable.
>>>
>>> Even for something like DBMS or COBOL, probably only a small part of the
>>> total time is likely to be spent on decimal arithmetic, and
>>> traditionally DBMS's are mostly IO bound anyways, ...
> <
>> Commercial work is throughput oriented. When we were defining the IEEE
>> decimal revision we got some numbers from Oracle: IIRC, 40% of CPU
>> cycles were in decimal emulation routines. Terje - does that match your
>> memory?
> <
> This 40% would vary massively if the base CPU had decimal instructions
> (like IBM 360) versus if it had nothing (MIPS) versus if it had only a trifling
> (x86).

With a number like this, I would assume it probably means that they are
doing all of the decimal stuff by working on it one-digit-at-a-time in C
or something...

But, yeah, the x86 BCD instructions are, in a way, so limited as to be
borderline useless.

If one has instructions which can ADD/SUB BCD 16 digits at a time or
similar, this should be at least a little more usable.

Nevermind if MUL/DIV, Int<->BCD conversion, ... would still be potential
bottlenecks.

Granted, if one had semi-fast conversion to/from binary integer types,
this would make MUL/DIV less of an issue, because then one could reuse
the (probably significantly faster) binary integer multiply and divide
operations.

Even if purely software, I suspect the converter route would still
likely be faster than doing decimal long-multiply and long-division.

....

Re: Extended double precision decimal floating point

<jwvpml71ldb.fsf-monnier+comp.arch@gnu.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24850&group=comp.arch#24850

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: monn...@iro.umontreal.ca (Stefan Monnier)
Newsgroups: comp.arch
Subject: Re: Extended double precision decimal floating point
Date: Sat, 23 Apr 2022 18:38:05 -0400
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <jwvpml71ldb.fsf-monnier+comp.arch@gnu.org>
References: <d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com>
<8f909c18-cfe1-4748-8478-543bac50fdbbn@googlegroups.com>
<t41g1s$14hv$1@gal.iecc.com>
<d09babe7-ef1a-43f9-a619-f2adddf766e1n@googlegroups.com>
<t41p9p$24fj$1@gal.iecc.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="9b68b08a72f881923098d72ccd3efaf7";
logging-data="10890"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/huYAhb5pvoV0xsueonkNJ"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
Cancel-Lock: sha1:jpqqp0hCMZ0/tiN19EGN6I8Xy1w=
sha1:ptmukXCwoondCAUT+LtgshsEsAQ=
 by: Stefan Monnier - Sat, 23 Apr 2022 22:38 UTC

>>The sane way is, of course, to change the rules toward
>>radical simplification.
> Indeed, but we're several centuries too late.

Not only that: it's far from obvious what that "radical simplification"
would look like. Look at what IEEE's binary floating point stipulates.
I think a lot of the complexity is inherent in the problem. It is true
that financial rounding rules have extra complexity due to the
combination of rules inherited from different markets/areas, but even
without it it's hard.

Stefan

Re: Extended double precision decimal floating point

<4468d05c-d5f9-48f4-8a38-fa0e624ca299n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24851&group=comp.arch#24851

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ae9:e8cf:0:b0:69f:1e45:2c with SMTP id a198-20020ae9e8cf000000b0069f1e45002cmr4750422qkg.513.1650755846101;
Sat, 23 Apr 2022 16:17:26 -0700 (PDT)
X-Received: by 2002:a05:6870:b383:b0:e9:2fea:2148 with SMTP id
w3-20020a056870b38300b000e92fea2148mr307049oap.103.1650755845839; Sat, 23 Apr
2022 16:17:25 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Sat, 23 Apr 2022 16:17:25 -0700 (PDT)
In-Reply-To: <jwvpml71ldb.fsf-monnier+comp.arch@gnu.org>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:5117:fee5:9e17:6cb7;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:5117:fee5:9e17:6cb7
References: <d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com>
<8f909c18-cfe1-4748-8478-543bac50fdbbn@googlegroups.com> <t41g1s$14hv$1@gal.iecc.com>
<d09babe7-ef1a-43f9-a619-f2adddf766e1n@googlegroups.com> <t41p9p$24fj$1@gal.iecc.com>
<jwvpml71ldb.fsf-monnier+comp.arch@gnu.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4468d05c-d5f9-48f4-8a38-fa0e624ca299n@googlegroups.com>
Subject: Re: Extended double precision decimal floating point
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Sat, 23 Apr 2022 23:17:26 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 23
 by: MitchAlsup - Sat, 23 Apr 2022 23:17 UTC

On Saturday, April 23, 2022 at 5:38:08 PM UTC-5, Stefan Monnier wrote:
> >>The sane way is, of course, to change the rules toward
> >>radical simplification.
> > Indeed, but we're several centuries too late.
<
> Not only that: it's far from obvious what that "radical simplification"
> would look like. Look at what IEEE's binary floating point stipulates.
<
Binary FP rounding has the properties of "low bias" and "numeric stability*".
<
> I think a lot of the complexity is inherent in the problem. It is true
> that financial rounding rules have extra complexity due to the
> combination of rules inherited from different markets/areas, but even
> without it it's hard.
<
There is nothing anyone can do to prevent legislation from creating
bias in rounding and causing numeric instabilities applied to monetary
transactions. That is: Decimal rounding will always be subject to the
whims of legislation without any regards to "reasonable arithmetic".
>
>
> Stefan
<
(*) repeatability might be a better word than stability.

Re: Extended double precision decimal floating point

<78eacde9-f1d8-4ee4-b3d4-ec6c96b37157n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24852&group=comp.arch#24852

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:620a:4515:b0:69f:1986:b07d with SMTP id t21-20020a05620a451500b0069f1986b07dmr5595075qkp.458.1650756032272;
Sat, 23 Apr 2022 16:20:32 -0700 (PDT)
X-Received: by 2002:a9d:2a85:0:b0:605:849d:8b38 with SMTP id
e5-20020a9d2a85000000b00605849d8b38mr3655372otb.229.1650756031995; Sat, 23
Apr 2022 16:20:31 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Sat, 23 Apr 2022 16:20:31 -0700 (PDT)
In-Reply-To: <jwvpml71ldb.fsf-monnier+comp.arch@gnu.org>
Injection-Info: google-groups.googlegroups.com; posting-host=2607:fea8:1dde:6a00:999d:75bb:d82f:b2f8;
posting-account=QId4bgoAAABV4s50talpu-qMcPp519Eb
NNTP-Posting-Host: 2607:fea8:1dde:6a00:999d:75bb:d82f:b2f8
References: <d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com>
<8f909c18-cfe1-4748-8478-543bac50fdbbn@googlegroups.com> <t41g1s$14hv$1@gal.iecc.com>
<d09babe7-ef1a-43f9-a619-f2adddf766e1n@googlegroups.com> <t41p9p$24fj$1@gal.iecc.com>
<jwvpml71ldb.fsf-monnier+comp.arch@gnu.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <78eacde9-f1d8-4ee4-b3d4-ec6c96b37157n@googlegroups.com>
Subject: Re: Extended double precision decimal floating point
From: robfi...@gmail.com (robf...@gmail.com)
Injection-Date: Sat, 23 Apr 2022 23:20:32 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 41
 by: robf...@gmail.com - Sat, 23 Apr 2022 23:20 UTC

On Saturday, April 23, 2022 at 6:38:08 PM UTC-4, Stefan Monnier wrote:
> >>The sane way is, of course, to change the rules toward
> >>radical simplification.
> > Indeed, but we're several centuries too late.
> Not only that: it's far from obvious what that "radical simplification"
> would look like. Look at what IEEE's binary floating point stipulates.
> I think a lot of the complexity is inherent in the problem. It is true
> that financial rounding rules have extra complexity due to the
> combination of rules inherited from different markets/areas, but even
> without it it's hard.
>
>
> Stefan

Okay, I am going with quad precision for processing. I will need to use a simpler
core to implement in the FPGA, I had hoped to avoid the 128-bit busses. There
are probably not many if any use cases for decimal floating point less than
double precision. But the less than quad precision formats may be handy for
lowering data transfer requirements across wire. If there is a small value
decimal number like $100.52 it could be transferred as single precision or BCD.
There are two bits available in the instruction to specify precision.

00 = reserved, 01 = decimal float single, 10 = decimal float double, 11 = decimal float quad

Being able to convert between BCD and decimal float might be handy.

The ISA has BCD add, subtract and multiply. BCD add / subtract takes only three
clock cycles for a full machine width operation (16 digits). Digits are processed in
pairs. The carries from a digit pair are saved between clock cycles and added in the
next cycles.

I may look at trying to come up with decimal float accelerator instructions for a software
implementation. Packing and unpacking decimal float numbers into registers comes to
mind. Only 32 BCD digits will fit into a 128-bit register. To get all 34 decimal digits a
136-bit register is required. A multiply would require 272 register bits. Great idea, a
machine with 136-bit registers.

My current machine is 80-bit registers. Used in pairs that would be 160-bits. Could use
triplets of registers in a 64-bit machine. It would take five registers to hold a multiplier
product though. Starts to take a lot of registers and clock cycles to use a 64-bit machine
for software decimal float.

Re: Extended double precision decimal floating point

<b8056fce-8bf6-4257-898b-25b9d23c16a4n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24853&group=comp.arch#24853

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a0c:c788:0:b0:444:2c7f:4126 with SMTP id k8-20020a0cc788000000b004442c7f4126mr8400675qvj.50.1650758962770;
Sat, 23 Apr 2022 17:09:22 -0700 (PDT)
X-Received: by 2002:a54:4e92:0:b0:325:224c:8ff7 with SMTP id
c18-20020a544e92000000b00325224c8ff7mr100531oiy.154.1650758962543; Sat, 23
Apr 2022 17:09:22 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Sat, 23 Apr 2022 17:09:22 -0700 (PDT)
In-Reply-To: <78eacde9-f1d8-4ee4-b3d4-ec6c96b37157n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:5117:fee5:9e17:6cb7;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:5117:fee5:9e17:6cb7
References: <d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com>
<8f909c18-cfe1-4748-8478-543bac50fdbbn@googlegroups.com> <t41g1s$14hv$1@gal.iecc.com>
<d09babe7-ef1a-43f9-a619-f2adddf766e1n@googlegroups.com> <t41p9p$24fj$1@gal.iecc.com>
<jwvpml71ldb.fsf-monnier+comp.arch@gnu.org> <78eacde9-f1d8-4ee4-b3d4-ec6c96b37157n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b8056fce-8bf6-4257-898b-25b9d23c16a4n@googlegroups.com>
Subject: Re: Extended double precision decimal floating point
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Sun, 24 Apr 2022 00:09:22 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 67
 by: MitchAlsup - Sun, 24 Apr 2022 00:09 UTC

On Saturday, April 23, 2022 at 6:20:33 PM UTC-5, robf...@gmail.com wrote:
> On Saturday, April 23, 2022 at 6:38:08 PM UTC-4, Stefan Monnier wrote:
> > >>The sane way is, of course, to change the rules toward
> > >>radical simplification.
> > > Indeed, but we're several centuries too late.
> > Not only that: it's far from obvious what that "radical simplification"
> > would look like. Look at what IEEE's binary floating point stipulates.
> > I think a lot of the complexity is inherent in the problem. It is true
> > that financial rounding rules have extra complexity due to the
> > combination of rules inherited from different markets/areas, but even
> > without it it's hard.
> >
> >
> > Stefan
> Okay, I am going with quad precision for processing. I will need to use a simpler
> core to implement in the FPGA, I had hoped to avoid the 128-bit busses. There
> are probably not many if any use cases for decimal floating point less than
> double precision. But the less than quad precision formats may be handy for
> lowering data transfer requirements across wire. If there is a small value
> decimal number like $100.52 it could be transferred as single precision or BCD.
> There are two bits available in the instruction to specify precision.
>
> 00 = reserved, 01 = decimal float single, 10 = decimal float double, 11 = decimal float quad
>
> Being able to convert between BCD and decimal float might be handy.
<
My thought is that with 32-digit fixed point, you cover the 99%-ile of what applications
actually need. Especially if 32-digit addition/subtraction is 2-3-4 cycles, with multiply
at less than 20 cycles, and division at less than 50 cycles.
<
>
> The ISA has BCD add, subtract and multiply. BCD add / subtract takes only three
> clock cycles for a full machine width operation (16 digits). Digits are processed in
> pairs. The carries from a digit pair are saved between clock cycles and added in the
> next cycles.
<
A = Rbcd1 + Rbcd2
C = A + 0x666666666666666666666
Answer = A + (C & 0x1111111111111110)
<
Done with a 3-input adder it fits in 1 cycle. {Hint, you use a 2-input adder to binary
add Rs1 and Rs2--in parallel you add Rs1 + Rs1 + 0x6666666666666666--then you
only allow the decimal carry bit at digit locations to be added--+--This last trick can
be performed by implementing a carry select output mux on a digit by digit basis.}
>
> I may look at trying to come up with decimal float accelerator instructions for a software
> implementation. Packing and unpacking decimal float numbers into registers comes to
> mind. Only 32 BCD digits will fit into a 128-bit register. To get all 34 decimal digits a
> 136-bit register is required. A multiply would require 272 register bits. Great idea, a
> machine with 136-bit registers.
<
It only costs 2-gates of delay (and 6 gates per digit) to convert from DPD to BCD.
Here, every 10-binary bits gives you 3 decimal digits. 128-bits gives you 36 digits
and 8 bits to "do stuff" with (sign, decimal exponent,...)
<
Repacking back to DPD only takes 2 gates of delay (and IIRC 7 gates per digit.)
>
> My current machine is 80-bit registers.
<
sorry about that.
<
> Used in pairs that would be 160-bits. Could use
> triplets of registers in a 64-bit machine. It would take five registers to hold a multiplier
> product though. Starts to take a lot of registers and clock cycles to use a 64-bit machine
> for software decimal float.
<
If you look at the clock counts for the latest Z-series DFP--it seems possible that SW would
be competitive with the right primitives.

Re: Extended double precision decimal floating point

<t4264g$ruv$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24854&group=comp.arch#24854

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: iva...@millcomputing.com (Ivan Godard)
Newsgroups: comp.arch
Subject: Re: Extended double precision decimal floating point
Date: Sat, 23 Apr 2022 17:37:35 -0700
Organization: A noiseless patient Spider
Lines: 77
Message-ID: <t4264g$ruv$1@dont-email.me>
References: <d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com>
<8f909c18-cfe1-4748-8478-543bac50fdbbn@googlegroups.com>
<t41g1s$14hv$1@gal.iecc.com>
<d09babe7-ef1a-43f9-a619-f2adddf766e1n@googlegroups.com>
<t41p9p$24fj$1@gal.iecc.com> <jwvpml71ldb.fsf-monnier+comp.arch@gnu.org>
<78eacde9-f1d8-4ee4-b3d4-ec6c96b37157n@googlegroups.com>
<b8056fce-8bf6-4257-898b-25b9d23c16a4n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 24 Apr 2022 00:37:37 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="170c88fd22dcfdb357c6720e8e4f1461";
logging-data="28639"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/e3i9BZgkiE+mhnRtrY9rT"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.8.0
Cancel-Lock: sha1:B0gUTvAffW8QjdMn5i0vacIRwgM=
In-Reply-To: <b8056fce-8bf6-4257-898b-25b9d23c16a4n@googlegroups.com>
Content-Language: en-US
 by: Ivan Godard - Sun, 24 Apr 2022 00:37 UTC

On 4/23/2022 5:09 PM, MitchAlsup wrote:
> On Saturday, April 23, 2022 at 6:20:33 PM UTC-5, robf...@gmail.com wrote:
>> On Saturday, April 23, 2022 at 6:38:08 PM UTC-4, Stefan Monnier wrote:
>>>>> The sane way is, of course, to change the rules toward
>>>>> radical simplification.
>>>> Indeed, but we're several centuries too late.
>>> Not only that: it's far from obvious what that "radical simplification"
>>> would look like. Look at what IEEE's binary floating point stipulates.
>>> I think a lot of the complexity is inherent in the problem. It is true
>>> that financial rounding rules have extra complexity due to the
>>> combination of rules inherited from different markets/areas, but even
>>> without it it's hard.
>>>
>>>
>>> Stefan
>> Okay, I am going with quad precision for processing. I will need to use a simpler
>> core to implement in the FPGA, I had hoped to avoid the 128-bit busses. There
>> are probably not many if any use cases for decimal floating point less than
>> double precision. But the less than quad precision formats may be handy for
>> lowering data transfer requirements across wire. If there is a small value
>> decimal number like $100.52 it could be transferred as single precision or BCD.
>> There are two bits available in the instruction to specify precision.
>>
>> 00 = reserved, 01 = decimal float single, 10 = decimal float double, 11 = decimal float quad
>>
>> Being able to convert between BCD and decimal float might be handy.
> <
> My thought is that with 32-digit fixed point, you cover the 99%-ile of what applications
> actually need. Especially if 32-digit addition/subtraction is 2-3-4 cycles, with multiply
> at less than 20 cycles, and division at less than 50 cycles.
> <
>>
>> The ISA has BCD add, subtract and multiply. BCD add / subtract takes only three
>> clock cycles for a full machine width operation (16 digits). Digits are processed in
>> pairs. The carries from a digit pair are saved between clock cycles and added in the
>> next cycles.
> <
> A = Rbcd1 + Rbcd2
> C = A + 0x666666666666666666666
> Answer = A + (C & 0x1111111111111110)
> <
> Done with a 3-input adder it fits in 1 cycle. {Hint, you use a 2-input adder to binary
> add Rs1 and Rs2--in parallel you add Rs1 + Rs1 + 0x6666666666666666--then you
> only allow the decimal carry bit at digit locations to be added--+--This last trick can
> be performed by implementing a carry select output mux on a digit by digit basis.}
>>
>> I may look at trying to come up with decimal float accelerator instructions for a software
>> implementation. Packing and unpacking decimal float numbers into registers comes to
>> mind. Only 32 BCD digits will fit into a 128-bit register. To get all 34 decimal digits a
>> 136-bit register is required. A multiply would require 272 register bits. Great idea, a
>> machine with 136-bit registers.
> <
> It only costs 2-gates of delay (and 6 gates per digit) to convert from DPD to BCD.
> Here, every 10-binary bits gives you 3 decimal digits. 128-bits gives you 36 digits
> and 8 bits to "do stuff" with (sign, decimal exponent,...)
> <
> Repacking back to DPD only takes 2 gates of delay (and IIRC 7 gates per digit.)
>>
>> My current machine is 80-bit registers.
> <
> sorry about that.
> <
>> Used in pairs that would be 160-bits. Could use
>> triplets of registers in a 64-bit machine. It would take five registers to hold a multiplier
>> product though. Starts to take a lot of registers and clock cycles to use a 64-bit machine
>> for software decimal float.
> <
> If you look at the clock counts for the latest Z-series DFP--it seems possible that SW would
> be competitive with the right primitives.

Software is easier if you define your own semantics :-) There's this
thing called "preferred quantum". Any multiply must rescale. You can't
just add a number in pennies to a number in dollars, and the
precision-conserving scaling you are used to from BFP is wrong.

Roughly speaking, BCD ops in hardware make implementing DFP easier/less
expensive, but you can't just convert DFP to BCD and add away willy-nilly.

Re: Extended double precision decimal floating point

<f93c264f-bdc9-46c7-a5ad-e3d49bceceadn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24855&group=comp.arch#24855

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:6214:625:b0:441:1578:620b with SMTP id a5-20020a056214062500b004411578620bmr8390885qvx.126.1650762354059;
Sat, 23 Apr 2022 18:05:54 -0700 (PDT)
X-Received: by 2002:a05:6808:16ac:b0:2f9:52e5:da90 with SMTP id
bb44-20020a05680816ac00b002f952e5da90mr9567773oib.5.1650762353841; Sat, 23
Apr 2022 18:05:53 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Sat, 23 Apr 2022 18:05:53 -0700 (PDT)
In-Reply-To: <t4264g$ruv$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:5117:fee5:9e17:6cb7;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:5117:fee5:9e17:6cb7
References: <d1790e73-11b1-497d-abd0-a349fedf750cn@googlegroups.com>
<8f909c18-cfe1-4748-8478-543bac50fdbbn@googlegroups.com> <t41g1s$14hv$1@gal.iecc.com>
<d09babe7-ef1a-43f9-a619-f2adddf766e1n@googlegroups.com> <t41p9p$24fj$1@gal.iecc.com>
<jwvpml71ldb.fsf-monnier+comp.arch@gnu.org> <78eacde9-f1d8-4ee4-b3d4-ec6c96b37157n@googlegroups.com>
<b8056fce-8bf6-4257-898b-25b9d23c16a4n@googlegroups.com> <t4264g$ruv$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f93c264f-bdc9-46c7-a5ad-e3d49bceceadn@googlegroups.com>
Subject: Re: Extended double precision decimal floating point
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Sun, 24 Apr 2022 01:05:54 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 101
 by: MitchAlsup - Sun, 24 Apr 2022 01:05 UTC

On Saturday, April 23, 2022 at 7:37:40 PM UTC-5, Ivan Godard wrote:
> On 4/23/2022 5:09 PM, MitchAlsup wrote:
> > On Saturday, April 23, 2022 at 6:20:33 PM UTC-5, robf...@gmail.com wrote:
> >> On Saturday, April 23, 2022 at 6:38:08 PM UTC-4, Stefan Monnier wrote:
> >>>>> The sane way is, of course, to change the rules toward
> >>>>> radical simplification.
> >>>> Indeed, but we're several centuries too late.
> >>> Not only that: it's far from obvious what that "radical simplification"
> >>> would look like. Look at what IEEE's binary floating point stipulates.
> >>> I think a lot of the complexity is inherent in the problem. It is true
> >>> that financial rounding rules have extra complexity due to the
> >>> combination of rules inherited from different markets/areas, but even
> >>> without it it's hard.
> >>>
> >>>
> >>> Stefan
> >> Okay, I am going with quad precision for processing. I will need to use a simpler
> >> core to implement in the FPGA, I had hoped to avoid the 128-bit busses. There
> >> are probably not many if any use cases for decimal floating point less than
> >> double precision. But the less than quad precision formats may be handy for
> >> lowering data transfer requirements across wire. If there is a small value
> >> decimal number like $100.52 it could be transferred as single precision or BCD.
> >> There are two bits available in the instruction to specify precision.
> >>
> >> 00 = reserved, 01 = decimal float single, 10 = decimal float double, 11 = decimal float quad
> >>
> >> Being able to convert between BCD and decimal float might be handy.
> > <
> > My thought is that with 32-digit fixed point, you cover the 99%-ile of what applications
> > actually need. Especially if 32-digit addition/subtraction is 2-3-4 cycles, with multiply
> > at less than 20 cycles, and division at less than 50 cycles.
> > <
> >>
> >> The ISA has BCD add, subtract and multiply. BCD add / subtract takes only three
> >> clock cycles for a full machine width operation (16 digits). Digits are processed in
> >> pairs. The carries from a digit pair are saved between clock cycles and added in the
> >> next cycles.
> > <
> > A = Rbcd1 + Rbcd2
> > C = A + 0x666666666666666666666
> > Answer = A + (C & 0x1111111111111110)
> > <
> > Done with a 3-input adder it fits in 1 cycle. {Hint, you use a 2-input adder to binary
> > add Rs1 and Rs2--in parallel you add Rs1 + Rs1 + 0x6666666666666666--then you
> > only allow the decimal carry bit at digit locations to be added--+--This last trick can
> > be performed by implementing a carry select output mux on a digit by digit basis.}
> >>
> >> I may look at trying to come up with decimal float accelerator instructions for a software
> >> implementation. Packing and unpacking decimal float numbers into registers comes to
> >> mind. Only 32 BCD digits will fit into a 128-bit register. To get all 34 decimal digits a
> >> 136-bit register is required. A multiply would require 272 register bits. Great idea, a
> >> machine with 136-bit registers.
> > <
> > It only costs 2-gates of delay (and 6 gates per digit) to convert from DPD to BCD.
> > Here, every 10-binary bits gives you 3 decimal digits. 128-bits gives you 36 digits
> > and 8 bits to "do stuff" with (sign, decimal exponent,...)
> > <
> > Repacking back to DPD only takes 2 gates of delay (and IIRC 7 gates per digit.)
> >>
> >> My current machine is 80-bit registers.
> > <
> > sorry about that.
> > <
> >> Used in pairs that would be 160-bits. Could use
> >> triplets of registers in a 64-bit machine. It would take five registers to hold a multiplier
> >> product though. Starts to take a lot of registers and clock cycles to use a 64-bit machine
> >> for software decimal float.
> > <
> > If you look at the clock counts for the latest Z-series DFP--it seems possible that SW would
> > be competitive with the right primitives.
> Software is easier if you define your own semantics :-) There's this
> thing called "preferred quantum". Any multiply must rescale. You can't
> just add a number in pennies to a number in dollars, and the
> precision-conserving scaling you are used to from BFP is wrong.
>
> Roughly speaking, BCD ops in hardware make implementing DFP easier/less
> expensive, but you can't just convert DFP to BCD and add away willy-nilly.
<
I was not--I was leaving EVERYTHING in BCD/DPD and doing NOTHING in DFP.
<
It seems to me that when doing cash calculations; more than 99% of these
calculations stay within a single numeric system ($ = $ + $;...) and the very
vast majority need no extra digits behind the decimal point. After all the unit
quantum is (in the $ system) the penny ($0.01) so you don't buy 7.6 units
and the unit cost is not $x.yzabc unless abc=000.
<
Only the application of taxes requires more precision, and here, every state gets
to define the point of rounding and the methods of rounding.
<
Converting world GDP into the least valuable monetary system needs no more
precision than found in eXcel--precisely because the meaning of the calculated
value is without worth.
<
<---------------------------------------------------------------------------------------------------------------------------
<
But let us consider that DFP was easy to provide, and that MS was feeling
benign one day*, and put DFP into eXcel.
<
I put it to you that the surprise factor encountered in eXcel would not be
diminished.
<
(*) MS has never operated that benignly on any given day since about 1981.....

Pages:12345
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor