Reputation: 21577
When printing floats, ruby prints 1234.0
with only one 0
after the period. How can I force ruby to print two 0
s?
Upvotes: 8
Views: 6003
Reputation: 66837
Format strings to the rescue:
>> puts "%.2f" % 1.0 #=> nil
1.00
Upvotes: 24