84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
我想对一个数值做以下类似的取整,如:
4001 取整到 10000 5010 取整到 10000 100001 取整到 20000
依次类推,请问有什么好的方法吗?
补充:我想将一个不是很规则的值取一个比它大的规则值。
走同样的路,发现不同的人生
ruby def ten_thouusand_ceil(n) (n.fp 10000).ceil * 10000 end
ruby
def ten_thouusand_ceil(n) (n.fp 10000).ceil * 10000 end
2.1.5 :015 > ten_thouusand_ceil 4001 => 10000 2.1.5 :016 > ten_thouusand_ceil 5010 => 10000 2.1.5 :017 > ten_thouusand_ceil 10001 => 20000
It can be like this
def get_num(n) while j ||= 0 return 10**j if n <= 10**j j = j + 1 end end
It can be like this