名前


drem, dremf, dreml, remainder, remainderf, remainderl - 浮動小数点剰余関数

書式


#include <math.h>

/* C99 版 */ double remainder(double x, double y); float remainderf(float x, float y); long double remainderl(long double x, long double y);

/* 廃止された別名 */ double drem(double x, double y); float dremf(float x, float y); long double dreml(long double x, long double y);

-lm でリンクする。

説明


remainder() 関数は xy で割った余りを計算する。 返り値は x - n * y である。 ここで nx / y の値を最も近い整数に丸めたものである。 この商の端数 (小数部分) が 1/2 の場合、(現在の丸めモードとは関係なく) 最も近い偶数に丸められる。 返り値が 0 の場合、 x の符号を持つ。

drem() 関数はこれと全く同じ動作をする。

返り値


remainder() 関数は、 y が 0 でない場合は、余りを返す。 関数が失敗すると、 errno が設定される。

エラー


EDOM 除数 y が 0 である。

準拠


IEC 60559 に準拠する。 関数 remainder(), remainderf(), remainderl() は C99 に由来する。 関数 drem() は 4.3BSD に由来する。 floatlong double 版の dremf() と dreml() は、Tru64 や glibc2 のようないくつかのシステムに存在する。


"remainder(29.0, 3.0)" を呼び出すと -1 を返す。

関連項目


fmod(3), remquo(3)

openSUSE Logo

コンテンツ