multiply-0.2.0: A number of different algorithms for integer multiplication
Copyright© Frank Jung 2021
LicenseGPL-3
Safe HaskellSafe-Inferred
LanguageHaskell2010

Multiply

Description

Haskell implementations of multiplication algorithms as described by From Mathematics to Generic Programming.

Synopsis

Documentation

multiply0 :: Word -> Word -> Word Source #

The Egyptian multiplication as described by Ahmes.

multiply1 :: Word -> Word -> Word Source #

Improved Ahmes algorithm.

multiply2 :: Word -> Word -> Word Source #

Improved Ahmes algorithm using an accumulator.

multiply3 :: Word -> Word -> Word Source #

Non-recursive version of Egyptian multiplication. Based on MathnStuff Egyptian multiplication.

multiply4 :: Word -> Word -> Word Source #

Non-recursive version of Egyptian multiplication by Rodrigo Girão Serrão

double :: Word -> Word Source #

Double the current value.

doubles :: Word -> [Word] Source #

Continuously double value.

half :: Word -> Word Source #

Half the current value.

halves :: Word -> [Word] Source #

List of halves until 1.

oddHalvesBinary :: Word -> [Word] Source #

Repeatadly half the given integer until 1 then replace even entries with 0 and odd entries with 1.