Q:

Sprintf in Ruby

Sort of a quick question.  I'm writing:
puts "%.3f %.4f %.5f" % [3.998877, 3.998877, 3.998877]

and get the following output:
3.999 3.9989 3.99888

sprintf simply rounds the numbers.  How do I restrict that rounding? 

A:

>> 3.998877.to_s[/^\d+\.\d{3}/].to_f
=> 3.998
>> 3.998877.to_s[/^\d+\.\d{4}/].to_f
=> 3.9988

