import Math.Integer
The Math.Integer Class has declarations used to perform common integer arithmetic operations.
I128 { Hi cell, Lo cell } 128 bit integer I256 { Cell[3] } 256 bit integer Random.Number(word) { Seed word } 32 bit random numbers Random.Number(cell) { Seed cell } 64 bit random numbers Random.Range(word) % Random.Number(word) { From = -1 word, Width word, Max word } Random.Range(cell) % Random.Number(cell) { From = -1 cell, Width cell, Max cell }
These macros perform simple but fast hashing operations for use in non-cryptographic applications.
Hash.Key( .Key ) => Hash__key( .Key ) : The result is a Word; perform in a Word context. : Hash..word( .Key ) => (( .Key _* 2654435761 ) // 11 ) _* 2654435761 : The result is a Word or Cell; depending on the context. : Hash..cell( .Key ) => cell{[( .Key _* 11400714819323197493 ) // 23 ] & _* 11400714819323197493 } : The result is a Word or Cell; depending on the context type. : Hash..string( .Key ) => Hash.Key.String( .Key )
Procedures that perform 32 and 64 bit arithmetic operations:
Times( Left cell, Right cell ) ==> Times I128 Square( Base cell ) ==> Square I128 Population( Value cell ) ==> Count byte Population( Value word ) ==> Count byte Jacobi( A cell, N cell ) ==> Jacobi cell Jacobi( A word, N word ) ==> Jacobi word Signed.Jacobi( A cell, N cell ) ==> Jacobi cell Signed.Jacobi( A word, N word ) ==> Jacobi word Minus.Jacobi( A cell, N cell ) ==> Jacobi cell Minus.Jacobi( A word, N word ) ==> Jacobi word Lcm( Left cell, Right cell ) ==> Lcm cell Lcm( Left word, Right word ) ==> Lcm word Gcd( Left cell, Right cell ) ==> Divisor cell Gcd( Left word, Right word ) ==> Divisor word Gcd( Left I128, Right I128 ) ==> Divisor I128 Gcd.Odd( Left cell, Right cell ) ==> Divisor cell Gcd.Odd( Left word, Right word ) ==> Divisor word Gcd.Odd( Left I128, Right I128 ) ==> Divisor I128 GCD.EXTENDED entry Left cell, Right cell, exit S cell, T cell pure GCD.EXTENDED entry Left word, Right word, exit S word, T word pure GCD.EXTENDED.SET entry Left cell, Right cell, exit S cell, T cell, Gcd cell pure GCD.EXTENDED.SET entry Left word, Right word, exit S word, T word, Gcd word pure PLUS.CARRY change Sum cell, change Carry Bit, entry Increment = 0 cell MINUS.BORROW change Sum cell, change Borrow Bit, entry Decrement = 0 cell Divide.Round( Numerator cell, Denominator cell ) ==> Quotient cell Divide.Round( Numerator word, Denominator word ) ==> Quotient word Divide.Roundup( Numerator cell, Denominator cell ) ==> Quotient cell Divide.Roundup( Numerator word, Denominator word ) ==> Quotient word PERFECT.POWER change Base cell, exit Power = 1 byte PERFECT.POWER.PRIME change Base cell, exit Power = 1 byte Is.Prime( N cell ) ==> Prime Bit Is.Prime( N word ) ==> Prime Bit Sprp( N cell, Base cell ) ==> Sprp Bit Sprp( N word, Base word ) ==> Sprp Bit Sprp.Two( N cell ) ==> Sprp Bit Sprp.Two( N word ) ==> Sprp Bit
Procedures that perform safe 64 bit arithmetic operations:
Safe.Plus( Left cell, Right cell ) ==> Sum cell Safe.Minus( Left cell, Right cell ) ==> Delta cell Safe.Times( Left cell, Right cell ) ==> Product cell Safe.Divide( Left cell, Right cell ) ==> Quotient cell Safe.Uplus( Left cell, Right cell ) ==> Sum cell Safe.Uminus( Left cell, Right cell ) ==> Delta cell Safe.Utimes( Left cell, Right cell ) ==> Product cell
Procedures that perform 32 and 64 bit modular arithmetic:
Square.Mod( Base cell, Modulus cell ) ==> Square cell Square.Mod( Base word, Modulus word ) ==> Square word Power.Mod( Base cell, Exponent cell, Modulus cell ) ==> Power cell Power.Mod( Base word, Exponent word, Modulus word ) ==> Power word Two.Power.Mod( Exponent cell, Modulus cell ) ==> Power cell Two.Power.Mod( Exponent word, Modulus word ) ==> Power word Times.Mod( Left cell, Right cell, Modulus cell ) ==> Times cell DIVIDE.MOD change Left cell, entry Denominator cell, exit Modulus cell Plus.Mod( Left cell, Right cell, Modulus cell ) ==> Sum cell Minus.Mod( Left cell, Right cell, Modulus cell ) ==> Delta cell
Procedures that perform 128 bit arithmetic operations:
Form( I128, Format = "" string ) ==> Form string SET exit I128, entry Lo = 0 cell, Hi = 0 cell pure To.Double( I128 ) ==> double Signed64( Cell = 0 ) ==> I128 Positive64( Cell = 0 ) ==> I128 Absolute( I128 ) ==> Absolute I128 Negate( I128 ) ==> Negative I128 Complement( I128 ) ==> Complement I128 Population( I128 ) ==> Count parcel Square.Root( I128 ) ==> Root cell LOG2 entry I128, exit Log2 byte pure Log2.Double( entry I128 ) ==> Log2 double PLUS change Left I128, entry Right I128 pure PLUS64 change Left I128, entry Right cell pure PLUS.CARRY change I128, change Carry Bit, entry Increment I128 MINUS change Left I128, entry Right I128 pure MINUS64 change Left I128, entry Right cell pure Utimes( Left I128, Right I128 ) ==> Product I256 Utimes64( Left I128, Right cell ) ==> Product I128 Square( Base I128 ) ==> Square I128 Power( Base I128, Exponent I128 ) ==> Power I128 Power64( Base I128, Exponent cell ) ==> Power I128 TWO.POWER exit I128, entry Power byte UDIVIDE64 change I128, entry Denominator cell, exit Quotient cell pure Mod64( I128, Modulus cell ) ==> Mod cell Mod32( I128, Modulus word ) ==> Mod word Gcd( Left I128, Right I128 ) ==> Divisor I128 Gcd.Odd( Left I128, Right I128 ) ==> Divisor I128 SHIFT.LEFT change I128, entry Shift = 1 word pure SHIFT.RIGHT change I128, entry Shift = 1 word pure And( I128, N I128 ) ==> And I128 Or( I128, N I128 ) ==> Or I128 Xor( I128, N I128 ) ==> Xor I128 Is.Zero( I128 ) ==> Zero Bit Is.Bit( I128, Index byte ) ==> Bit Is.Perfect.Power( N I128, Power parcel ) ==> Perfect Bit Equal64( Left I128, Right cell ) ==> Equal Bit Less( Left I128, Right I128 ) ==> Less Bit Less64( Left I128, Right cell ) ==> Less Bit Less.Equal( Left I128, Right I128 ) ==> Less Bit Less.Equal64( Left I128, Right cell ) ==> Less Bit Over( Left I128, Right I128 ) ==> Over Bit Over64( Left I128, Right cell ) ==> Over Bit Over.Equal( Left I128, Right I128 ) ==> Over Bit Over.Equal64( Left I128, Right cell ) ==> Over Bit
Procedures that perform 32 and 64 bit factorization:
First.Factor( N cell ) ==> Factor word First.Factor( N word ) ==> Factor word First.Factor( N parcel ) ==> Factor parcel Factor( N cell ) >>> Factor cell Factor( N word ) >>> Factor word Factor.wheel( Start cell ) >>> Odd cell pure Factor.wheel( Start word ) >>> Odd word pure Prime( From = 3 cell ) >>> Prime cell pure Prime( From = 3 word ) >>> Prime word pure Prime( From = 3 parcel ) >>> Prime parcel pure Square.Form( N cell ) ==> Factor word Square.Form( N word ) ==> Factor word Form.Factor( N cell, Format = "" string ) ==> Factor string
Procedures that perform 32 and 64 bit hashing and randomization operations:
HASH.KEY exit Key cell, entry Value string HASH.KEY exit Key I128, entry Value string HASH.KEY exit Key I256, entry Value string HASH.STRING exit Key cell, entry Value string HASH.STRING exit Key I128, entry Value string HASH.STRING exit Key I256, entry Value string Hash.Key.String( Key string ) ==> Hash cell SEED change Random.Number, entry Seed = 0 cell pure SEED change Random.Number, entry Seed = 0 word pure UNIFORM change Random.Number, exit Random cell pure UNIFORM change Random.Number, exit Random word pure LOG2 change Random.Number, exit Random cell pure LOG2 change Random.Number, exit Random word pure RANGE change Random.Range, exit Random cell pure RANGE change Random.Range, exit Random word pure RANDOM.RANGE change Random.Range, entry Here = -1 cell, There = 0 cell, Seed = 0 cell pure RANDOM.RANGE change Random.Range, entry Here = -1 word, There = 0 word, Seed = 0 word pure