I want to convert 8874M to GIGA so I did this
echo $(( 8874 / 1024 ))
but actually we get 8 ( while exactly results is 8.6 )
so what need to change in order to get the 8.6?
I want to convert 8874M to GIGA so I did this
echo $(( 8874 / 1024 ))
but actually we get 8 ( while exactly results is 8.6 )
so what need to change in order to get the 8.6?
Bash doesn't do floating point arithmetics. Use bc -l
instead:
bc -l <<< 'scale = 1; 8874 / 1024'
By setting scale
to 1, you get the "exact" result 8.6, not the real exact result of 8.66601562500000000000.