c++四舍五入函数

软件和网站开发以及相关技术探讨
回复
zzh.org
帖子: 46
注册时间: 2007-08-14 14:33

c++四舍五入函数

#1

帖子 zzh.org » 2007-10-10 19:23

如题,c++有没有四舍五入函数呢?在GOOGLE中找了N天,没找到。谢谢
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

#2

帖子 eexpress » 2007-10-10 19:34

都是+0.5,取整数吧。
● 鸣学
头像
BigSnake.NET
帖子: 12522
注册时间: 2006-07-02 11:16
来自: 廣州
联系:

#3

帖子 BigSnake.NET » 2007-10-10 19:34

round ?
^_^ ~~~
要理解递归,首先要理解递归。

地球人都知道,理论上,理论跟实际是没有差别的,但实际上,理论跟实际的差别是相当大滴。
头像
tipfoo
帖子: 303
注册时间: 2007-07-12 16:30
来自: 桂林

#4

帖子 tipfoo » 2007-10-10 21:20

Name
round, lround, llround

Interface

代码: 全选

#include <math.h>
 	double	round (double x)
 	long	roundl (long double x)
 	float	roundf (float x)
 	long	lround (double x)
 	long	lroundl (long double x)
 	long	lroundf (float x)
 	long	llround (double x)
 	long	llroundl (long double x)
 	long	llroundf (float x)
Description
The round functions return the integral value nearest to x rounding half-way cases away from zero, regardless of the current rounding direction.

The lround and llround functions return the integral value nearest to x (rounding half-way cases away from zero, regardless of the current rounding direction) in the return formats specified. If the rounded value is outside the range of the return type, the numeric result is unspecified and the invalid floating-point exception is raised. A range error may occur if the magnitude of x is too large.

Special Values
round ( �0 ) returns �0.

round ( �infinity ) returns �infinity.

The round functions may, but are not required to, raise the inexact floating-point exception for non-integer numeric arguments.

The lround and llround functions need not raise the inexact floating-point exception for non-integer arguments that round to within the range of the return type.

See Also
abs, fabs, ceil, floor
zzh.org
帖子: 46
注册时间: 2007-08-14 14:33

#5

帖子 zzh.org » 2007-10-14 15:26

谢谢
回复