Random Float

Generate a random floating-point number within a specified range with configurable decimal precision.

Code

General
printf "%.${decimals}f\n" "$(echo "$min + $RANDOM / 32767 * ($max - $min)" | bc -l)"

Parameters

Minimum value

Maximum value

Decimal places

Server

More Bash Snippets