我需要一个简单的浮点舍入函数,因此:
double round(double);
round(0.1) = 0
round(-0.1) = 0
round(-0.9) = -1
Run Code Online (Sandbox Code Playgroud)
我能找到ceil()和floor()在math.h中-但不是round().
它是以另一个名称存在于标准C++库中,还是缺少?
当我在Visual Studio 2008立即窗口中键入它时:
? .9 - .8999999999999995
它给了我这个答案:
0.00000000000000055511151231257827
文档说双精度具有15-16位精度,但是它给出了32位精度的结果.所有额外的精度来自何处?