From: Clark F Morris on
On Tue, 1 Apr 2008 13:14:46 -0600, "Frank Swarbrick"
<Frank.Swarbrick(a)efirstbank.com> wrote:

>>>> On 4/1/2008 at 12:43 PM, in message
><if05v3503beg04nonbeci3n8eqo2vill79(a)4ax.com>, Clark F
>Morris<cfmpublic(a)ns.sympatico.ca> wrote:
>> On Mon, 31 Mar 2008 22:37:12 -0600, Robert <no(a)e.mail> wrote:
>>
>>>On Mon, 31 Mar 2008 21:55:10 -0300, Clark F Morris
>><cfmpublic(a)ns.sympatico.ca> wrote:
>>>
>>>>On Tue, 18 Mar 2008 19:34:51 -0600, Robert <no(a)e.mail> 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.
>> You may have to do this in Assembler to get the results that I am
>> talking about. Take a look at the generated instructions. If I had
>> access to an IBM mainframe I would compile a small test program to see
>> what the underlying code is.
>
>5820 9510 L 2,1296(0,9) NUMERATOR
>
>4E20 D1C4 CVD 2,452(0,13) TS2=4
>
>D203 D1C0 C02A MVC 448(4,13),42(12) TS2=0
> SYSLIT AT +42
>F060 D1C5 0004 SRP 453(7,13),4(0),0 TS2=5
>
>5820 9518 L 2,1304(0,9) DENOMINATOR
>
>4E20 D1D0 CVD 2,464(0,13) TS2=16
>
>FDB4 D1C0 D1D3 DP 448(12,13),467(5,13) TS2=0
> TS2=19
>F896 D1E0 D1C0 ZAP 480(10,13),448(7,13) TS2=32
> TS2=0
>960F D1E9 OI 489(13),X'0F' TS2=41
>
>D202 D1D8 C02A MVC 472(3,13),42(12) TS2=24
> SYSLIT AT +42
>D204 D1DB D1E5 MVC 475(5,13),485(13) TS2=27
> TS2=37
>4F20 D1D8 CVB 2,472(0,13) TS2=24
>
>F144 D1DB D1E0 MVO 475(5,13),480(5,13) TS2=27
> TS2=32
>4F50 D1D8 CVB 5,472(0,13) TS2=24
>
>5C40 C004 M 4,4(0,12) SYSLIT AT +4
>
>1E52 ALR 5,2
>
>58B0 C034 L 11,52(0,12) PBL=1
>
>47C0 B698 BC 12,1688(0,11) GN=16(000A70)
>
>5A40 C000 A 4,0(0,12) SYSLIT AT +0
>
> GN=16 EQU *
>
>1222 LTR 2,2
>47B0 B6A2 BC 11,1698(0,11) GN=17(000A7A)
>5B40 C000 S 4,0(0,12) SYSLIT AT +0
> GN=17 EQU *
>9045 9520 STM 4,5,1312(9) QUOTIENT

Wow, they are actually doing this in decimal. I wonder what the code
would be like using binary instructions. I see they are handling the
remainder separately.
>
>Frank
Clark
From: William M. Klein on
Clark,
Can you try this (slight) variation - and compile

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

compute quotient = numerator / denominator
display quotient

My guess is that they would still be doing it in decimal, but this would "force"
the compiler into knowing the fields were to be truncated/handeld in "true"
binary rather than based on the PIC.

--
Bill Klein
wmklein <at> ix.netcom.com
"tlmfru" <lacey(a)mts.net> wrote in message
news:SJvIj.51320$097.28239(a)newsfe21.lga...
>
> Clark F Morris <cfmpublic(a)ns.sympatico.ca> wrote in message
> news:if05v3503beg04nonbeci3n8eqo2vill79(a)4ax.com...
>> On Mon, 31 Mar 2008 22:37:12 -0600, Robert <no(a)e.mail> wrote:
>>
>> >On Mon, 31 Mar 2008 21:55:10 -0300, Clark F Morris
> <cfmpublic(a)ns.sympatico.ca> wrote:
>> >
>> >>On Tue, 18 Mar 2008 19:34:51 -0600, Robert <no(a)e.mail> 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
>
>


From: Robert on
On Tue, 01 Apr 2008 12:44:49 GMT, "Michael Mattias" <mmattias(a)talsystems.com> wrote:

>"Robert" <no(a)e.mail> wrote in message
>news:jbd3v3tomdipsgke42j5cklujltahbtjle(a)4ax.com...
>> 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

For ease of reading, in base 16 and 10

5F5E100 / C350 = 7D0

100000000 / 50000 = 2000


From: Binyamin Dissen on
On Tue, 01 Apr 2008 19:29:05 -0300 Clark F Morris <cfmpublic(a)ns.sympatico.ca>
wrote:

