It's not necessary to send your result to a float (.to_f). That method interprets parts of strings to float numbers, but you've already done mathematical operations on the objects here before calling .to_f, so they're probably already numbers :)