该函数使用当前舍入模式将给定值舍入为最接近的整数。当前的舍入模式由fesetround()确定。
例如: strong>
rint(7.9) = 8; if, fesetround(FE_DOWNWARD) then, rint(7.9) = 7;
句法
Suppose a number x. 句法 would be:
return_type rint(data_type x);
Note: The return_type can be float, double or long double.
参数
x strong>:可以是float或double的值。
返回值
它返回x的舍入值。
例子1
让我们看一个简单的例子。
#include
#include
#include
using namespace std;
int main()
{
float x=9.9;
std::cout 输出 strong>:
Value of x is :9.9 Rounding to nearest,value is :10 Rounding to upward,value is :10 Rounding to downward,value is :9