Skip to content

Commit dc69862

Browse files
BIGNUM support
1 parent a008f77 commit dc69862

312 files changed

Lines changed: 5290 additions & 1197 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docpages/basic-language-reference/functions/integer/02_INDEX.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ The following functions operate on or return **integer values** in Retro Rocket
44

55
* \subpage ABS
66
* \subpage ASC
7+
* \subpage BIGCMP
78
* \subpage BITAND
89
* \subpage BITEOR
910
* \subpage BITNAND
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
\page BIGCMP BIGCMP Function
2+
3+
```basic
4+
BIGCMP(string-expression, string-expression)
5+
```
6+
7+
Compares two **arbitrary precision integers** provided as **decimal strings**.
8+
9+
---
10+
11+
### Examples
12+
13+
```basic
14+
PRINT BIGCMP("100", "50")
15+
```
16+
17+
Produces `1`.
18+
19+
```basic
20+
PRINT BIGCMP("42", "42")
21+
```
22+
23+
Produces `0`.
24+
25+
```basic
26+
PRINT BIGCMP("-10", "5")
27+
```
28+
29+
Produces `-1`.
30+
31+
---
32+
33+
### Notes
34+
35+
* Inputs must be valid base-10 integer strings.
36+
* Returns:
37+
38+
* `1` if first value is greater than second
39+
* `0` if both values are equal
40+
* `-1` if first value is less than second
41+
* Supports values far beyond 64-bit limits.
42+
* Negative numbers are supported.
43+
44+
---
45+
46+
**See also:**
47+
\ref BIGADDS "BIGADD$" · \ref BIGSUBS "BIGSUB$" · \ref BIGMULS "BIGMUL$" · \ref BIGDIVS "BIGDIV$" · \ref BIGMODS "BIGMOD$"

docpages/basic-language-reference/functions/string/04_INDEX.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
The following functions return or manipulate **string values** in Retro Rocket BASIC.
44

