Bash Multiplying Decimal to int

后端 未结 5 1915
花落未央
花落未央 2020-12-30 09:10

I read price from user input. When i multiply the input with int like this

T=\"$((PRICE*QTY))\"|bc; gives line 272: 12.

5条回答
  •  执笔经年
    2020-12-30 09:51

    You can use mul=0.8 exp=200 texp=awk -vp=$mul -vq=$exp 'BEGIN{printf "%.2f" ,p * q}'

    Hope this is going to work.

提交回复
热议问题