projects
/
BK-2020-03.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
chore(doc/up/bkshuf/article.tm):Update GitLab URL in bkshuf doc
[BK-2020-03.git]
/
unitproc
/
bkt-randFloat
diff --git
a/unitproc/bkt-randFloat
b/unitproc/bkt-randFloat
index eb5ef4933046d771453efaaff32624bd5a794385..7d61707ba6887c42b0117eeb3b2758154c76f92a 100644
(file)
--- a/
unitproc/bkt-randFloat
+++ b/
unitproc/bkt-randFloat
@@
-2,11
+2,11
@@
#==BEGIN Function Definitions==
randFloat() {
#==BEGIN Function Definitions==
randFloat() {
- # Desc: Output random float
with no newline
+ # Desc: Output random float
# Usage: randFloat arg1
# Inputs: arg1: number of decimal places
# Output: stdout: float as decimal string
# Usage: randFloat arg1
# Inputs: arg1: number of decimal places
# Output: stdout: float as decimal string
- # Version: 0.
0
.1
+ # Version: 0.
1
.1
# Note: Outputs float from 0.000... to 0.999...
# Note: Default number of decimals is 5.
# Ref/Attrib: Integer test regular expression https://stackoverflow.com/a/806923
# Note: Outputs float from 0.000... to 0.999...
# Note: Default number of decimals is 5.
# Ref/Attrib: Integer test regular expression https://stackoverflow.com/a/806923
@@
-21,13
+21,13
@@
randFloat() {
echo "ERROR:Not an integer." >&2; exit 1;
fi;
else
echo "ERROR:Not an integer." >&2; exit 1;
fi;
else
- echo "ERROR:Invalid number of arguments:${
@
}";
+ echo "ERROR:Invalid number of arguments:${
*
}";
fi;
# Produce output
fi;
# Produce output
- decimals="$(head -c
${arg1:-5}
< <(LC_ALL=C tr -cd "[:digit:]" < <(cat /dev/urandom)))";
-
echo 0.
"$decimals";
-}
+ decimals="$(head -c
"${arg1:-5}"
< <(LC_ALL=C tr -cd "[:digit:]" < <(cat /dev/urandom)))";
+
printf "0.%s\n"
"$decimals";
+}
; # output random float [0.00000 1.00000] to stdout
#==END Function Definitions==
#==BEGIN sample code==
#==END Function Definitions==
#==BEGIN sample code==