From: Marnen Laibow-Koser Date: 2009-11-01T03:59:55+09:00 Subject: Re: Really small numbers in ruby coming as zero!? Alex Young wrote: > Mahadev Ittina wrote: >> # This is where I am having my problem >> K = ((M) / (b*(d**2)*fck)).to_f > > K = M.to_f / (b*(d**2)*fck) > > In your code, you're dividing an integer by an integer, so Ruby makes it > an integer division. If you make either the numerator or denominator a > float, you'll get a float result. But don't use floats for math, because of the imprecision inherent in the format. For math, stick to integers or BigDecimal. > > -- > Alex Best, -- Marnen Laibow-Koser http://www.marnen.org marnen@marnen.org -- Posted via http://www.ruby-forum.com/.