From: "Jesús Gabriel y Galán" Date: 2012-09-19T00:08:16+09:00 Subject: Re: FloatDomainError while rounding On Tue, Sep 18, 2012 at 4:23 PM, raj g. wrote: > Yes I have printed @den1 and @den2 but both of them are not same. even > than I face the same problem when I tried to round @answer. > > If I print @answer without rounding I am not getting the error and > getting a Number with long floating point Which is not required for me. OK. Let's simplify. Can you show the minimal piece of code that produces the error. Like: a = ? b = ? coeff = [?,?] num = ? den1 = coeff.first * Math::log10(a) den2 = coeff.last * Math::log10(b) p den1 p den2 answer = num/(den1-den2) p answer answer = (answer*100).round/100.to_f Can you assign some example values to the variables (where I placed the ?) from your program, run this and show us the output? BTW, I'm not sure you need instance variables (variables starting with @). Unless you are actually inside an instance of a class and you need to keep all those values around. Jesus.