llround(x)函数详解

首页 / C++入门教程 / llround(x)函数详解

此函数用于舍入给定值并将其转换为long long整数。

llround - 语法

假设数字是“ x”。语法为:

long long int llround(data_type x);

llround - 参数

x :可以是double或float的值。

llround - 返回值

它返回x的舍入值。该函数的返回类型是long long整数。

llround - 例子1

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

链接:https://www.learnfk.comhttps://www.learnfk.com/c++/cpp-math-llround-function.html

来源:LearnFk无涯教程网

#include <iostream>  
#include<math.h>  
using namespace std;  
int main()  
{  
    float x=50.8;  
    std::cout <<"The value of x is :" <<x<< std::endl;  
    std::cout << "The rounded value of x is :"<<llround(x) << std::endl;  
    return 0;  
}  

输出:

The value of x is :50.8
The rounded value of x is :51

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

从0开始学架构 -〔李运华〕

摄影入门课 -〔小麥〕

后端存储实战课 -〔李玥〕

etcd实战课 -〔唐聪〕

跟着高手学复盘 -〔张鹏〕

基于人因的用户体验设计课 -〔刘石〕

玩转Vue 3全家桶 -〔大圣〕

郭东白的架构课 -〔郭东白〕

徐昊 · TDD项目实战70讲 -〔徐昊〕

好记忆不如烂笔头。留下您的足迹吧 :)