[Ethereum] converting uint256 to string

stringuint256

Any idea for the simplest way to add "degrees" variable into the string like below?
Looking for getString to return "today is 40 degrees outside".

 pragma solidity ^0.5.3;

        uint public degrees= 40;

        function getString() public view returns(string memory){
                string memory a = "today is ";
                string memory b = degrees;
                string memory c = "degrees outside";
                string memory sentence = string(abi.encodePacked(a, b, c));
                return sentence;
        }

Best Answer

oraclize helped

 pragma solidity ^0.5.3;

        uint public degrees= 40;

        function getString() public view returns(string memory){
                string memory a = "today is ";
                string memory b = uint2str(degrees);
                string memory c = "degrees outside";
                string memory sentence = string(abi.encodePacked(a, b, c));
                return sentence;
        }
Related Topic