remainder
计算x/y的余数。
接口定义
C interface:
float remainderf(float x, float y);
double remainder(double x, double y);
long double remainderl(long double x, long double y);
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
x |
|
表示输入数据的浮点值。 |
输入 |
y |
|
表示输入数据的浮点值。 |
输入 |
返回值
- 返回x模y的结果。
- 输入x为任意值,y为±0或nan,返回nan。
- 输入x为±0,y不为±0和nan,返回±0。
- 输入x为±∞或者nan,y为任意值,返回nan。
依赖
C: "km.h"
示例
C interface:
// typical usage float x1 = 3.0, x2 = 3.5; float y1 = 4.0, y2 = 4.5; // special handling float e = INFINITY, f = -INFINITY, g = NAN; // print result printf("remainder(3.0, 4.0) = %.15f\n", remainder(x1, y1)); printf("remainder(3.5, 4.5) = %.15f\n", remainder(x2, x2)); printf("remainder(4.5, 4.5) = %.15f\n", remainder(y2, y2)); printf("remainder(INFINITY, 0) = %.15f\n", remainder(e, 0.0f)); printf("remainder(-INFINITY, 3.0) = %.15f\n", remainder(f, x1)); printf("remainder(NAN, 3.0) = %.15f\n", remainder(g, x1)); printf("remainder(NAN, INFINITY) = %.15f\n", remainder(g, e)); /* * remainder(3.0, 4.0) = -1.000000000000000 * remainder(3.5, 4.5) = 0.000000000000000 * remainder(4.5, 4.5) = 0.000000000000000 * remainder(INFINITY, 0) = nan * remainder(-INFINITY, 3.0) = nan * remainder(NAN, 3.0) = nan * remainder(NAN, INFINITY) = nan * */
父主题: 取余函数