We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
And to answer your question: if you need the decimal part, then of course you shouldn't convert it, just as you said when you convert it to int the decimal part is lost. On normal basis this lost of precision isn't something that matters much, but you need to be aware of it, aspeccialy, in conditional statements. Now, when you really need great precision, for example in banks and accounting then there are classes for it.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Python: Division
You are viewing a single comment's thread. Return to all comments →
And to answer your question: if you need the decimal part, then of course you shouldn't convert it, just as you said when you convert it to int the decimal part is lost. On normal basis this lost of precision isn't something that matters much, but you need to be aware of it, aspeccialy, in conditional statements. Now, when you really need great precision, for example in banks and accounting then there are classes for it.