0

I'm having a hard time on thinking what should I do with this problem. I'm dividing the two numbers and expecting a non-whole number answer. Meaning to say it should be on decimal format. But unfortunately it answers a whole number. example: 5 / 2 = 2

 s.apts =  sum_pts.to_f / sum_game.to_f
ana
  • 603
  • 6
  • 17

2 Answers2

1

You just need to tell Ruby you are doing non-integer division, by writing the problem as "5.0 / 2.0"

See:

Why is division in Ruby returning an integer instead of decimal value?

Community
  • 1
  • 1
Dmitri
  • 2,658
  • 2
  • 25
  • 41
0

Try this:

a = 5.0
b = 2.0
puts a / b
taintedzodiac
  • 2,658
  • 1
  • 18
  • 16