Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Cobol > Re: Decimal ver...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 43 of 53 Topic 4077 of 4196
Post > Topic >>

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

by Robert <no@[EMAIL PROTECTED] > Apr 7, 2008 at 09:11 PM

On Mon, 7 Apr 2008 11:08:23 -0500, "tlmfru" <lacey@[EMAIL PROTECTED]
> wrote:

>Robert <no@[EMAIL PROTECTED]
> wrote in message
>news:521gv394rgj59j3d8u86clvp0a8am6857n@[EMAIL PROTECTED]
>> On Sat, 5 Apr 2008 10:54:00 -0600, "tlmfru" <lacey@[EMAIL PROTECTED]
> wrote:
>>
>> >
>> >One very good reason that pure binary representation was not used is
that
>> >decimal fractions cannot (generally) be expressed except as a
repeating
>> >number in binary.  Examples: 0.2 (decimal) = .00110011 ... (binary). 
.12
>> >(decimal) = .000111 etc. (binary).
>>
>> To pay for something costing .50, you don't tear a dollar bill in half
(a
>fraction), you
>> tender 50 pennies (an integer).
>>
>
>Nevertheless, if you're calculating what happened, you've spent half a
>dollar - unless you convert  ALL the figures to pennies.

No conversion is necessary. Figures are already in pennies. 

>> >To make correct arithmetic using only binary possible, it seems to me
>that
>> >ALL numbers must be implicitly scaled to remove the decimal point.  If
>that
>> >is your meaning, Robert, then you haven't made it clear.  Binary
>fractions
>> >cannot be represented accurately - period.
>>
>> I did make it clear. Here's the thread:
>>
>> >> On Mon, 31 Mar 2008 21:55:10 -0300, Clark F Morris
>> >> <cfmpublic@[EMAIL PROTECTED]
> wrote:
>> >>
>> >>>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.
>> >
>> >That's because you did not do it in binary, you did it in decimal.
>> >One-fifth is rational in decimal, but irrational in binary.
>>
>> >Nope, all three numbers are binary INTEGERS. The fallacy is in
thinking
>of quotient as a fraction. It is not a fraction, it is an integer.
>> > The compiler SCALED two integers by multiplying by powers of 10, then
>divided two binary integers to get a quotient with no fraction.
>> > Binary 10 divided by binary 5 gives binary 2.
>>
>> >101111101011110000100000000 / 1100001101010000 = 11111010000
>
>This isn't the point.  The point is that with very few exceptions a
decimal
>number with figures on both sides of the decimal point can't be
represented
>as a pure binary number, as the fractional ****tion is almost always
>non-terminating. Binary ONE divided by binary 5 gives binary
.00110011.....
>A scaled number is not the number itself: it's a transformation of the
>original.

By definition, integers are whole numbers. There is no fractional part to
an integer. 

>Incidentally, how do you decode that string of digits?

I paste it into a calculator and hit Dec.  Hardware does it by doubling
the answer and
adding each bit, left to right.

>> >Incidentally - everybody knows about the simple algoritm to convert
base
>10
>> >numbers to base 2 - i.e. repeated division by 2 -
>> >I had some fun working out the mirror algorithm to convert decimal
>FRACTIONS
>> >to binary fractions.  (Very easy, actually).  (Both algorithms work
for
>any
>> >base).  But what puzzles me is I've never seen this written up
anywhere.
>> >I'm certain that the early developers of computers (or perhaps IBM
>research
>> >fellows) must have discovered the algorithm.  Has anyone seen it
written
>up?

It's of no use when dealing with integers, because they have no fractional
part.

>Very interesting!  But doesn't answer my question.  I'd really like to
make
>an original contribution to math or computer science but I can't believe
>that "my algorithm" is it.

Now you're in the domain of abstraction and generalization, a faux pas in
these parts.
 




 53 Posts in Topic:
