-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Description
parseInt wasn't working for me with 0.8.0, so I modified a bit. This worked for me if you are interested in updating the library:
/**
* Parse Int
*
* Converts an ASCII string value into an uint as long as the string
* its self is a valid unsigned integer
*
* @param _value The ASCII string to be converted to an unsigned integer
* @return _ret The unsigned value of the ASCII string
*/
function parseInt(string memory _value) public view returns (uint256 _ret) {
bytes memory _bytesValue = bytes(_value);
uint256 j = 1;
uint256 i = _bytesValue.length-1;
while(i >= 0) {
assert(uint8(_bytesValue[i]) >= 48 && uint8(_bytesValue[i]) <= 57);
_ret += (uint8(_bytesValue[i]) - 48)*j;
j*=10;
if(i > 0){i--;}else{break;}
}
}
Metadata
Metadata
Assignees
Labels
No labels