menu
manual-integer-log
Prefer integerLog2 over equivalent base-two integer logarithms
Subtracting the leading-zero count from an integer width manually computes its base-two logarithm.
Instead, you SHOULD call integerLog2, which states the operation directly and preserves exact integer behavior.
Reported
1function magnitude(value: uint32): uint32 {2 return 31 - value.countLeadingZeros();3}Accepted
1function magnitude(value: uint32): uint32 {2 return value.integerLog2();3}