Try multiplying by total_b.to_f
or by 1.0 when calculating the ratio. It automatically converts the type.
total_a = 10
total_b = 5
ratio = total_b.to_f / total_a
# # ratio = 1.0 * total_b/total_a
print ratio
© 2024 OneMinuteCode. All rights reserved.