Check division is integer or float solidity
up vote
2
down vote
favorite
Suppose i have a contract with decimals and total Supply as follow.
How can i check if tokenAmountInWei pass in is integer value in form of ether.
decimals = 18
totalSupply = 1000000
function someFunction(uint tokenAmountInWei) {
// check if tokenAmountInWei convert to ether is integer value
}
solidity erc-20
New contributor
add a comment |
up vote
2
down vote
favorite
Suppose i have a contract with decimals and total Supply as follow.
How can i check if tokenAmountInWei pass in is integer value in form of ether.
decimals = 18
totalSupply = 1000000
function someFunction(uint tokenAmountInWei) {
// check if tokenAmountInWei convert to ether is integer value
}
solidity erc-20
New contributor
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
Suppose i have a contract with decimals and total Supply as follow.
How can i check if tokenAmountInWei pass in is integer value in form of ether.
decimals = 18
totalSupply = 1000000
function someFunction(uint tokenAmountInWei) {
// check if tokenAmountInWei convert to ether is integer value
}
solidity erc-20
New contributor
Suppose i have a contract with decimals and total Supply as follow.
How can i check if tokenAmountInWei pass in is integer value in form of ether.
decimals = 18
totalSupply = 1000000
function someFunction(uint tokenAmountInWei) {
// check if tokenAmountInWei convert to ether is integer value
}
solidity erc-20
solidity erc-20
New contributor
New contributor
New contributor
asked yesterday
vincentsty
1324
1324
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
5
down vote
accepted
This should work:
pragma solidity ^0.4.24;
contract Test {
function checkIntegerETH(uint a) public pure returns (bool) {
return (a % 1 ether == 0);
}
}
Here we are basically confirming that a
has no remainder when being divided by 1018 (1 ether
).
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
This should work:
pragma solidity ^0.4.24;
contract Test {
function checkIntegerETH(uint a) public pure returns (bool) {
return (a % 1 ether == 0);
}
}
Here we are basically confirming that a
has no remainder when being divided by 1018 (1 ether
).
add a comment |
up vote
5
down vote
accepted
This should work:
pragma solidity ^0.4.24;
contract Test {
function checkIntegerETH(uint a) public pure returns (bool) {
return (a % 1 ether == 0);
}
}
Here we are basically confirming that a
has no remainder when being divided by 1018 (1 ether
).
add a comment |
up vote
5
down vote
accepted
up vote
5
down vote
accepted
This should work:
pragma solidity ^0.4.24;
contract Test {
function checkIntegerETH(uint a) public pure returns (bool) {
return (a % 1 ether == 0);
}
}
Here we are basically confirming that a
has no remainder when being divided by 1018 (1 ether
).
This should work:
pragma solidity ^0.4.24;
contract Test {
function checkIntegerETH(uint a) public pure returns (bool) {
return (a % 1 ether == 0);
}
}
Here we are basically confirming that a
has no remainder when being divided by 1018 (1 ether
).
answered yesterday
Shawn Tabrizi
3,8342521
3,8342521
add a comment |
add a comment |
vincentsty is a new contributor. Be nice, and check out our Code of Conduct.
vincentsty is a new contributor. Be nice, and check out our Code of Conduct.
vincentsty is a new contributor. Be nice, and check out our Code of Conduct.
vincentsty is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fethereum.stackexchange.com%2fquestions%2f62448%2fcheck-division-is-integer-or-float-solidity%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown