modfd32()、modfd64()、modfd128() - 10 進数浮動小数点値の小数部と整数部の取り出し

標準

標準/拡張機能 C/C++ 依存項目
C/C++ DFP 両方 z/OS® V1.8

形式

#define __STDC_WANT_DEC_FP__
#include <math.h>

_Decimal32  modfd32(_Decimal32 x, _Decimal32 *p); 
_Decimal64  modfd64(_Decimal64 x, _Decimal64 *x);
_Decimal128 modfd128(_Decimal128 x, _Decimal128 *x);
_Decimal32  modf(_Decimal32 x, _Decimal32 *x);   /* C++ only */
_Decimal64  modf(_Decimal64 x, _Decimal64 *x);   /* C++ only */
_Decimal128 modf(_Decimal128 x, _Decimal128 *x); /* C++ only */

機能説明

10 進数浮動小数点値の x を小数と整数の部分に分けます。整数部分は p が指すオブジェクトに保管されます。小数部分と整数部分の両方には、x と 同じ符号が指定されます。
注:
  • IEEE 10 進数浮動小数点を使用するためには、ハードウェアに 10 進数浮動小数点機能 がインストールされている必要があります。
  • これらの関数は、IEEE 10 進数浮動小数点形式で機能します。詳細は 「IEEE 10 進数浮動小数点」を参照してください。

戻り値

lround 関数は、x の符号付き小数部分を戻します。

丸められた値が戻りの型の範囲外の場合、数値結果は未指定です。 x の絶対値が大すぎる場合、範囲エラーが発生します。

⁄* CELEBM24

   This example illustrates the modfd128() function.

   This example breaks the floating-point number -14.876 into
   its fractional and integral components.

*⁄

#define  __STDC_WANT_DEC_FP__
#include <math.h>
#include <stdio.h>

int main(void)
{
  _Decimal128 x, y, d;

  x = -14.876DL;
  y = modfd128(x, &d);

  printf("Number          = %DDf¥n", x);
  printf("Integral part   = %DDf¥n", d);
  printf("Fractional part = %DDf¥n", y);
}

関連情報