Bash Multiplying Decimal to int

后端 未结 5 1928
花落未央
花落未央 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 10:00

    this works:

    
    PRICE=1.1
    QTY=21
    RES=$(echo "scale=4; $PRICE*$QTY" | bc)
    echo $RES
    

提交回复
热议问题