Why do people use uint8 for constant variables such as decimals for tokens, isn't it better to use uint256? the EVM would need to use additional calls to go from 256/32bits to 8 and therefore increase gas costs
With optimization enabled, there will be no extra gas cost for using
uint8 constants instead of
uint256 constants. The conversion instructions are optimized away entirely.
With optimization disabled, there is a small extra gas cost.
I just tested it, and with optimization disabled the use of a
uint8 constant gave 3 bytes of bytecode more than the use of a
With optimization enabled, the Solidity compiler gives the exact same bytecode in both cases.