IR.CreateBigIntContext()
Creates a large number.
Syntax
IR.CreateBigIntContext(bool)
| Input | Value | Description |
|---|---|---|
| bool | false | type: Boolean number format: true - hexadecimal; false - decimal. |
| Output | ||
|---|---|---|
| result | 11111111111111... | type: number large number. |
Example
var DBigNum = IR.CreateBigIntContext(false)
var DValue1 = "11111111111111111111111111111111111111111111111111111111"
var DValue2 = "11111111111111111111111111111111111111111111111111111111"
IR.Log(DBigNum.Add(DValue1, DValue2))
The following methods operate on large numbers.
.Add
Add large numbers (r = a + b).
Syntax
HBigNum.Add(a, b)
| Input | Value | Description |
|---|---|---|
| HBigNum | IR.CreateBigIntContext(true) | type: object pointer to a large number. |
| Output | ||
|---|---|---|
| r | 1E | type: number result of adding large numbers. |
Example
var HBigNum = IR.CreateBigIntContext(true)
IR.Log(HBigNum.Add("F", "F"))
.Exp
Raise a number to a power (r = a ^ p).
Syntax
HBigNum.Exp(a, b)
| Input | Value | Description |
|---|---|---|
| HBigNum | IR.CreateBigIntContext(true) | type: object pointer to a large number. |
| Output | ||
|---|---|---|
| r | 03E8 | type: number result of raising large numbers to a power. |
Example
var HBigNum = IR.CreateBigIntContext(true)
IR.Log(HBigNum.Exp("A", "3"))
.ModExp
Get the remainder after raising a number to a power and dividing by m (r = a ^ p % m).
Syntax
HBigNum.ModExp(a, p, m)
| Input | Value | Description |
|---|---|---|
| HBigNum | IR.CreateBigIntContext(true) | type: object pointer to a large number. |
| Output | ||
|---|---|---|
| r | 08 | type: number result of exponentiation and taking the remainder of division of large numbers. |
Example
var HBigNum = IR.CreateBigIntContext(true)
IR.Log(HBigNum.ModExp("2", "3", "A"))
.Sub
Subtract large numbers (r = a - b).
Syntax
HBigNum.Sub(a, b)
| Input | Value | Description |
|---|---|---|
| HBigNum | IR.CreateBigIntContext(true) | type: object pointer to a large number. |
| Output | ||
|---|---|---|
| r | F5 | type: number result of subtracting large numbers. |
Example
var HBigNum = IR.CreateBigIntContext(true)
IR.Log(HBigNum.Sub("FF", "A"))
.Mul
Multiply large numbers (r = a * b).
Syntax
HBigNum.Mul(a, b)
| Input | Value | Description |
|---|---|---|
| HBigNum | IR.CreateBigIntContext(true) | type: object pointer to a large number. |
| Output | ||
|---|---|---|
| r | D2 | type: number result of subtracting large numbers. |
Example
var HBigNum = IR.CreateBigIntContext(true)
IR.Log(HBigNum.Mul("F", "E"))
.Sqr
Square large numbers (r = a ^ 2).
Syntax
HBigNum.Sqr(a)
| Input | Value | Description |
|---|---|---|
| HBigNum | IR.CreateBigIntContext(true) | type: object pointer to a large number. |
| Output | ||
|---|---|---|
| r | 64 | type: number result of squaring large numbers. |
Example
var HBigNum = IR.CreateBigIntContext(true)
IR.Log(HBigNum.Sqr("A"))
.Gcd
Calculate the greatest common divisor (r = (a, b)).
Syntax
HBigNum.Gcd(a, b)
| Input | Value | Description |
|---|---|---|
| HBigNum | IR.CreateBigIntContext(true) | type: object pointer to a large number. |
| Output | ||
|---|---|---|
| r | 05 | type: number greatest common divisor of a and b. |
Example
var HBigNum = IR.CreateBigIntContext(true)
IR.Log(HBigNum.Gcd("FF", "AF"))
.Div
Integer division of large numbers (r = a / b).
Syntax
HBigNum.Div(a, b)
| Input | Value | Description |
|---|---|---|
| HBigNum | IR.CreateBigIntContext(true) | type: object pointer to a large number. |
| Output | ||
|---|---|---|
| r | 0199 | type: number integer-division result. |
Example
var HBigNum = IR.CreateBigIntContext(true)
IR.Log(HBigNum.Gcd("FFF", "A"))
.HexToDec
Convert a large hexadecimal number to decimal.
Syntax
HBigNum.HexToDec(a)
| Input | Value | Description |
|---|---|---|
| HBigNum | IR.CreateBigIntContext(true) | type: object pointer to a large number. |
| a | "C" | type: number hexadecimal number. |
| Output | ||
|---|---|---|
| result | 12 | type: number result of converting the number to decimal. |
Example
var HBigNum = IR.CreateBigIntContext(true)
IR.Log(HBigNum.HexToDec("С"))
.DecToHex
Convert a large decimal number to hexadecimal.
Syntax
HBigNum.DecToHex(a)
| Input | Value | Description |
|---|---|---|
| HBigNum | IR.CreateBigIntContext(true) | type: object pointer to a large number. |
| a | "10" | type: number decimal number. |
| Output | ||
|---|---|---|
| result | 0A | type: number result of converting the number to hexadecimal. |
Example
var HBigNum = IR.CreateBigIntContext(true)
IR.Log(HBigNum.DecToHex("10")) // result: 0A