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.
任何整数在哪里x,我的值约为x.1..x.4。我想将它四舍五入x.5,如果它在上面x.5,比如说x.7或x.8,那么它应该四舍五入(x+1).0。这怎么可能?红宝石有功能吗?
x
x.1..x.4
x.5
x.7
x.8
(x+1).0
使用(v*2).ceil.to_f / 2where v 是你的变量。
(v*2).ceil.to_f / 2