This is my solidity codes, I am trying to compare the variables passed with different variables. Because float data type is not supported by solidity and function input is default tailed with 18 zeros, I use the timeAmount to multiply 10^18.
function setUriToUpdate(uint256 temperature) public {
uint256 timesAmount = 10 ** 18;
if (temperature < 10 * timesAmount) {
uriToUpdate = METADATA_BELOW;
} else if (temperature > 10 * timesAmount && temperature < 20 * timesAmount) {
uriToUpdate = METADATA_AVERAGE;
} else if (temperature >= 20 * timesAmount && temperature < 50 * timesAmount) {
uriToUpdate = METADATA_ABOVE;
}
}
When I write my unit test in js code, I don't know to pass a variable tailed with 18 zeros.
await nft.connect(deployer).setUriToUpdate(15 * 10 ** 18)
The error is:
Error: overflow [ See: https://links.ethers.org/v5-errors-NUMERIC_FAULT-overflow ] (fault="overflow", operation="BigNumber.from", value=15000000000000000000, code=NUMERIC_FAULT, version=bignumber/5.7.0)
Can anyone tell me how to pass big number to the function?
thanks in advance!