From: "Jesús Gabriel y Galán" Date: 2010-03-03T00:37:46+09:00 Subject: Re: Increase significant digits in Float On Tue, Mar 2, 2010 at 4:26 PM, Jason Lillywhite wrote: > If I want to increase my significant digits beyond 15 in a result of a > math expression involving floats, how do I do it? So, for example, I > would like more than 15 sig digits in the result of: > > irb(main):001:0> 4.005 / 7 > => 0.572142857142857 irb is calling inspect on the value of the expression. It's the inspect method the one that truncates to 15 digits when it creates the string. You can create your own strings with greater precision like this: irb(main):001:0> result = 4.005 / 7 => 0.572142857142857 irb(main):002:0> "%.20f" % result => "0.57214285714285717521" irb(main):003:0> "%.30f" % result => "0.572142857142857175212213860505" Check the String#% method: http://ruby-doc.org/core/classes/String.html#M000770 and the Kernel#sprintf method: http://ruby-doc.org/core/classes/Kernel.html#M005962 Jesus.