On 18.09.2012 16:51, Alex Gutteridge wrote:
> On 18.09.2012 15:23, 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.
>>
>> Raj
>
> In that case @num must be Infinity (or -Infinity). Possibly @a or @b
> are 0 and so the logarithms you are calling earlier generate
> -Infinity. Either way, as Jesus says the simplest thing is to just
> print out all the intermediate variables until you see what's wrong.

Apologies, I didn't read your second paragraph closely enough. If your 
number is above the Float maximum limit it will also die with this error 
(so not necessarily Infinity, but a large number):

>> (Float::MAX_10_EXP).round
=> 308
>> (1E308).round
=> 
100000000000000001097906362944045541740492309677311846336810682903157585404911491537163328978494688899061249669721172515611590283743140088328307009198146046031271664502933027185697489699588559043338384466165001178426897626212945177628091195786707458122783970171784415105291802893207873272974885715430223118336
>> (1E309).round
(irb):23: warning: Float 1E309 out of range
FloatDomainError: Infinity
         from (irb):23:in `round'
         from (irb):23

-- 
Alex Gutteridge