Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
bdweirdt

New User

Joined: 09 Nov 2006
Posts: 2

 Posted: Fri Nov 10, 2006 2:51 pm    Post subject: Problem in remainder with division by 2 Hello I'm new at PL/I and have written a program. A simple X / 2 is doing some weird things. An example X dec fixed(15) Y dec fixed(15,1) Y = X/2 now the problem is that this simple division is giving some weird results: IF X = 1, Y = 0,0 (I would expect 0,5) It would be a lot easier to use the builtin function REM, but I can't get it to work. When I declare REM as al builtin, it complains that it's not a builtin function. Thx in advance, Bart

acp_ajay1

New User

Joined: 13 Mar 2006
Posts: 9

 Posted: Fri Dec 01, 2006 6:02 pm    Post subject: Re: Problem in remainder with division by 2 Hello Bart, Please declare the variables as given below DCL X FIXED BIN(15,0) DCL Y FIXED BIN(15,1) Try it out.....It definitely works...Do let me know if u have any further problems with this..... Regards, Ajay
cheryala

New User

Joined: 20 Mar 2006
Posts: 46

 Posted: Mon Mar 26, 2007 9:17 pm    Post subject: Re: Problem in remainder with division by 2 hello bdweirdt, When you use y=x/2 ; here compiler assumes the precision of numeric constant to be fixed dec(1,0). When the division is evaluated the result will have the precision of (15,0) . This result is assigned to the target variable Y. For more information on how the precision is calculated refere IBM manual .. Regards, Raj
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Having a problem FTP'ng to the MF pahiker All Other Mainframe Topics 2 Fri Nov 10, 2017 8:20 pm Extend the decimal values in DIVISION Balaryan DFSORT/ICETOOL 3 Thu Oct 05, 2017 4:05 pm LMINIT problem - not finding DDNAME Danielle.Filteau CLIST & REXX 7 Tue Sep 19, 2017 9:57 pm Problem commiting to DB2 from IMS MPP Ole Soerensen IMS DB/DC 2 Wed Jul 26, 2017 5:19 pm Strings with double quotes having pro... raja Arumugam All Other Mainframe Topics 11 Thu Mar 30, 2017 10:34 am

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us