I'm using an oraclize contract and would like to convert the string result to an integer, but somehow keep track of the decimal places (like show multiplied by 1000).
Say for instance the result is "290.025", I would like to get 290025 as the int. Here is the oraclize call back code that doesn't work:

function __callback(bytes32 _oraclizeID, string _result) {
      require(msg.sender == oraclize_cbAddress());
      Value = mul(parseInt(_result),1000);

The problem here is that parseInt (an oraclize function) drops the decimal places. So how do I convert string to int and keep the decimal places for multiplication?

1 Answer 1


Thomas from Oraclize here.

parseInt takes an optional second argument to do exactly that!

To be more specific, parseInt("290.025", 3) will return 290025.

I hope this helps!

  • its like you guys have done this before...thanks for the quick response
    – thefett
    Sep 26, 2017 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.