Question: I am trying to convert **uint** to **string** in solidity. Is it possible to convert? if so how can I convert it?

Convertion to base 10 is prefered, but in hexadecimal might also be helpful.

Answer: 
You can convert the uint to bytes32 by using `bytes32 data = bytes32(u)` (uint is same uint256 [How to convert a uint256 type integer into a bytes32?](https://ethereum.stackexchange.com/questions/6498/how-to-convert-a-uint256-type-integer-into-a-bytes32))

Then use [How to convert a bytes32 to string](https://ethereum.stackexchange.com/questions/2519/how-to-convert-a-bytes32-to-string):

```
function bytes32ToString (bytes32 data) returns (string) {
    bytes memory bytesString = new bytes(32);
    for (uint j=0; j<32; j++) {
        byte char = byte(bytes32(uint(data) * 2 ** (8 * j)));
        if (char != 0) {
            bytesString[j] = char;
        }
    }
    return string(bytesString);
}

```
Based on the Oraclize code that Dmitry supplied I made a function to return a `uint` as a `string` in hex format:

```
function uint2hexstr(uint i) internal pure returns (string) {
    if (i == 0) return "0";
    uint j = i;
    uint length;
    while (j != 0) {
        length++;
        j = j >> 4;
    }
    uint mask = 15;
    bytes memory bstr = new bytes(length);
    uint k = length - 1;
    uint numStart = 48;
    uint letterStarn = 65;
    while (i != 0){
        uint curr = (i & mask);
        bstr[k--] = curr > 9 ? byte(55 + curr ) : byte(48 + curr); // 55 = 65 - 10
        i = i >> 4;
    }
    return string(bstr);
}

```

<https://gist.github.com/okwme/f3a35193dc4eb9d1d0db65ccf3eb4034>