Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Problem in remainder with division by 2

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
bdweirdt

New User


Joined: 09 Nov 2006
Posts: 2

PostPosted: Fri Nov 10, 2006 2:51 pm    Post subject: Problem in remainder with division by 2
Reply with quote

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
Back to top
View user's profile Send private message

acp_ajay1

New User


Joined: 13 Mar 2006
Posts: 9

PostPosted: Fri Dec 01, 2006 6:02 pm    Post subject: Re: Problem in remainder with division by 2
Reply with quote

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
Back to top
View user's profile Send private message
cheryala

New User


Joined: 20 Mar 2006
Posts: 46

PostPosted: Mon Mar 26, 2007 9:17 pm    Post subject: Re: Problem in remainder with division by 2
Reply with quote

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
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Problem reading GTF trace output danik56 ABENDS & Debugging 7 Thu Mar 16, 2017 1:02 pm
No new posts ROUNDED Problem with COMPUTE statement shalem COBOL Programming 11 Thu Feb 09, 2017 8:16 pm
No new posts SYMNAMES problem jacobdng DFSORT/ICETOOL 7 Thu Dec 22, 2016 7:47 am
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm
No new posts How to get the remainder and quotient... vnktrrd DFSORT/ICETOOL 2 Mon Oct 31, 2016 10:59 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us