开发者

Ruby float with double 0

When printing floats, ruby prints 1234.0 with only one 0 after the period. How can I f开发者_C百科orce ruby to print two 0s?


Format strings to the rescue:

>> puts "%.2f" % 1.0 #=> nil
1.00
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