use*_*267 3 c c++ objective-c rounding floor
我什至找不到与此相关的搜索关键字。请考虑以下代码:
float inputValue = getInputValue();
float resultValue;
if (inputValue < 0.1f) {
resultValue = 0.01f;
}
else if (inputValue < 1.0f) {
resultValue = 0.1f;
}
else if (inputValue < 10.0f) {
resultValue = 1.0f;
}
else {
resultValue = 10.0f;
}
Run Code Online (Sandbox Code Playgroud)
等等。必须有一种更优雅的方法来执行此操作。我猜该解决方案很简单,但是我尝试找到2小时的方法,然后阅读有关圆形,天花板,地板...找不到的方法。
有人知道吗?
| 归档时间: |
|
| 查看次数: |
2217 次 |
| 最近记录: |