Hello @dsbarnes
,
You can not do floating point arithmetic natively in Bash, but there is a trick I use i.e. using the 'bc' command like:
echo "3.142 + 3.142" | bc -l # add the value of pi to itself
echo "sqrt(49)" | bc -l # find the square root of 49
echo "scale=2; sqrt(91)" | bc -l # To find the square root of 91 to just 2 decimal places.
The capabilities of bc is extremely wide. Check the Manpage for its full documentation.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hello @dsbarnes ,
You can not do floating point arithmetic natively in Bash, but there is a trick I use i.e. using the 'bc' command like:
echo "3.142 + 3.142" | bc -l # add the value of pi to itself
echo "sqrt(49)" | bc -l # find the square root of 49
echo "scale=2; sqrt(91)" | bc -l # To find the square root of 91 to just 2 decimal places.
The capabilities of bc is extremely wide. Check the Manpage for its full documentation.