2

This is what I get

 echo $((5/2))
2

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

sharkant
  • 3,560
  • 10
  • 30
  • 46
  • `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](https://unix.stackexchange.com/q/40786/44425), 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

1 Answers1

2

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

Waleed Hamra
  • 379
  • 1
  • 3
  • 9