>>> On 4/1/2008 at 4:29 PM, in message
<jld5v39e0mbt577fcr16ulsgjkquub27vf@[EMAIL PROTECTED]
>, Clark F
Morris<cfmpublic@[EMAIL PROTECTED]
> wrote:
> On Tue, 1 Apr 2008 13:14:46 -0600, "Frank Swarbrick"
> <Frank.Swarbrick@[EMAIL PROTECTED]
> wrote:
>
>>>>> On 4/1/2008 at 12:43 PM, in message
>><if05v3503beg04nonbeci3n8eqo2vill79@[EMAIL PROTECTED]
>, Clark F
>>Morris<cfmpublic@[EMAIL PROTECTED]
> wrote:
>>> On Mon, 31 Mar 2008 22:37:12 -0600, Robert <no@[EMAIL PROTECTED]
> wrote:
>>>
>>>>On Mon, 31 Mar 2008 21:55:10 -0300, Clark F Morris
>>><cfmpublic@[EMAIL PROTECTED]
> wrote:
>>>>
>>>>>On Tue, 18 Mar 2008 19:34:51 -0600, Robert <no@[EMAIL PROTECTED]
> 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 was amazed that the 'v' in the PICTURE clause was even allowed for a
COMP
data item. I just assumed that it had to be DISPLAY, PACKED-DECIMAL or a
floating point field for a decimal to be allowed. Not sure *why* I
thought
this, but this was definitely the first time I had ever seen this.
For what its worth, here it is with the data items declared as
01 NUMERATOR VALUE 1 BINARY PIC 9(9)V9(4).
01 DENOMINATOR VALUE 5 BINARY PIC 9(9)V9(4).
01 QUOTIENT BINARY PIC 9(9)V9(4).
LM 2,3,1376(9) NUMERATOR
D 2,4(0,12) SYSLIT AT +4
CVD 3,480(0,13) TS2=16
MVO 470(6,13),483(5,13) TS2=6 TS2=19
CVD 2,480(0,13) TS2=16
TM 475(13),X'10' TS2=11
MVC 475(5,13),483(13) TS2=11 TS2=19
L 11,52(0,12) PBL=1
BC 8,1832(0,11) GN=18(000B10)
OI 479(13),X'01' TS2=15
EQU *
MVC 464(6,13),42(12) TS2=0 SYSLIT AT
+42
SRP 471(9,13),4(0),0 TS2=7
LM 2,3,1384(9) DENOMINATOR
D 2,4(0,12) SYSLIT AT +4
CVD 3,496(0,13) TS2=32
MVO 480(6,13),499(5,13) TS2=16 TS2=35
CVD 2,496(0,13) TS2=32
TM 485(13),X'10' TS2=21
MVC 485(5,13),499(13) TS2=21 TS2=35
BC 8,1884(0,11) GN=19(000B44)
OI 489(13),X'01' TS2=25
EQU *
DP 464(16,13),483(7,13) TS2=0 TS2=19
ZAP 504(10,13),466(7,13) TS2=40 TS2=2
OI 513(13),X'0F' TS2=49
MVC 496(3,13),42(12) TS2=32 SYSLIT AT
+42
MVC 499(5,13),509(13) TS2=35 TS2=45
CVB 2,496(0,13) TS2=32
MVO 499(5,13),504(5,13) TS2=35 TS2=40
CVB 5,496(0,13) TS2=32
M 4,4(0,12) SYSLIT AT +4
ALR 5,2
BC 12,1940(0,11) GN=20(000B7C)
A 4,0(0,12) SYSLIT AT +0
EQU *
LTR 2,2
BC 11,1950(0,11) GN=21(000B86)
S 4,0(0,12) SYSLIT AT +0
EQU *
STM 4,5,1392(9) QUOTIENT
It appears it is still converting the binary data to packed decimal and
then
doing the calculations.
Frank


|