Alex Gutteridge wrote in post #1076502:
> On 18.09.2012 16:51, Alex Gutteridge wrote:
>>> 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

Thanks for the explanation. So How can we avoid this problem? Is there
any solution for this to avoid this FloatDoaminError?

-- 
Posted via http://www.ruby-forum.com/.