100 Days Of Solidity, Assembly Math, Solidity Academy.
Assembly Math. You can shift bits, perform logical AND/OR/XOR operations, and set/clear specific bits. // Set the nth bit of a uint256 to 1 function setBit(uint256 num, uint8 bit) public pure returns (uint256) { assembly { num := or(num, shl(bit, 1)) } } Gas Optimization ⛽ One of the main reasons