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! While you're at it, check out some resources Treehouse students have shared here.
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 trialCaleb Kleveter
Treehouse Moderator 37,862 PointsDecimals.
I noticed in my browsing of ruby that if I divide 7 by 3 I get a whole number, not a decimal. How do I get a decimal in division?
2 Answers
Joshua Shroy
9,943 PointsHi Caleb,
You can divide the number into a decimal by adding one like so: 7.0 / 3
Or you can convert the whole number into a floating point using the .to_f
method as shown: 7.to_f / 3
.
Caleb Kleveter
Treehouse Moderator 37,862 PointsThanks Joshua.