Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Java では、どのように任意の値に丸めますか? 具体的には、.0025 ステップに丸めます。つまり、次のようになります。
0.032611 -> 0.0325
0.034143 -> 0.0350
0.035233 -> 0.0350
0.037777 -> 0.0375
...
アイデアやライブラリはありますか?
y = Math.round(x / 0.0025) * 0.0025
あなたはこれを行うことができます:
double step = 0.0025; double rounded = ((int)(unrounded / step + 0.5)) * step;