modf,modfl
math.h:インデックス への移動
ヘッダーファイル
math.h
カテゴリ
演算ルーチン
プロトタイプ
double modf(double x, double *ipart);
long double modfl(long double x, long double *ipart);
説明
double または long double を整数部と小数部に分割します。
modf は,double 型 x を 2 つの部分(整数部と小数部)に分割します。modf は,整数部を ipart に格納し,小数部を返します。
modfl は long double バージョンです。long double 引数を受け取り,long double の結果を返します。
戻り値
modf および modfl は,x の小数部を返します。
例
#include <math.h>
#include <stdio.h>
int main(void)
{
double fraction, integer;
double number = 100000.567;
fraction = modf(number, &integer);
printf("The whole and fractional parts of %lf are %lf and %lf\n",
number, integer, fraction);
return 0;
}
移植性
POSIX | Win32 | ANSI C | ANSI C++ | |
---|---|---|---|---|
modf |
+ |
+ |
+ |
+ |
modfl |
+ |
+ |
+ |