libdivide
« Back to VersTracker
Description:
Optimized integer division
Type: Formula  |  Tracked Since: Dec 28, 2025
Links: Homepage  |  formulae.brew.sh
Category: Developer tools
Tags: c-plus-plus c performance math optimization algorithms
Install: brew install libdivide
About:
Libdivide is a library that replaces expensive integer division operations with faster multiplication and bitshift operations. It precomputes a 'magic number' based on the divisor, allowing the compiler to generate highly optimized code. This results in significant performance gains in scenarios involving repeated division by the same constant.
Key Features:
  • Replaces integer division with faster multiplication
  • Supports signed and unsigned 32-bit and 64-bit integers
  • Generates branch-free code for consistent performance
  • Works across multiple compilers and architectures
Use Cases:
  • Optimizing high-performance computing loops
  • Speeding up hash table implementations and bit manipulation
  • Reducing CPU overhead in graphics and game engine code
Alternatives:
  • Compiler auto-vectorization – Modern compilers often optimize division automatically, but Libdivide offers explicit control and guarantees for specific hotspots.
Version History
Detected Version Rev Change Commit