bash float addition code example

Example 1: bash sum float numbers

bc <<< '0.3333+0.6666' # Get sum of floats in bash
0.99

Example 2: bash float

bc <<< '0.3333+0.6666' # Get sum of floats in bash.
0.99			#Same for Substraction and Multiplication
bc -l <<< '10/3' # Fast way to get division
3.33333333333333333333
bc <<< 'scale=2; 10/3' #Define also how many decimals to take in scale
3.33

Example 3: bash sum floating point numbers

bc <<< '0.3333+0.6666' # Get sum of floating points in bash
0.99