aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorYawning Angel <yawning@schwanenlied.me>2025-11-25 03:59:18 +0900
committerYawning Angel <yawning@schwanenlied.me>2025-11-29 10:45:53 +0900
commit0bd6410ea3b2b76eeafaa52c0fa626b4477190e2 (patch)
treeefbf3fa755900d47fb9564812fe3ce5c7b06a891 /examples
parent73883b70c83f2d9d1d7c99784450e7926206f12d (diff)
examples/demo: Set the RNG to xoshiro256
The example should run on any target, not just first class ones.
Diffstat (limited to 'examples')
-rw-r--r--examples/demo/demo.odin5
1 files changed, 5 insertions, 0 deletions
diff --git a/examples/demo/demo.odin b/examples/demo/demo.odin
index 161d48acb..1ea06d096 100644
--- a/examples/demo/demo.odin
+++ b/examples/demo/demo.odin
@@ -11,6 +11,7 @@ import "core:reflect"
import "base:runtime"
import "base:intrinsics"
import "core:math/big"
+import "core:math/rand"
/*
Odin is a general-purpose programming language with distinct typing built
@@ -2258,6 +2259,10 @@ arbitrary_precision_mathematics :: proc() {
a, b, c, d, e, f, res := &big.Int{}, &big.Int{}, &big.Int{}, &big.Int{}, &big.Int{}, &big.Int{}, &big.Int{}
defer big.destroy(a, b, c, d, e, f, res)
+ // Set the context RNG to something that does not require
+ // cryptographic entropy (not supported on all targets).
+ context.random_generator = rand.xoshiro256_random_generator()
+
// How many bits should the random prime be?
bits := 64
// Number of Rabin-Miller trials, -1 for automatic.