Re: Decimal versus binary arithmetic was Re: J4 -
"Frank Swarbrick&quo  2008-04-01 13:14:46 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
Clark F Morris <cfmpub  2008-04-01 19:29:05 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
Binyamin Dissen <posti  2008-04-02 10:18:01 
Re: Decimal versus binary arithmetic was Re: J4 -
Alistair <alistair@[EM  2008-04-05 14:39:44 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/
Robert <no@[EMAIL PROT  2008-04-05 18:46:10 
Re: Decimal versus binary arithmetic was Re: J4 -
Richard <riplin@[EMAIL  2008-04-07 21:53:28 
Re: Decimal versus binary arithmetic was Re: J4 -
Richard <riplin@[EMAIL  2008-04-07 22:09:08 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/
Robert <no@[EMAIL PROT  2008-04-08 22:05:16 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/
"Rick Smith" &l  2008-04-09 10:16:29 
Re: Decimal versus binary arithmetic was Re: J4 -
Richard <riplin@[EMAIL  2008-04-07 22:16:47 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/
Michael Wojcik <mwojci  2008-04-08 16:57:05 
Re: Decimal versus binary arithmetic was Re: J4 -
Richard <riplin@[EMAIL  2008-04-07 22:29:07 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/
Robert <no@[EMAIL PROT  2008-04-08 21:59:07 
Re: Decimal versus binary arithmetic was Re: J4 -
Richard <riplin@[EMAIL  2008-04-07 22:41:07 
Re: Decimal versus binary arithmetic was Re: J4 -
Richard <riplin@[EMAIL  2008-04-07 22:54:32 
Sampling accuracy and everyone being wrong was Re: Decimal vers
Clark F Morris <cfmpub  2008-04-08 10:31:39 
Re: Sampling accuracy and everyone being wrong was Re: Decimal
docdwarf@[EMAIL PROTECTED  2008-04-08 14:48:38 
Re: Decimal versus binary arithmetic was Re: J4 -
Richard <riplin@[EMAIL  2008-04-08 21:41:10 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/
Robert <no@[EMAIL PROT  2008-04-09 19:19:26 
Re: Decimal versus binary arithmetic was Re: J4 -
Richard <riplin@[EMAIL  2008-04-09 18:45:59 
Re: Decimal versus binary arithmetic was Re: J4 -
"Frank Swarbrick&quo  2008-04-03 18:42:16 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
Robert <no@[EMAIL PROT  2008-04-04 00:13:23 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
"William M. Klein&qu  2008-04-04 05:52:42 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
Robert <no@[EMAIL PROT  2008-04-07 22:41:47 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
Howard Brazee <howard@  2008-04-04 07:50:39 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
Robert <no@[EMAIL PROT  2008-04-04 19:51:24 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
docdwarf@[EMAIL PROTECTED  2008-04-05 01:39:33 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
Robert <no@[EMAIL PROT  2008-04-04 21:54:44 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
docdwarf@[EMAIL PROTECTED  2008-04-06 02:23:46 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
Robert <no@[EMAIL PROT  2008-04-07 22:39:38 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
Howard Brazee <howard@  2008-04-08 08:47:27 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
Robert <no@[EMAIL PROT  2008-04-08 20:39:22 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
Howard Brazee <howard@  2008-04-09 07:51:19 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
Robert <no@[EMAIL PROT  2008-04-09 20:00:40 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
Howard Brazee <howard@  2008-04-10 07:36:17 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
Howard Brazee <howard@  2008-04-10 08:53:22 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
Howard Brazee <howard@  2008-04-09 07:53:32 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
Robert <no@[EMAIL PROT  2008-04-09 19:54:10 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
Howard Brazee <howard@  2008-04-07 08:07:32 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
"tlmfru" <la  2008-04-05 10:54:00 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
Robert <no@[EMAIL PROT  2008-04-05 18:18:13 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
"tlmfru" <la  2008-04-07 11:08:23 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
Robert <no@[EMAIL PROT  2008-04-07 21:11:04 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
"tlmfru" <la  2008-04-08 11:00:52 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
Howard Brazee <howard@  2008-04-07 08:09:26 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
"tlmfru" <la  2008-04-07 10:49:27 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
Howard Brazee <howard@  2008-04-07 08:04:00 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
"HeyBub" <he  2008-04-04 08:53:49 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
Robert <no@[EMAIL PROT  2008-04-04 21:19:36 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
"Pete Dashwood"  2008-04-05 17:34:51 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
docdwarf@[EMAIL PROTECTED  2008-04-05 14:03:36 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
Howard Brazee <howard@  2008-04-07 08:12:37 
Re: Decimal versus binary arithmetic was Re: J4 - presentation/d
Robert <no@[EMAIL PROT  2008-04-07 20:24:59 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 3:27:27 CDT 2008.