//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f. pragma solidity ^0.4.17; contract TestBits { function spawnPassTo() public pure returns(bytes32){ uint256[] memory tickets = new uint256[](1); // we test uint256 value 26322820181848127205119429488744061657188852288741917040354512141634951523633: // which in hex format is: // 0x3a32303138313133303030303030302b30383030000100005649500000412d31 tickets[0] = 26322820181848127205119429488744061657188852288741917040354512141634951523633; encodeMessageSpawnable(tickets); // after calling encodeMessageSpawnable // tickets has been changed, now the value become // 0x3100000000000000000000000000000000000000000000000000000000000000 // only contains the last byte // it looks this local variable has been changed even out of the scope in another function call return bytes32(tickets[0]); } function encodeMessageSpawnable(uint256[] tickets) public pure returns(bytes){ bytes memory message = new bytes(tickets.length * 32); for (uint i = 0; i < tickets.length; i++){ message[i * 32] = byte(bytes32(tickets[i])); // convert uint256[] to bytes for (uint j = 1; j < 32; j++) { message[i * 32 + j] = byte(bytes32(tickets[i] = tickets[i] << 8)); } } } }
0.4.18