相关疑难解决方法(0)

将浮点数舍入到预定义点的常规网格

我想将浮点数舍入到给定的精度,例如:

0.051 i want to convert it to
0.1

0.049 i want to convert it to
0.0

0.56 i want to convert it to
0.6

0.54 i want to convert it to
0.5
Run Code Online (Sandbox Code Playgroud)

我无法更好地解释它,但其原因是将点位置(如0.131f,0.432f)转换为网格中瓷砖的位置(如0.1f,0.4f).

c++ rounding

27
推荐指数
4
解决办法
6万
查看次数

标签 统计

c++ ×1

rounding ×1