Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
Why does ruby do this?
irb(main):001:0> a = 1.1
irb(main):002:0> b = 2.2
irb(main):003:0> a + b
why does it add that three in the end even tho 1.1 + 2.2 = 3.3
Jason AndersTreehouse Moderator 145,855 Points
I don't fully understand the 'math' behind this, but it's not just Ruby. Any compiled programming language will have this happen with floating point numbers. It has to do with how machine language (binary) deals with the decimal number.
If your really curious, you can search for something along the lines of "problems with floating point numbers in code"