I've got a calculation for example 57 / 30 so the solution will be 1,766666667.. How do i first of all get the 1,766666667 i only get 1 or 1.00 and then how do i round the solution (to be 2)?
我有一个例子57 / 30的计算所以答案是1 766666666。我如何首先得到1,76666666666666667我只得到1或1。00,然后我如何四舍五入得到2 ?
thanks a lot!
谢谢!
1 个解决方案
#1
0
57/30 performs integer division. To obtain a float (or double) result you should make 1 of the operands a floating point value:
执行57/30整数的除法。要获得浮点数(或double)结果,您应该将操作数的1作为浮点值:
result = 57.0/30;
To round result have a look at standard floor
and ceil
functions.
为了获得更全面的结果,我们来看看标准地板和ceil的功能。
#1
0
57/30 performs integer division. To obtain a float (or double) result you should make 1 of the operands a floating point value:
执行57/30整数的除法。要获得浮点数(或double)结果,您应该将操作数的1作为浮点值:
result = 57.0/30;
To round result have a look at standard floor
and ceil
functions.
为了获得更全面的结果,我们来看看标准地板和ceil的功能。