ILE C/C++ Programmer's Guide

Suppressing a Run-Time Overflow Exception


C language only
You can use the #pragma nosigtrunc directive to suppress a run-time exception that occurs as a result of overflow. The WebSphere Development Studio: ILE C/C++ Compiler Reference contains information on the#pragma nosigtrunc directive.

The following figure shows how to suppress the run-time exception created when a packed decimal variable overflows on assignment, in a function call, and in an arithmetic operation.

Figure 289. ILE C Source to Suppress a Run-Time Exception



/* This program shows how to suppress a run-time exception when a */
/* packed decimal variable overflows on assignment, in a function call */
/* and in an arithmetic operation. */
#include <decimal.h>
#pragma nosigtrunc /* The directive turns off */
/* SIGFPE which is raised */
/* in the following overflow */
/* situations; no exception */
/* occurs at run time. */
void f(decimal(4,2) a)
{
}
int main(void)
{
decimal(8,4) arg=1234.1234d;
decimal(5,2) op_1=1234567.1234567d; /* Overflow in initialization.*/
decimal(2) op_2;
decimal(20,5) op_3=12.34d;
decimal(15,2) op_4=1234567890.12d;
decimal(6,2) op_5=1234.12d, cast;
decimal(31,2) res;
cast=(decimal(2))op_5; /* Overflow in casting. */
op_2=arg; /* Overflow in assignment. */
f(arg); /* Overflow in function call. */
res=op_3*op_4; /* Overflow in arithmetic */
/* operation. */
}
Note:
No run-time exception is logged in the job log.


[ Top of Page | Previous Page | Next Page | Table of Contents ]