std::modf
来自cppreference.com
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
在头文件 <cmath> 中定义
|
||
float modf( float x, float* iptr ); |
||
double modf( double x, double* iptr ); |
||
long double modf( long double x, long double* iptr ); |
||
分解浮点值
x
整数和小数部分,每个部分具有相同类型和符号x
。 (浮点格式)的组成部分存储在指向的对象的iptr
.原文:
Decomposes given floating point value
x
into integral and fractional parts, each having the same type and sign as x
. The integral part (in floating-point format) is stored in the object pointed to by iptr
.目录 |
[编辑] 参数
arg | - | 浮点值
|
iptr | - | 指针浮点值来存储的组成部分
原文: pointer to floating point value to store the integral part to |
[编辑] 返回值
的小数部分与相同的符号
x
x
。不可分割的一部分投入指向的值iptr
.原文:
The fractional part of
x
with the same sign as x
. The integral part is put into the value pointed to by iptr
.[编辑] 示例
#include <iostream> #include <cmath> int main() { double f = 123.45; double f3; double f2 = std::modf(f, &f3); std::cout << "Given the number " << f << ", " << "modf() makes " << f3 << " and " << f2 << '\n'; f = -3.21; f2 = std::modf(f, &f3); std::cout << "Given the number " << f << ", " << "modf() makes " << f3 << " and " << f2 << '\n'; }
输出:
Given the number 123.45, modf() makes 123 and 0.45 Given the number -3.21, modf() makes -3 and -0.21
[编辑] 另请参阅
(C++11) |
最接近的整数的幅值比不大于给定值 原文: nearest integer not greater in magnitude than the given value (函数) |