Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


not modulo but something else

for the value 7.6666, we called the int and it returned 7. The modulo returned 3. but say you only wanted to return .66666 part? what would I enter?

For example, 23/12 = 1.91666667 but I just want to return the .91666667? handy when working with degrees minutes and seconds.

1 Answer

Just take whatever answer you have and find modulo of 1:

7.6666 % 1 = .6666

1.91666667 % 1 = .91666667

There would be some rounding errors, for instance 1.91666667 % 1 would actually give you .9166666699999999 but I this is probably what you're looking for.