>>405 Ruby sprintfフォーマット使わない場合

[12345,
12.34,
1.234,
0.0123].each{|i|p i.floor(1-Math.log10(i).floor)}
#=>
12000
12
1.2
0.012