Re: Decimal versus binary arithmetic was Re: J4 - presentation/discussion on "Future of the COBOL Standard"




Clark F Morris <cfmpublic@xxxxxxxxxxxxxxx> wrote in message
news:if05v3503beg04nonbeci3n8eqo2vill79@xxxxxxxxxx
On Mon, 31 Mar 2008 22:37:12 -0600, Robert <no@xxxxxx> wrote:

On Mon, 31 Mar 2008 21:55:10 -0300, Clark F Morris
<cfmpublic@xxxxxxxxxxxxxxx> wrote:

On Tue, 18 Mar 2008 19:34:51 -0600, Robert <no@xxxxxx> wrote:


Lots of muddled thinking on numeric errors has been published. Some
talk about 'binary
arithmetic' without making a distinction between integer and floating
point. Here's an
example:

Try doing a simple divide like calculate the value of 1 / 5 in binary.

OK.

01 numerator value 1 binary pic 9(9).
01 denominator value 5 binary pic 9(9).
01 quotient binary pic 9(9)v9(4).

compute quotient = numerator / denominator
display quotient

0000000002000

You get a never ending fraction.

Looks pretty diadic to me.


He's right, you know.

0.2 (decimal) in binary = 1/8 + 1/16 + 1/128 + 1/256 ... = .00110011 ... =
0.19921875. etc. Obviously binary division is done by black magic
involving shifts & counts.

PL


.



Relevant Pages


Loading