lrint(), lrintf(), lrintl() and llrint(), llrintf(), llrintl() -- Round the argument to the nearest
来源:互联网 发布:网络教育毕业证分几种 编辑:程序博客网 时间:2024/06/06 05:31
lrint(), lrintf(), lrintl() and llrint(), llrintf(), llrintl() -- Round the argument to the nearest integer
z/OS V1R12.0 XL C/C++ Run-Time Library Reference
SA22-7821-12
Standards / Extensions C or C++ Dependencies
z/OS V1R12.0 XL C/C++ Run-Time Library Reference
SA22-7821-12
Standards
C99
Single UNIX® Specification, Version 3
C++ TR1 C99
both z/OS V1R7Single UNIX® Specification, Version 3
C++ TR1 C99
Format
#define _ISOC99_SOURCE#include <math.h>long int lrint(double x);long int lrintf(float x);long int lrintl(long double x);long long int llrint(double x);long long int llrintf(float x);long long int llrintl(long double x);
C++ TR1 C99:
#define _TR1_C99#include <math.h>long int lrint(float x);long int lrint(long double x);long long int llrint(float x);long long int llrint(long double x);
Compile requirement:
The llrint() family of functions requires the long long data type. See z/OS XL C/C++ Language Reference for information on how to make long long available.
General description
The lrint() and llrint() families of functions round their argument to the nearest integer value according to the current rounding mode. If the rounded value is outside the range of the return type, the numeric result is unspecified. A range error may occur if the magnitude of x is too large.
Note:
The following table shows the viable formats for these functions. See IEEE binary floating-point for more information about IEEE Binary Floating-Point.Function Hex IEEE lrintXXlrintfXXlrintlXXllrintXXllrintfXXllrintlXX
Returned value
If successful, they return the rounded integer value. If the correct value is positive or negative and too large to represent as a long (lrint() family) or long long (llrint() family), a domain error will occur and an unspecified value is returned.
Example
/* * This program illustrates the use of lrint() function * * Note: To get the output shown in this information, this program * should be compiled using FLOAT(IEEE) * */#define _ISOC99_SOURCE#include <math.h>#include <stdio.h>#include <_Ieee754.h> /* save/get fpc functions */char *RoundStr (_FP_rmode_t rm_type) { char *RndStr="undetermined"; switch (rm_type) { case (_RMODE_RN): RndStr="round to nearest"; break; case (_RMODE_RZ): RndStr="round toward zero"; break; case (_RMODE_RP): RndStr="round toward +infinity "; break; case (_RMODE_RM): RndStr="round toward -infinity "; break; } return (RndStr);}void main() { _FP_fpcreg_t save_rmode, current_rmode; long int rnd2nearest; double number=500.99; printf("Illustrates the lrint() function\n"); __fpc_rd(¤t_rmode); /* get current rounding mode */ rnd2nearest = lrint(number); printf ("When rounding direction is %s:\n lrint(%.2f) = %li\n",RoundStr(current_rmode.rmode), number, rnd2nearest); save_rmode.rmode = _RMODE_RZ; __fpc_sm(save_rmode.rmode); /* set rounding mode to round to zero */ rnd2nearest = lrint(number); printf ("When rounding direction is %s:\n lrint(%.2f) = %li\n",RoundStr(save_rmode.rmode), number, rnd2nearest);}OutputIllustrates the lrint() functionWhen rounding direction is round to nearest: lrint(500.99) = 501When rounding direction is round toward zero: lrint(500.99) = 500
Related information
- math.h
- ceil(), ceilf(), ceill() — Round up to integral value
- floor(), floorf(), floorl() — Round down to integral value
- llround(), llroundf(), llroundl() -- Round to the nearest integer
- lround(), lroundf(), lroundl() — Round a decimal floating-point number to its nearest integer
- nearbyint(), nearbyintf(), nearbyintl() -- Round the argument to the nearest integer
- rint(), rintf(), rintl() — Round to nearest integral value
- round(), roundf(), roundl() -- Round to the nearest integer
- trunc(), truncf(), truncl() — Truncate an integer value
http://www.cplusplus.com/reference/cmath/lrint/
- lrint(), lrintf(), lrintl() and llrint(), llrintf(), llrintl() -- Round the argument to the nearest
- Top K nearest points to the origin
- 【收藏】"Blink" and the Tall CEO Argument
- The expected argument types are (java.util.Map) but the supplied types were(java.lang.String) and converted to (null).
- The nearest taller cow
- The Nearest Same Chocolate
- Paper摘记:Bagging and Boosting for the Nearest Mean Classifier:
- Understanding the Difference Between an Argument and a Parameter
- The argument is invalid.
- How to get a type in C++ when its template argument is the argument
- 选手“晋级” advance to the next round
- IEEE 754 round-to-nearest-even
- 警告The argument of type String[] should explicitly be cast to Object[] for the invocation of the vara
- 论文读书笔记-on the difficulty of nearest neighbor search[and so on]
- USING SAS TO FIND THE BEST K FOR K-NEAREST-NEIGHBOR CLASSIFICATION
- recommended to choose the nearest exit highway toll station in advance.
- How to get the nearest parent node given a text node in jQuery?
- Codeforces Round #435 A. Mahmoud and Ehab and the MEX
- c程序内存分布
- ubuntu12.04 配置mysql5.5utf-8编码
- C++强制类型转换 static_cast; dynamic_cast; reinterpret_cast; const_cast
- Java基础 之软引用、弱引用、虚引用
- 原码,反码,补码,移码计算规则
- lrint(), lrintf(), lrintl() and llrint(), llrintf(), llrintl() -- Round the argument to the nearest
- ubuntu设置
- 使用C语言实现二维,三维绘图算法(2)-解析曲面的显示
- 深入研究java.lang.ThreadLocal类
- Linux常用命令笔记-Shell
- mysql常用命令(基于ubuntu)
- linux根文件系统
- PHP中写SQL语句注意
- IOS6 学习笔记(2)——视图的生命周期