#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# split/slice uint

New ZealandMember Posts: 5
I have a couple of keccaks, which could be reduced to one, if I would find a cheap way to get parts of the created uint.

pragma solidity ^0.4.19;

contract test {
function test() {

}

function sup() returns (uint test) {
uint _test = uint(keccak256("wow"));
return _test;
}
}
Which returns me a sweet random number: 13483274892375982735325
Now the plan is that instead of calling keccak 5 times with different "seeds" I could take that number apart and get something like:
1348, 3274, 8923 etc.
which I then use for my random number e.g.: 1348 % 10

I am lost.

• New ZealandMember Posts: 5
Here my best attempt.

pragma solidity ^0.4.19;

contract test {

event randomNumbers(uint numbers, uint randomNumbers);

function testa() public returns (uint bla) {

//uint something = 12345678123456781234567812345678;
uint something = uint(keccak256("rockandroll"));

uint memory array;
uint memory random;

for(uint i=0; i<8; i++) {
uint digit = something % 10000;
// do something with digit
array[i] = digit;
something /= 10000;
random[i] =digit % 10;
}

randomNumbers(array,random);

return array;
}