This project is archived and is in readonly mode.
Coerce 0 Average Calculation To Float
-
josh
- State changed from new to resolved
- Assigned user set to josh
-
Repository
(from [a7f920f674d234f281d2491ebe6d74710a79e663]) If average value from DB is 0, make sure to convert it to a 0.0 float before calling #to_d on it [#1346 Coerce 0 Average Calculation To Float state:resolved]
Signed-off-by: Joshua Peek josh@joshpeek.com http://github.com/rails/rails/co...
-
Ken Collins
Wow! Thanks alot! :)
-
Tarmo Tänav
- State changed from resolved to open
What's the point of using BigDecimal at all if we're first converting to float?, the bigdecimal is certainly not going to be any more precise than the float it is made from.
Seems to me that the special case should only be used if the value actually is 0, in which case to_f wouldn't really be needed, one could just use: value && (value == 0 ? 0.0.to_d : value.to_d)
-
Ken Collins
That looks just fine to me. I'll put together another patch.
-
josh
- Milestone cleared.
-
Repository
- State changed from open to resolved
(from [335a31524055c7dd79618ea79b3c18d827e25d3d]) Add simple case when DB calculations returns 0 instead of 0.0 [#1346 Coerce 0 Average Calculation To Float state:resolved] http://github.com/rails/rails/co...
-
Ken Collins
Thanks again! My Monday was crushed with bugs from co-workers. Cheers!
