From 9ed7bc1bd52d850ae740eb18e5640f59e24d63fd Mon Sep 17 00:00:00 2001 From: Steven Baltakatei Sandoval Date: Tue, 14 Feb 2023 08:28:40 +0000 Subject: [PATCH 1/1] feat(unitproc/bkt-randFloat):Update to use printf --- unitproc/bkt-randFloat | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/unitproc/bkt-randFloat b/unitproc/bkt-randFloat index eb5ef49..077e8d0 100644 --- a/unitproc/bkt-randFloat +++ b/unitproc/bkt-randFloat @@ -2,11 +2,11 @@ #==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 - # Version: 0.0.1 + # Version: 0.1.0 # 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 @@ -26,8 +26,8 @@ randFloat() { # Produce output decimals="$(head -c ${arg1:-5} < <(LC_ALL=C tr -cd "[:digit:]" < <(cat /dev/urandom)))"; - echo 0."$decimals"; -} + printf "0.%s\n" "$decimals"; +}; # output random float [0.00000 1.00000] to stdout #==END Function Definitions== #==BEGIN sample code== -- 2.30.2