aboutsummaryrefslogtreecommitdiff
path: root/random_bigint
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-02-09 19:38:26 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2025-02-09 19:39:13 +0100
commitd16656919753438a57a32f9ad6ba972c25d66b11 (patch)
treee7b99259c2584d0c092b5044583571cce0a4918e /random_bigint
parentece9b2e4c547c986fd9e2bb4b7d97287be5621fb (diff)
downloadzmodn-d16656919753438a57a32f9ad6ba972c25d66b11.tar.gz
zmodn-d16656919753438a57a32f9ad6ba972c25d66b11.zip
Added random number generator for bigintHEADmaster
Diffstat (limited to 'random_bigint')
-rwxr-xr-xrandom_bigint34
1 files changed, 34 insertions, 0 deletions
diff --git a/random_bigint b/random_bigint
new file mode 100755
index 0000000..250de64
--- /dev/null
+++ b/random_bigint
@@ -0,0 +1,34 @@
1#if 0
2
3cc=${CC:-g++}
4bin="$(mktemp)"
5
6if [ -z "$1" ] || [ -z "$2" ]; then
7 echo "Usage: $0 m n"
8 echo "Example: to generate 5 random 25-digits number use"
9 echo " $0 \\\"10000000000000000000000000\\\" 5"
10 exit 1
11fi
12
13${cc} -x c++ -std=c++20 -o "$bin" -g -O0 "$(realpath $0)" \
14 -DMAX_RANDOM="$1" -DHOW_MANY="$2"
15echo "Running $bin"
16"$bin"
17
18exit 0
19#endif
20
21#include "bigint.h"
22
23#include <iostream>
24
25int main() {
26 // Read compile-time variables
27 int n = HOW_MANY;
28 BigInt<100> r(MAX_RANDOM);
29
30 for (int i = 0; i < n; i++)
31 std::cout << BigInt<100>::random(r) << std::endl;
32
33 return 0;
34}