remove trailing zeros from currency and qty

here's one way:

def fix_qty(qty)     if qty.to_i == qty         return "%i" % qty     else         return "%.3f" % qty     end end

def fix_price(price)     return "%.2f" % price end

qty = [1, 2.0, 3.00, 4.000, 5.001, 6.010, 7.100] price = [1, 2.0, 3.00, 4.001, 5.987, 6.010, 7.100]

qty.each {|q| puts fix_qty(q)} price.each {|p| puts fix_price(p)}