Open aelmanaa opened 3 years ago
https://github.com/provable-things/ethereum-api/blob/9f34daaa550202c44f48cdee7754245074bde65d/provableAPI_0.6.sol#L1041
Hi
I have few revert issues when I tried to format 1 digit numbers (1 ,2 ,3..Etc) .
uint k = len - 1; --> length is 1 and k is 0
uint k = len - 1;
bstr[k--] = byte(uint8(48 + _i % 10)); underflows as k is unsigned so 0-1 = -1
bstr[k--] = byte(uint8(48 + _i % 10));
suggestion to have something like this. "k" starts with 1 and is decremented before operation
uint k = len ; while (_i != 0) { bstr[--k] = bytes1(uint8(48 + _i % 10)); _i /= 10; } return string(bstr);
https://github.com/provable-things/ethereum-api/blob/9f34daaa550202c44f48cdee7754245074bde65d/provableAPI_0.6.sol#L1041
Hi
I have few revert issues when I tried to format 1 digit numbers (1 ,2 ,3..Etc) .
uint k = len - 1;
--> length is 1 and k is 0bstr[k--] = byte(uint8(48 + _i % 10));
underflows as k is unsigned so 0-1 = -1suggestion to have something like this. "k" starts with 1 and is decremented before operation