Skip to content
F

Fastrange

A fast alternative to the modulo reduction

by lemireFree

#4589in Utilities
0In stores

Description

fastrange is a small C and C++ library that maps a machine word to an integer in a range faster than the modulo operator. Mapping a value to…

Highlights

  • Single header file with no linking needed
  • Faster alternative to modulo reduction
  • Works with C99 and C++ compilers
  • CMake use through FetchContent, submodule or install
  • Static inline functions

Ratings & Reviews

No ratings yet

Be the first to rate Fastrange.

People also visit

F

Frozen

a header-only, constexpr alternative to gperf for C++14 users

Utilities
Launch
C

cpp-pro

Writes, optimizes, and debugs C++ applications

AI Skills
Get
H

Hash Wasm

Lightning fast hash functions using hand-tuned WebAssembly binaries

Utilities
Launch
M

Mppp

Multiprecision for modern C++

Education
Launch
R

Re2

RE2 is a fast, safe, thread-friendly alternative

Utilities
Launch
C

Competitive Programming RS

Algorithm Snippets for Competitive Programming in Rust

Developer Tools
Launch

Fastrange FAQ

What is fastrange?

A header-only C and C++ library that maps a value into a range faster than the modulo operator. It is useful in hashing and probabilistic algorithms.

How do I add it to a project?

Copy the single header file into your project, or use it with CMake through FetchContent, a git submodule or an installed copy. The README covers each option.

Which compiler do I need?

A C99 or better compiler, or a C++ compiler. The README says the header is known to work with GCC and Clang.

Does it need to be linked?

No. All the functions are static inline, so there is no library to link against.

Is it open source?

The source is public on GitHub at lemire/fastrange. The README cites Daniel Lemire's related paper on fast random integer generation.

What are the best Fastrange alternatives?

Popular alternatives to Fastrange include Frozen, Hash Wasm and Re2. See all Fastrange alternatives

Developer Stuff

Badges