2

This question already has an answer here:

This is what I get

🐷 echo $((5/2))
2

How to make $((5/2)) giving me 2.5 ?

marked as duplicate by steeldriver, Jeff Schaller, phk, Gilles command-line May 20 '17 at 12:36

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • bc -l <<< 'scale=2; 5/2' – RomanPerekhrest May 20 '17 at 11:01
  • 1
    your $PS1 is quite funny. any way you need to use another shell like ksh93, yash or zsh, or use another tool for the maths – phuclv May 20 '17 at 11:08
  • 1
    $((5/2)).$((10*5/2%10)) (j/k) – frostschutz May 20 '17 at 11:18
  • @LưuVĩnhPhúc it is unicode, so any shell supporting unicode will work. That is all of them, though some struggle with non-ascii, when calculating widths. However you may need to install a new font, maybe a different terminal emulator. – ctrl-alt-delor May 20 '17 at 13:21
2

You can't. Bash will only work with integers. For more precision, use something like bc.

Not the answer you're looking for? Browse other questions tagged or ask your own question.