How do you do a floating point arithmetic in shell script?

Ngoc Hue

New member
How do you do a floating point arithmetic in shell script?
Answer
For floating point arithmetic (where 3/2=1.5)
  1. bash awk “BEGIN {print 10/3}” (low precision)
  2. bash echo “10/3″|bc -l (high precision)
  3. fish math -s4 10/3.
  4. zsh* echo $((10./3))
 

Tìm kiếm

Back
Top