Why doesn't the write variable = 0.22?

Hi all,

This question is outside of the course from codecademy but is something I’m struggling with that I was hoping this awesome community could help with.

When I puts write (variable below it gives me 0) I thought it should be 0.22 as 22/100 = 0.22

number = 22
left = number
write = left/100 
puts write # output is 0
left = left - write*100

Can anyone explain why it is giving 0?

1 Like

Hi there, welcome to the forums! :tada:

You’re doing integer division (which will always return an integer). If you add a .0 to one of the numbers it should make it float division and give you what you want.