Jamie's Blog

Ruby developer. CTO. Swimmer. Always trying to write more

1 / 3 = 0

Yep, that’s right. And I even used a computer to work it out.

I was up til 5 this morning writing a couple of python scripts to trawl through the data from the Reality Mining project @ MIT Media Lab and work out how complete the data was. At 3AM the last thing you need to find out is that Python automatically tries to keep your types consistent. Therefore, 1 / 3 = 0 because integer / integer = integer, whereas 1.0 / 3.0 = 0.33333 (because float / float = float).