calculate float division 1

calculate float division

bc -l <<< '10/3' # Fast way
3.33333333333333333333
bc <<< 'scale=2; 10/3' #Define also how many decimals to take in scale
3.33

Here is what the above code is Doing:
1. bc is a command line calculator
2. <<< is a bash operator that redirects the string to the command on the left 3. bc -l loads the math library 4. scale=2 sets the number of digits after the decimal point 5. 10/3 is the math expression

Similar Posts