---
title: lround
description: "基于当前舍入策略，以long int形式返回舍入值。"
url: https://www.hikunpeng.com/document/detail/zh/kunpenghpcs/hpckit/devg/kunpengaccel_kml_0242.html
sourcePath: /source/zh/kunpenghpcs/hpckit/devg/kunpengaccel_kml_0242.html
indexId: 229e88d44f1558629c597ddedeaebf364c575e7f3a6df5423d9f9798597a185661
---
# lround

基于当前舍入策略，以long int形式返回舍入值。

#### 接口定义

C interface：

long int lroundf(float x);

long int lround(double x);

long int lroundl(long double x);


#### 参数

| 参数名 | 类型 | 描述 | 输入/输出 |
| --- | --- | --- | --- |
| x | 在lroundf中，x是单精度浮点类型。 在lround中，x是双精度浮点类型。 在lroundl中，x是长双精度浮点类型。 | 表示输入数据的浮点值。 | 输入 |


#### 返回值

返回x的舍入值，x ∈ (-inf, inf)。


#### 依赖

C: "km.h"


#### 示例

C interface：
```
// typical usage
printf("lround(0.0) = %ld\n", lround(0.0));
printf("lround(-0.0) = %ld\n", lround(-0.0));
printf("lround(1.0) = %ld\n", lround(1.0));
printf("lround(1.4) = %ld\n", lround(1.4));
printf("lround(1.5) = %ld\n", lround(1.5));
printf("lround(-3.0) = %ld\n", lround(-3.0));
printf("lround(-3.4) = %ld\n", lround(-3.4));
printf("lround(-3.5) = %ld\n", lround(-3.5));
result
/*
* lround(0.0) = 0
* lround(-0.0) = 0
* lround(1.0) = 1
* lround(1.4) = 1
* lround(1.5) = 2
* lround(-3.0) = -3
* lround(-3.4) = -3
* lround(-3.5) = -4
* */
```
