mecca.lib.division

Library for efficient integer division by a single divider

When repeatedly dividing (with integer arithmetics) by the same divider, there are certain tricks that allow for quicker operation that the CPU's divide command. This is payed for by higher computation work during the setup stage.

For compile time known values, the compiler already performs this trick. This module is meant for run-time known values that are used repeatedly.

This code is a D adaptation of libdivide (http://libdivide.com).

Members

Functions

divisor
auto divisor(T value)

Automatically selects the correct divisor based on type

Structs

S32Divisor
struct S32Divisor

Signed 32 bit divisor

S64Divisor
struct S64Divisor

Signed 64 bit divisor

U32Divisor
struct U32Divisor

Unsigned 32 bit divisor

U64Divisor
struct U64Divisor

Unsigned 64 bit divisor

Meta