IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Zerodivide raised when divisor is 0.01


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
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
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: 8569
Location: Dubuque, Iowa, USA

PostPosted: Wed May 11, 2016 12:46 am
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: 1788
Location: Bloomington, IL

PostPosted: Wed May 11, 2016 1:22 am
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: 8569
Location: Dubuque, Iowa, USA

PostPosted: Wed May 11, 2016 1:47 am
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

Global Moderator


Joined: 21 Sep 2010
Posts: 2573
Location: NYC,USA

PostPosted: Wed May 11, 2016 2:10 am
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
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
Reply with quote

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

Senior Member


Joined: 07 Feb 2009
Posts: 1241
Location: Vilnius, Lithuania

PostPosted: Wed May 11, 2016 12:58 pm
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7311
Location: Inside the Matrix

PostPosted: Wed May 11, 2016 10:36 pm
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: 1788
Location: Bloomington, IL

PostPosted: Wed May 11, 2016 11:00 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Any idea about how to solve 3022 aben... IMS DB/DC 3
No new posts Error: IBM0141S ONCODE=41, TRANSMIT c... ABENDS & Debugging 2
Search our Forums:

Back to Top