C++ Math lrint()

2024年8月30日 | 阅读 1 分钟

此函数使用当前的舍入模式对给定值进行四舍五入,并返回 long int 类型的值。

语法

假设一个数是 'x'。语法是

参数

x:可以是 float、double 或 long double 类型的值。

返回值

它返回 x 的舍入值,返回值的类型为 long int。

示例 1

让我们看一个简单的例子。

输出

Enter the value which you want to round : 7.8

Name of the methods are :
1. Rounding downwards
2. Rounding upwards
3. Rounding towards zero
4. Rounding to the nearest
Enter the number of rounding method : 1

Rounding downwards,value is :7

下一主题C++ 数学函数