Skip to content

Replace arithmetic ops with bitwise shifts in FastMath - #673

Open
Ameer-5-5 wants to merge 1 commit into
MDTechLabs:mainfrom
Ameer-5-5:issuefixed
Open

Replace arithmetic ops with bitwise shifts in FastMath#673
Ameer-5-5 wants to merge 1 commit into
MDTechLabs:mainfrom
Ameer-5-5:issuefixed

Conversation

@Ameer-5-5

Copy link
Copy Markdown

CLOSES #670
Use bitwise shift operations (<< 1, >> 2, & 7) instead of explicit arithmetic (* 2, / 4, % 8) in the new FastMath library to save gas.

  • mul2: x * 2 → x << 1
  • div4: x / 4 → x >> 2
  • mod8: x % 8 → x & 7

Each bitwise op saves ~2 gas vs its arithmetic counterpart.

Use bitwise shift operations (<< 1, >> 2, & 7) instead of explicit
arithmetic (* 2, / 4, % 8) in the new FastMath library to save gas.

- mul2: x * 2 → x << 1
- div4: x / 4 → x >> 2
- mod8: x % 8 → x & 7

Each bitwise op saves ~2 gas vs its arithmetic counterpart.
@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@Ameer-5-5 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[PERF] Convert Multiplication/Division by Powers of Two to Bitwise Shifts

1 participant