Qua*_*ter 25
使用Math.Ceiling:
返回大于或等于指定数字的最小整数
请注意,这适用于双精度数,因此如果您需要浮点数(或整数),则需要进行强制转换.
float num = (float)Math.Ceiling(x/y);
Run Code Online (Sandbox Code Playgroud)
float num = (x/y);
float roundedValue = (float)Math.Round(num, 2);
Run Code Online (Sandbox Code Playgroud)
如果我们使用Math.Round函数,我们可以指定没有要舍入的地方.
| 归档时间: |
|
| 查看次数: |
6442 次 |
| 最近记录: |