Just got a "FloatDomainError" in my app, with the message "NaN" where the server would ordinarily describe the offense. The server error page points me to these lines (well, the first one):
n = ((self.weight * (c.percent)/100) / c.package_weight).to_i
n.times do
The problem seems to be with the .to_i, which is meant to convert what totals to 8.35 into an integer so I can do n.times do.
The problem is, if I take to_i away, I get an error telling me, logically enough, that there's no method "times" for the float 8.35. But I don't get why it's not letting me round off 8.35 to an integer. I've tried .floor too, but I get the FloatDomainError.
Ideas on how to round this off so I can get it to work?
Thanks!
This error means that you tried to convert a NaN value to int. NaN stands for "Not a number". That probably meants that your calculation is flawed and not result in 8.35. Maybe the value of c.package_weight
is zero and you divide with it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With