実行時オーバーフロー例外の抑制

C 言語のみ
#pragma nosigtrunc ディレクティブを使用すると、オーバーフローの結果として発生する実行時例外を抑制することができます。 「ILE C/C++ コンパイラー参照」には、#pragma nosigtrunc ディレクティブに関する説明があります。

以下の図は、代入、関数呼び出し、および算術演算でパック 10 進変数がオーバーフローすると作成される実行時例外を抑制する方法を示しています。
図 1. 実行時例外を抑制するための ILE C ソース
/* This program shows how to suppress a runtime 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 runtime.         */
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.                 */
}
注: 実行時例外はジョブ・ログに記録されません。