It is a funny and simply tip under bash.
How to deals with float and division under bash. ‘bc’ is your friend such as :

clucas@jupiter:~$ i=$( echo "scale=3; 1/3" | bc)
clucas@jupiter:~$ echo $i
.333
clucas@jupiter:~$

It must found on the net (where I found), but searchable for me on this stuff for future.

NdR :

clucas@pluton:~$ i=$((1/3))
clucas@pluton:~$ echo $i
0
clucas@pluton:~$

Float and divide into bash

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.