v4-core icon indicating copy to clipboard operation
v4-core copied to clipboard

Use bit operation to perform modulo operations

Open malik672 opened this issue 1 year ago • 1 comments

Component

Gas Optimization, General design optimization (improving efficiency, cleanliness, or developer experience)

Describe the suggested feature and problem it solves.

Modular operations where the denominator is a power of 2, instead of doing this uint8 fee0 = fee % 16; , we can simply do this uint8 fee0 = fee & (16 - 1); and can we aslo add the unchecked block to the this part since it has no possibility of overflow or underflow

Describe the desired implementation.

http://graphics.stanford.edu/~seander/bithacks.html#ModulusDivisionEasy

Describe alternatives.

No response

Additional context.

No response

malik672 avatar Jun 16 '23 20:06 malik672

:sparkles: Thanks to the community, there's an estimated bounty value of $68.13 USD for a successful merge request of this issue via contributions such as 6.09375 UNI tokens. Happy coding :grinning: Details and T&Cs at joinfuel.io

fuelmessenger avatar Apr 07 '24 18:04 fuelmessenger

@malik672 Can be closed.

shuhuiluo avatar May 20 '24 19:05 shuhuiluo