I'm confused as to how to handle floating point numbers in shell scripts. Is there a way to convert a number (string) read into a shell variable so that it can be used as a floating point decimal for calculation purposes? Or am I stuck with integrating C or Perl into my script?
Ex:
--input
read Number1 --number entered for example is .20
read Number2 --number entered for example is .30
Total
--or--
let Total=$Number1 + $Number2 --which I know only works for integers.
--output
printf "%0.2f" $Total=$Number1 + $Number2
I essentially want a total of two decimal numbers that have been read from the command line (i.e. .20+.30=.50 or Total), but printf will not compute the calculation as I have it coded. I'm at a loss...
Any insight would be appreciated,
--S