aboutsummaryrefslogtreecommitdiff
path: root/bin/rndi
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-03 17:57:47 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-03 18:03:38 +1200
commit8783a7ba4fccb5f8bb178241a98392cb4b6f6f6c (patch)
tree9323cf3529ba1c809beed46256889b8ee88c6d0d /bin/rndi
parentAllow numerator and denominator in myb(1) (diff)
downloaddotfiles-8783a7ba4fccb5f8bb178241a98392cb4b6f6f6c.tar.gz
dotfiles-8783a7ba4fccb5f8bb178241a98392cb4b6f6f6c.zip
Add rnds(1)
Low-quality random seed attempt.
Diffstat (limited to 'bin/rndi')
-rwxr-xr-xbin/rndi8
1 files changed, 4 insertions, 4 deletions
diff --git a/bin/rndi b/bin/rndi
index 3b0ea005..f6cd33da 100755
--- a/bin/rndi
+++ b/bin/rndi
@@ -1,9 +1,9 @@
#!/usr/bin/awk -f
-# Get a low-quality random number between two integers. Note that depending on
-# implementation, this might return the same number if run in the same second.
-# It's only for trivial purposes.
+# Get a low-quality random number between two integers. Depending on the awk
+# implementation, if you don't provide a third argument (a seed), you might get
+# very predictable random numbers based on the current epoch second.
BEGIN {
- srand()
+ srand(ARGV[3])
print int(ARGV[1]+rand()*(ARGV[2]-ARGV[1]+1))
exit
}