# How is uint8 calculated from a uint256 conversion in Solidity?

I'm aware that a conversion from `uint256` to `uint8` looks like this:

``````uint8(A_UINT256_NUMBER)
``````

But how is a `uint8` calculated from `uint256`?

There's definitely loss of data, but I assumed that converting to `uint8` simply meant taking the first or last 8 bits of the `uint256` number.

I did some `console.log()` in the .sol file using Hardhat, but it proved both assumptions wrong. When my `uint256` was:

``````uint hashed = uint(keccak256(abi.encodePacked(blockhash(block.number - 1), block.timestamp))
console.log(hashed) // 88631825676121136580333262905198704734650330576553363943113505420509106239582
``````

The `uint8` conversion of the above returned:

``````uint8 answer = uint8(hashed);
``````

Unless I'm doing this wrong, there doesn't seem to be a connection between them.

Found the answer - it just needed a bit more digging.

`uint8` takes the last 2 characters of a `uint256` hexadecimal. In the example above:

``````88631825676121136580333262905198704734650330576553363943113505420509106239582 // decimal
With the last 2 characters as `5E`, it returns us `94` in decimal. Therefore,
``````uint8 answer = uint8(0xC3F3D5E971FB24DF07463BC04B9518288E6E495556A1180BC517428AD8FD785E) // 94