1
contract TypeConversion{

    uint96 data = 5;
    bytes32 b = bytes32(data);

}

It gives error:
Explicit type conversion not allowed from "uint96" to "bytes32".

What will be the better way to convert integers to a string in solidity?

  • What is uint95? – goodvibration Feb 3 at 8:06
  • What will be the better way to convert integers to a string in solidity? - that is a different question than the question in the title. – goodvibration Feb 3 at 8:08
2

Try this:

bytes32 b = bytes32(uint256(data));
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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