Prevent FloatDomainError NaN

Viewed 1803

In this calculation:

months = (saved_cents / spend_cents).to_f.floor

I get the following error:

FloatDomainError: NaN

I think saved_cents and spend_cents are floats, that's why I don't understand why I get this error.

What could be the reason for this error? And how can I fix it?

1 Answers
Related