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.
Yes. pow() returns a double, but you can cast this return to fit in your storage. This "(dataType)" before "Math.pow()" is the castling.
Of course you'll have problems in some occasions, because doing that you are going to lose information (the decimal part). So, if the decimal is needed, is not good castling your code.
For this challenge it was not necessary and have the size as double isn't a problem. So, you don't need to cast anything.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Datatypes
You are viewing a single comment's thread. Return to all comments →
Yes. pow() returns a double, but you can cast this return to fit in your storage. This "(dataType)" before "Math.pow()" is the castling. Of course you'll have problems in some occasions, because doing that you are going to lose information (the decimal part). So, if the decimal is needed, is not good castling your code. For this challenge it was not necessary and have the size as double isn't a problem. So, you don't need to cast anything.