C ++,舍入数字。 2.5 => 2 || 2.5 => 3 [英] C++, rounding numbers. 2.5 => 2 || 2.5 => 3
本文介绍了C ++,舍入数字。 2.5 => 2 || 2.5 => 3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我通过舍入数字来解决问题。
in matlab我们有一些默认函数来舍入如下数字,
ceil(2.5)= 3;
floor(2.5)= 2;
我在C ++中找不到任何可以做的事情。有人可以帮我吗?
我正在使用visual studio 2010.
谢谢,
Hi,
I''m having a problem by rounding numbers.
in matlab we have some default functions to round numbers as below,
ceil( 2.5 ) = 3;
floor( 2.5 ) = 2;
I didn''t find anything to do these in C++. Can someone help me with that?
I''m using visual studio 2010.
thanks,
推荐答案
C ++中也有ceil和floor函数。包括标题math.h。
There are ceil and floor functions in C++ as well. Include the header math.h.
这篇关于C ++,舍入数字。 2.5 => 2 || 2.5 => 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文