55
* \subpage ADFSIMAGE
6+
* \subpage BIGABSS
7+
* \subpage BIGADDS
8+
* \subpage BIGDIVS
9+
* \subpage BIGGCDS
10+
* \subpage BIGMODINVS
11+
* \subpage BIGMODPOWS
12+
* \subpage BIGMODS
13+
* \subpage BIGMULS
14+
* \subpage BIGNEGS
15+
* \subpage BIGSHLS
16+
* \subpage BIGSHRS
17+
* \subpage BIGSUBS
618
* \subpage BOOL
719
* \subpage BUFFERTOSTRINGS
820
* \subpage CHR
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
\page BIGABSS BIGABS$ Function
2+
3+
```basic
4+
BIGABS$(string-expression)
5+
```
6+
7+
Returns the **absolute value** of an **arbitrary precision integer** provided as a decimal string.
8+
9+
---
10+
11+
### Examples
12+
13+
```basic
14+
PRINT BIGABS$("-12345678901234567890")
15+
```
16+
17+
Produces `"12345678901234567890"`.
18+
19+
```basic
20+
PRINT BIGABS$("42")
21+
```
22+
23+
Produces `"42"`.
24+
25+
```basic
26+
PRINT BIGABS$("0")
27+
```
28+
29+
Produces `"0"`.
30+
31+
---
32+
33+
### Notes
34+
35+
* Input must be a valid base-10 integer string.
36+
* Negative values are converted to positive.
37+
* Zero and positive values are returned unchanged.
38+
* Result is returned as a decimal string.
39+
40+
---
41+
42+
**See also:**
43+
\ref BIGNEGS "BIGNEG$" · \ref BIGADDS "BIGADD$" · \ref BIGSUBS "BIGSUB$" · \ref BIGCMP "BIGCMP"
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
\page BIGADDS BIGADD$ Function
2+
3+
```basic
4+
BIGADD$(string-expression, string-expression)
5+
```
6+
7+
Adds two **arbitrary precision integers** provided as **decimal strings**, returning the result as a string.
8+
9+
---
10+
11+
### Examples
12+
13+
```basic
14+
PRINT BIGADD$("12345678901234567890", "1")
15+
```
16+
17+
Produces `"12345678901234567891"`.
18+
19+
```basic
20+
PRINT BIGADD$("99999999999999999999", "1")
21+
```
22+
23+
Produces `"100000000000000000000"`.
24+
25+
```basic
26+
PRINT BIGADD$("-50", "25")
27+
```
28+
29+
Produces `"-25"`.
30+
31+
---
32+
33+
### Notes
34+
35+
* Inputs must be valid base-10 integer strings.
36+
* Supports values far beyond 64-bit limits.
37+
* Negative numbers are supported.
38+
* Result is returned as a decimal string.
39+
* Leading zeros in input are ignored.
40+
41+
---
42+
43+
**See also:**
44+
\ref BIGSUBS "BIGSUB$" · \ref BIGMULS "BIGMUL$" · \ref BIGDIVS "BIGDIV$" · \ref BIGMODS "BIGMOD$" · \ref BIGCMP "BIGCMP"
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
\page BIGDIVS BIGDIV$ Function
2+
3+
```basic
4+
BIGDIV$(string-expression, string-expression)
5+
```
6+
7+
Divides one **arbitrary precision integer** (as a decimal string) by another, returning the **quotient** as a string.
8+
9+
---
10+
11+
### Examples
12+
13+
```basic
14+
PRINT BIGDIV$("100000000000000000000", "10")
15+
```
16+
17+
Produces `"10000000000000000000"`.
18+
19+
```basic
20+
PRINT BIGDIV$("7", "2")
21+
```
22+
23+
Produces `"3"`.
24+
25+
```basic
26+
PRINT BIGDIV$("-100", "4")
27+
```
28+
29+
Produces `"-25"`.
30+
31+
---
32+
33+
### Notes
34+
35+
* Inputs must be valid base-10 integer strings.
36+
* Division is integer division (fractional part is discarded).
37+
* Division by zero produces an error.
38+
* Negative numbers are supported.
39+
* Result is returned as a decimal string.
40+
41+
---
42+
43+
**See also:**
44+
\ref BIGMODS "BIGMOD$" · \ref BIGADDS "BIGADD$" · \ref BIGSUBS "BIGSUB$" · \ref BIGMULS "BIGMUL$" · \ref BIGCMP "BIGCMP"
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
\page BIGGCDS BIGGCD$ Function
2+
3+
```basic
4+
BIGGCD$(string-expression, string-expression)
5+
```
6+
7+
Calculates the **greatest common divisor (GCD)** of two **arbitrary precision integers** provided as decimal strings, returning the result as a string.
8+
9+
---
10+
11+
### Examples
12+
13+
```basic
14+
PRINT BIGGCD$("48", "18")
15+
```
16+
17+
Produces `"6"`.
18+
19+
```basic
20+
PRINT BIGGCD$("12345678901234567890", "9876543210")
21+
```
22+
23+
Produces `"90"`.
24+
25+
```basic
26+
PRINT BIGGCD$("-42", "56")
27+
```
28+
29+
Produces `"14"`.
30+
31+
---
32+
33+
### Notes
34+
35+
* Inputs must be valid base-10 integer strings.
36+
* Negative values are treated by magnitude (the result is always non-negative).
37+
* If both inputs are zero, the result is `"0"`.
38+
* Result is returned as a decimal string.
39+
40+
---
41+
42+
**See also:**
43+
\ref BIGADDS "BIGADD$" · \ref BIGSUBS "BIGSUB$" · \ref BIGMULS "BIGMUL$" · \ref BIGDIVS "BIGDIV$" · \ref BIGMODS "BIGMOD$" · \ref BIGCMP "BIGCMP"
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
\page BIGMODINVS BIGMODINV$ Function
2+
3+
```basic
4+
BIGMODINV$(string-expression, string-expression)
5+
```
6+
7+
Computes the **modular multiplicative inverse** of an **arbitrary precision integer**.
8+
Returns a value (X) such that:
9+
10+
```
11+
(A * X) MOD M = 1
12+
```
13+
14+
---
15+
16+
### Examples
17+
18+
```basic
19+
PRINT BIGMODINV$("3", "11")
20+
```
21+
22+
Produces `"4"`.
23+
24+
```basic
25+
PRINT BIGMODINV$("10", "17")
26+
```
27+
28+
Produces `"12"`.
29+
30+
```
31+
(10 * 12) MOD 17 = 1
32+
```
33+
34+
---
35+
36+
### Notes
37+
38+
* Inputs must be valid base-10 integer strings.
39+
* The inverse exists only if `A` and `M` are coprime.
40+
* If no inverse exists, an error is produced.
41+
* Modulus must be non-zero.
42+
* Result is returned as a decimal string.
43+
44+
---
45+
46+
**See also:**
47+
\ref BIGMODPOWS "BIGMODPOW$" · \ref BIGMODS "BIGMOD$" · \ref BIGGCDS "BIGGCD$" · \ref BIGMULS "BIGMUL$"
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
\page BIGMODPOWS BIGMODPOW$ Function
2+
3+
```basic
4+
BIGMODPOW$(string-expression, string-expression, string-expression)
5+
```
6+
7+
Computes **modular exponentiation** on **arbitrary precision integers**, returning
8+
((A^E) \bmod M) as a string.
9+
10+
---
11+
12+
### Examples
13+
14+
```basic
15+
PRINT BIGMODPOW$("2", "10", "1000")
16+
```
17+
18+
Produces `"24"`.
19+
20+
```basic
21+
PRINT BIGMODPOW$("5", "3", "13")
22+
```
23+
24+
Produces `"8"`.
25+
26+
```basic
27+
PRINT BIGMODPOW$("123456789", "2", "100000")
28+
```
29+
30+
Produces `"521"`.
31+
32+
---
33+
34+
### Notes
35+
36+
* All inputs must be valid base-10 integer strings.
37+
* Efficient for large values (uses modular exponentiation, not naive power).
38+
* Modulus must be non-zero.
39+
* Negative bases are supported; exponent must be non-negative.
40+
* Result is always in the range `0` to `M-1`.
41+
* Result is returned as a decimal string.
42+
43+
---
44+
45+
**See also:**
46+
\ref BIGMODINVS "BIGMODINV$" · \ref BIGMODS "BIGMOD$" · \ref BIGMULS "BIGMUL$" · \ref BIGADDS "BIGADD$"
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
\page BIGMODS BIGMOD$ Function
2+
3+
```basic
4+
BIGMOD$(string-expression, string-expression)
5+
```
6+
7+
Calculates the **remainder** of dividing one **arbitrary precision integer** (as a decimal string) by another, returning the result as a string.
8+
9+
---
10+
11+
### Examples
12+
13+
```basic
14+
PRINT BIGMOD$("10", "3")
15+
```
16+
17+
Produces `"1"`.
18+
19+
```basic
20+
PRINT BIGMOD$("100000000000000000000", "7")
21+
```
22+
23+
Produces `"2"`.
24+
25+
```basic
26+
PRINT BIGMOD$("-10", "3")
27+
```
28+
29+
Produces `"-1"`.
30+
31+
---
32+
33+
### Notes
34+
35+
* Inputs must be valid base-10 integer strings.
36+
* Division by zero produces an error.
37+
* The result follows the sign of the dividend.
38+
* Result is returned as a decimal string.
39+
40+
---
41+
42+
**See also:**
43+
\ref BIGDIVS "BIGDIV$" · \ref BIGADDS "BIGADD$" · \ref BIGSUBS "BIGSUB$" · \ref BIGMULS "BIGMUL$" · \ref BIGCMP "BIGCMP"

0 commit comments

Comments
 (0)