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 21 of 53 Topic 4077 of 4195
Post > Topic >>

Re: Decimal versus binary arithmetic was Re: J4 -

by "Frank Swarbrick" <Frank.Swarbrick@[EMAIL PROTECTED] > Apr 3, 2008 at 06:42 PM

>>> 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
 




 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 Fri Jul 25 22:59:32 CDT 2008.