/** Base for calculations, the bigger the better but must fit in 32 bits. */ export const limbSize32 = Math . pow ( 2 , 32 ) ; export const limbInv32 = Math . pow ( 2 , - 32 ) ; export const limbsPerDigit32 = Math . log ( 10 ) / ( 32 * Math . log ( 2 ) ) ; /** Create a string with the given number of zero digits. */ function zeroes ( count ) { return ( new Array ( count + 1 ) . join ( '0' ) ) ; } export class BaseInfo32 { constructor ( public base ) { } static init ( base ) { return ( BaseInfo32 . baseTbl [ base ] || ( BaseInfo32 . baseTbl [ base ] = new BaseInfo32 ( base ) ) ) ; } private static baseTbl : { [ base ] : BaseInfo32 ; } = { } ; /** Average number of digits per limb. */ limbDigitsExact = Math . log ( limbSize32 ) / Math . log ( this . base ) ; /** Number of entire digits per limb. */ limbDigits = ~ ~ this . limbDigitsExact ; /** Maximum power of base that fits in a limb. */ limbBase = Math . pow ( this . base , this . limbDigits ) ; /** String of zeroes for padding an empty limb. */ pad = zeroes ( this . limbDigits ) ; }