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
 

 

Zerodivide raised when divisor is 0.01

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

New User


Joined: 17 Jan 2008
Posts: 25
Location: Chennai

PostPosted: Wed May 11, 2016 12:05 am    Post subject: Zerodivide raised when divisor is 0.01
Reply with quote

Dear All,

Strangely, I get a zerodivide error condition raised for the below statement. Can you please confirm if 0.01 is not accepted by the DIVIDE function or if I am missing something.

Code:

DCL A FIXED(15,9) INIT(0);
DCL B FIXED(15,2) INIT(0);
DCL C FIXED(15,2) INIT(0);

B = 10;
C = 0.01;

A = DIVIDE(B,C,15,9);       


It works if C is 0.02.

Thanks,
Soundar
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7914
Location: Bellevue, IA

PostPosted: Wed May 11, 2016 12:46 am    Post subject:
Reply with quote

Look at the binary representation of 0.01 and compare it to your FIXED BIN(15,2).

Also, why did you not just print the values of B and C?
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Wed May 11, 2016 1:22 am    Post subject:
Reply with quote

I believe that you may not be correct, Robert. IIRC, the default base of an arithmetic variable is DECIMAL (although Soundar-kun ought to declare that explicitly, lest some software engineer assigned to maintain the program add a DEFAULT statement that changes that).
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7914
Location: Bellevue, IA

PostPosted: Wed May 11, 2016 1:47 am    Post subject:
Reply with quote

I still wonder why a forum post instead of just printing the value of C to see what it is.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Wed May 11, 2016 2:10 am    Post subject:
Reply with quote

May you want to check the compiler options used.
Back to top
View user's profile Send private message
soundarr

New User


Joined: 17 Jan 2008
Posts: 25
Location: Chennai

PostPosted: Wed May 11, 2016 2:24 am    Post subject:
Reply with quote

B and C are printed as 10 and 0.01 as assigned.
Back to top
View user's profile Send private message
soundarr

New User


Joined: 17 Jan 2008
Posts: 25
Location: Chennai

PostPosted: Wed May 11, 2016 2:29 am    Post subject:
Reply with quote

DEC FIXED(15,2) gives the same result.
Back to top
View user's profile Send private message
prino

Active Member


Joined: 07 Feb 2009
Posts: 985
Location: Oostende, Belgium

PostPosted: Wed May 11, 2016 12:58 pm    Post subject: Re: Zerodivide raised when divisor is 0.01
Reply with quote

soundarr wrote:
Dear All,

Strangely, I get a zerodivide error condition raised for the below statement. Can you please confirm if 0.01 is not accepted by the DIVIDE function or if I am missing something.

Code:

DCL A FIXED(15,9) INIT(0);
DCL B FIXED(15,2) INIT(0);
DCL C FIXED(15,2) INIT(0);

B = 10;
C = 0.01;

A = DIVIDE(B,C,15,9);



It works if C is 0.02.

The above code compiles and executes flawlessly with
  • OS PL/I V2.3.0
  • Enterprise PL/I V3.3
  • Enterprise PL/I V3.5
  • Enterprise PL/I V3.7
  • Enterprise PL/I V3.9
  • Enterprise PL/I V4.3
Ergo conclusio: You're talking utter BS. Your zerodivide occurs somewhere else! The arrogant imbecility of assuming that c=0.01 would cause it is breathtaking.
Back to top
View user's profile Send private message
soundarr

New User


Joined: 17 Jan 2008
Posts: 25
Location: Chennai

PostPosted: Wed May 11, 2016 8:13 pm    Post subject:
Reply with quote

Thanks Prino. My apologies to you and all for giving an example of 10 instead of 10000 which I actually used. Please excuse me.

When I used 10000 for B. It divided 10000 by 0.01 which will be 1000000. But since A is 15,9 which leaves only 6 bytes for whole numbers thus unable to hold the 7 digit result. This results in a decimal divide exception which also raises a zero divide exception causing the confusion.

So, it was not a zero divide actually but the system did raise it.

Regards,
Soundar
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Wed May 11, 2016 10:36 pm    Post subject: Reply to: Zerodivide raised when divisor is 0.01
Reply with quote

Do you mean a Decimal Divide Exception (S0CB)? I'm not aware of an actual "zero divide" exception, perhaps you can tell us the system abend code for that?

If you divide and the result overflows the receiving field, you get S0CB unless it is "handled" in the programming language.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Wed May 11, 2016 11:00 pm    Post subject:
Reply with quote

I think that ZERODIVIDE is a PL/I condition; the environment distinguishes this from other errors that would cause a S0CB abend to occur.
Back to top
View user's profile Send private message
soundarr

New User


Joined: 17 Jan 2008
Posts: 25
Location: Chennai

PostPosted: Wed May 11, 2016 11:52 pm    Post subject:
Reply with quote

SOCB (decimal divide exception) was the abend code, but the statements inside ON ZERODIVIDE section were executed.
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 Error: IBM0141S ONCODE=41, TRANSMIT c... William Thompson ABENDS & Debugging 2 Tue Feb 20, 2007 7:08 pm


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