|
Prev: Printing from M/F COBOL
Next: Packed decimal versus binary was Re: J4 - presentation/discussion on "Future of the COBOL Standard"
From: tlmfru on 5 Apr 2008 12:54 Robert <no(a)e.mail> wrote in message news:c2ldv3dtaij23o1d7h2377975e2053k57d(a)4ax.com... > On Fri, 04 Apr 2008 07:50:39 -0600, Howard Brazee <howard(a)brazee.net> wrote: > > >On Fri, 04 Apr 2008 00:13:23 -0600, Robert <no(a)e.mail> wrote: > > > >>You thought that because 'everyone knows' binary fractions are inaccurate. Some refuse to > >>believe the number is an integer, not a fraction. That was my whole point -- we could have > >>been storing currency amounts (dollars/pounds/zlotnys and cents) in binary all along. We > >>never needed packed decimal. It was an IBM sales gimmick, and it worked. > > Tip o'the (Hatlo) hat to whoever pointed this out originally - 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 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. 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? Cheers PL
From: Robert on 5 Apr 2008 20:18 On Sat, 5 Apr 2008 10:54:00 -0600, "tlmfru" <lacey(a)mts.net> wrote: > >Robert <no(a)e.mail> wrote in message >news:c2ldv3dtaij23o1d7h2377975e2053k57d(a)4ax.com... >> On Fri, 04 Apr 2008 07:50:39 -0600, Howard Brazee <howard(a)brazee.net> >wrote: >> >> >On Fri, 04 Apr 2008 00:13:23 -0600, Robert <no(a)e.mail> wrote: >> > >> >>You thought that because 'everyone knows' binary fractions are >inaccurate. Some refuse to >> >>believe the number is an integer, not a fraction. That was my whole >point -- we could have >> >>been storing currency amounts (dollars/pounds/zlotnys and cents) in >binary all along. We >> >>never needed packed decimal. It was an IBM sales gimmick, and it worked. >> > > > >Tip o'the (Hatlo) hat to whoever pointed this out originally - > >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). >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(a)ns.sympatico.ca> 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 >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? There aren't any fractions in fixed-point number representations; the numbers are all integers. If you look in memory at the variable with 'pic 99v99 value .2', you will see '0020', which is not a fraction. Fractions appear only in floating point systems. Who says the number system base must be a real positive integer? In the negadecimal system, which has -10 as its base, 8163 decimal becomes 12243 negadecimal as 10000 + (-2000) + 200 + (-40) + 3. The advantage of negative base systems is they don't require a sign. An imaginary base system such as the one proposed by Donald Knuth represents numbers without an 'i' nor a sign. The ideal numeration base is an irrational called phi or golden ratio, which is 1.61803... The only digits are 0 and 1, which makes it ideal for computers. One would expect 'our' integers to produce infinately repeating fractions while irrational numbers produce terminated fractions. Not so. In phinary, EVERY number can be represented exactly in a finite string of 0s and 1s, including e, pi and square root of 2. That's a very valuable attribute. For more on this, see: http://www.mcs.surrey.ac.uk/Personal/R.Knott/Fibonacci/phigits.html http://en.wikipedia.org/wiki/Phinary
From: Anonymous on 5 Apr 2008 22:23 In article <lesdv3pds3tee2vekk00kf2oahm4p4l8b7(a)4ax.com>, Robert <no(a)e.mail> wrote: >On Sat, 5 Apr 2008 01:39:33 +0000 (UTC), docdwarf(a)panix.com () wrote: > >>In article <c2ldv3dtaij23o1d7h2377975e2053k57d(a)4ax.com>, >>Robert <no(a)e.mail> wrote: >>>On Fri, 04 Apr 2008 07:50:39 -0600, Howard Brazee <howard(a)brazee.net> wrote: >> >>[snip] >> >>>> Also, packed decimal was (and is) significantly quicker in >>>>when the application wants Display and computational use of the same >>>>number. >>> >>>Why was it used when the application did not need both formats, which >>>was most of the time? >> >>I cannot speak for any circumstances beyond my own limited experiences, Mr >>Wagner... but those have it that the reason *any* method was used at *any* >>time was because Someone of Sufficient Authority deemed it so. > >You're overly hung up on pleasing the bossman. Imagine being the >bossman, the one who makes such decisions. My desire, Mr Wagner, is to do the job I am paid to do; I cannot do that if someone tells Security to de-activate my badge which lets me into the building. Were I to do as you asked immediately above ('imagine being the bossman') then it might be only by chance that I could answer your earlier question ('why was it done'); I would be a one-who-imagined, not a one-who-did. > >>Have you never seen a job-site where something similar took place? > >As a contractor, I cannot criticize poor decision processes in real life >(only here). Leaving aside that you were asked what you had seen, not what you can or cannot do... .... I do not know what you acre calling 'criticizing', Mr Wagner, but as a contractor I have said many, many times 'I believe that there could be difficulties with this because of (reason); now that I have stated this... what you're doing does not violate what I assume to be my set of professional ethics nor my personal integrity so let me give you what you are paying for.' When - not if - saying something like that gets my badge de-activated then I find another job... that's what consultants/contractors/hired guns do, or so I've seen. DD
From: Howard Brazee on 7 Apr 2008 10:04 On Fri, 04 Apr 2008 19:51:24 -0600, Robert <no(a)e.mail> wrote: >>Packed decimal was never marketed as a Need. It was marketed as an >>efficiency option. Saving space used to be a significant cost >>factor. > >Binary takes 20% less space in memory. Compromises are often the best solution. >> Also, packed decimal was (and is) significantly quicker in >>when the application wants Display and computational use of the same >>number. > >Why was it used when the application did not need both formats, which was most of the >time? Please give me figures showing that it was used that way most of the time. Although how often something is mis-used does not indicate that it is a bad idea. >>>If they did it in binary and got right answers, people would find out. Then the decimal >>>ruse would be discredited. >> >>Most of us never saw a "ruse". Probably this was because we >>understood what packed-decimal was all about and made our choices >>accordingly. > >If you all truly understood what packed was all about, you all wouldn't have used it. Why not? I already told you when it is useful, and why. Your response was that most people used it other ways - therefore I shouldn't have used it. Your reply seems to be of a Religious nature, not one based upon logic. >>We also don't have our identity tied into understanding everything - >>so when we do find that we had a misunderstanding, we don't need to >>find someone to blame for trying to fool us. > >The brave new world would be better if people could just get along. Pointing out mistakes >is against social harmony, thus antisocial. A soma 'holiday' will relieve bad memories and >insure social stabilization. A world without change has some advantages - of course the saber tooth tigers would still be ignoring our harmony.
From: Howard Brazee on 7 Apr 2008 10:07
On Fri, 04 Apr 2008 21:54:44 -0600, Robert <no(a)e.mail> wrote: >As a contractor, I cannot criticize poor decision processes in real life (only here). If >shops were totally rational, they wouldn't hire contractors. I never did. If shops were totally rational, they wouldn't pre-judge whether contractors are cost-effective for a particular need or not. Instead, they would analyze each need, evaluate the options, and make a decision based upon that particular need. If this means, contracting out the garbage collection, the computer installation, the window cleaning - or whatever - so be it. |