MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Fixedoverflow vs Size

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
shashanktg1
Beginner


Joined: 30 Dec 2014
Posts: 1
Topics: 1

PostPosted: Wed Dec 31, 2014 11:40 am    Post subject: Fixedoverflow vs Size Reply with quote

As per IBM manual, the FIXEDOVERFLOW condition differs from the SIZE
condition in that SIZE is raised when a result exceeds the declared size of a variable, while FIXEDOVERFLOW is raised when a result exceeds the maximum allowed by the computer. But below code:

Code:
ON SIZE
  PUT SKIP LIST ('ONSIZE');

DCL A FIXED DEC (01);
DCL B FIXED DEC (01);
DCL C FIXED DEC (01);

A = 8;
B = 3;
C = A * B;


fails with FIXEDOVERFLOW instead of SIZE which is opposite to what is
written in IBM manuals. Can anyone please tell me waht exactly is the
difference in FIXEDOVERLOW and SIZE with example?

Thanks!
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Wed Dec 31, 2014 4:42 pm    Post subject: Reply with quote

shashanktg1,

Isn't fixed DEC defined as FIXED DEC(total-digits, decimal-digits) ?? Either way here is an example showcasing both size and fixedoverflow errors.

Code:

MYPGM: PROC OPTIONS(MAIN);
DCL SYSPRINT FILE STREAM OUTPUT;
DCL(BOOL,ONCODE,ONLOC) BUILTIN; /*BONUS - USING BOOL FUNCTION FOR   */
DCL A BIT(8) INIT('11110000'B); /*EXCLUSIVE OR COULD USE ON CHAR OR */
DCL B BIT(8) INIT('10101010'B); /* NUMERIC DATA                     */
DCL C BIT(8) INIT('00000000'B); /* BOOL BUILTIN does heavy lifting  */
DCL Z BIT(4) INIT('0110'B);     /* THIS IS AN EXCLUSIVE OR          */
DCL (I,J,K) FIXED BIN(15);
DCL VALUE PIC'99999999';
ON ERROR BEGIN; ON ERROR SYSTEM; VALUE = ONCODE;
PUT SKIP EDIT('@'||ONLOC||' OF '||VALUE)(A); END;
PUT SKIP DATA(A,B);
C = A&B; PUT SKIP DATA(C);            /* AND        */
C = A|B; PUT SKIP DATA(C);           /* OR          */
C = BOOL(A,B,Z); PUT SKIP DATA(C);  /* EXCLUSIVE OR */
K=9000;
CALL SIZE_ERROR;
CALL FIXED_OVER_ERROR;
SIZE_ERROR: PROC;
Size is a logical error. Target is too small for result.
ON SIZE BEGIN; PUT SKIP LIST('SIZE ERROR'); END;
I = 32000+32000; /* SIZE ERROR CAUGHT AT COMPLILE TIME */
(SIZE): I = 32000+K; /* FORCE CATCHING SIZE ERROR IN EXECUTION */
PUT DATA(I);
END SIZE_ERROR;
FIXED_OVER_ERROR: PROC;
Overflow is a machine error. The operation cannot be performed.
I = 32000; J = 1000;
K = I**J; /* THIS WILL NOT FIT IN 16 BITS */
PUT DATA(K);
END FIXED_OVER_ERROR;
END MYPGM;
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group