:>On Tue, 1 Apr 2008 13:14:46 -0600, "Frank Swarbrick"
:><Frank.Swarbrick(a)efirstbank.com> wrote:

:>>>>> On 4/1/2008 at 12:43 PM, in message
:>><if05v3503beg04nonbeci3n8eqo2vill79(a)4ax.com>, Clark F
:>>Morris<cfmpublic(a)ns.sympatico.ca> wrote:
:>>> On Mon, 31 Mar 2008 22:37:12 -0600, Robert <no(a)e.mail> wrote:

:>>>>On Mon, 31 Mar 2008 21:55:10 -0300, Clark F Morris
:>>><cfmpublic(a)ns.sympatico.ca> wrote:

:>>>>>On Tue, 18 Mar 2008 19:34:51 -0600, Robert <no(a)e.mail> 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.
:>>> You may have to do this in Assembler to get the results that I am
:>>> talking about. Take a look at the generated instructions. If I had
:>>> access to an IBM mainframe I would compile a small test program to see
:>>> what the underlying code is.

:>>5820 9510 L 2,1296(0,9) NUMERATOR
:>>4E20 D1C4 CVD 2,452(0,13) TS2=4
:>>D203 D1C0 C02A MVC 448(4,13),42(12) TS2=0
:>> SYSLIT AT +42
:>>F060 D1C5 0004 SRP 453(7,13),4(0),0 TS2=5
:>>5820 9518 L 2,1304(0,9) DENOMINATOR
:>>4E20 D1D0 CVD 2,464(0,13) TS2=16
:>>FDB4 D1C0 D1D3 DP 448(12,13),467(5,13) TS2=0
:>> TS2=19
:>>F896 D1E0 D1C0 ZAP 480(10,13),448(7,13) TS2=32
:>> TS2=0
:>>960F D1E9 OI 489(13),X'0F' TS2=41
:>>D202 D1D8 C02A MVC 472(3,13),42(12) TS2=24
:>> SYSLIT AT +42
:>>D204 D1DB D1E5 MVC 475(5,13),485(13) TS2=27
:>> TS2=37
:>>4F20 D1D8 CVB 2,472(0,13) TS2=24
:>>F144 D1DB D1E0 MVO 475(5,13),480(5,13) TS2=27
:>> TS2=32
:>>4F50 D1D8 CVB 5,472(0,13) TS2=24
:>>5C40 C004 M 4,4(0,12) SYSLIT AT +4
:>>1E52 ALR 5,2
:>>58B0 C034 L 11,52(0,12) PBL=1
:>>47C0 B698 BC 12,1688(0,11) GN=16(000A70)
:>>5A40 C000 A 4,0(0,12) SYSLIT AT +0
:>> GN=16 EQU *
:>>1222 LTR 2,2
:>>47B0 B6A2 BC 11,1698(0,11) GN=17(000A7A)
:>>5B40 C000 S 4,0(0,12) SYSLIT AT +0
:>> GN=17 EQU *
:>>9045 9520 STM 4,5,1312(9) QUOTIENT

:>Wow, they are actually doing this in decimal. I wonder what the code
:>would be like using binary instructions. I see they are handling the
:>remainder separately.

I would guess the conversions are being done to properly handle the different
scaling factors, where decimal arithmetic can handle larger precisions
(fullword is limited to 10 digits while packed can hold 15 digits - and with Z
hardware, the numbers double).

Try them all with the same picture, 9(4)V4(9), which will fit in a word.

--
Binyamin Dissen <bdissen(a)dissensoftware.com>
http://www.dissensoftware.com

Director, Dissen Software, Bar & Grill - Israel


Should you use the mailblocks package and expect a response from me,
you should preauthorize the dissensoftware.com domain.

I very rarely bother responding to challenge/response systems,
especially those from irresponsible companies.
From: Clark F Morris on
On Wed, 02 Apr 2008 02:45:10 GMT, "William M. Klein"
<wmklein(a)nospam.netcom.com> wrote:

>Clark,
> Can you try this (slight) variation - and compile
>
>01 numerator value 1 Comp-5 pic 9(9).
>01 denominator value 5 Comp-5 pic 9(9).
>01 quotient Comp-5 pic 9(9)v9(4).
>
>compute quotient = numerator / denominator
> display quotient
>
>My guess is that they would still be doing it in decimal, but this would "force"
>the compiler into knowing the fields were to be truncated/handeld in "true"
>binary rather than based on the PIC.
Frank is the person who did the compilation since I don't have access
to a z series computer (or a COBOL compiler). It would be interesting
to see the code generation for a computer that is basically binary
(Intel, HP, AIX boxes, etc.).