巴什乘法十进制为int [英] Bash Multiplying Decimal to int
本文介绍了巴什乘法十进制为int的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我读了用户的输入价格。当我乘的输入,这样INT
I read price from user input. When i multiply the input with int like this
T = $((PRICE * QTY))| BC
;给
行272:12.00:语法错误:无效的算术运算符(错误标记为.00)
或0.50
T=
"$((PRICE*QTY))"|bc
; gives line 272: 12.00: syntax error: invalid arithmetic operator (error token is ".00") or .50
取决于用户输入。我如何乘这两个变量,并得到以2个小分的总?
depending on user input. How do i multiply these two variables and get a total with 2 decimal points?
推荐答案
这个作品:
PRICE=1.1
QTY=21
RES=$(echo "scale=4; $PRICE*$QTY" | bc)
echo $RES
这篇关于巴什乘法十进制为int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文