Skip to content
RED SAG Skills
hardStudy question · answer published in Blockchain interview questions, so no pointssolidityarithmetic

Price that comes out as zero

This function returns 0 for amount = 5. Why, and what is the fix?

// price has 2 decimals: 1 unit = 100
function cost(uint256 amount) public pure returns (uint256) {
    return amount / 10 * 100;
}
Choose one answer

Discussion 0

Join free to post in the discussion.

Related questions