Module 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).

Functions

NameDescription
divisor(value) Automatically selects the correct divisor based on type

Structs

NameDescription
S32Divisor Signed 32 bit divisor
S64Divisor Signed 64 bit divisor
U32Divisor Unsigned 32 bit divisor
U64Divisor Unsigned 64 bit divisor