相对于this question,我想定义该函数的BC
m4宏:
syscmd(bc <<< "scale=6; print ARITHMETIC_OPERATION_STRING")
注意:它只是处理bc
的算术运算,例如:syscmd(bc <<< "scale=6; print 1.2*2") => 2.4
我猜是这样的:
define(`BC', syscmd(bc <<< "scale=6; print $1"))
但如何扩展BC参数中的其他变量,例如:
define(`ONEPOINTTWO', `1.2')
define(`TWO', `2')
BC(ONEPOINTTWO*TWO)
=> 2.4
谢谢
答案 0 :(得分:2)
define(`BC', `syscmd(echo "scale=6; print $1" | bc)')
然后:
BC(ONEPOINTTWO*TWO)
=> 2.4