2014-06-16 96 views
1

相對this question,我想定義功能的BC m4宏:M4預處理BC宏觀

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")) 

但如何擴大B中其他變量Ç說法,如:

define(`ONEPOINTTWO', `1.2') 
define(`TWO', `2') 

BC(ONEPOINTTWO*TWO) 
=> 2.4 

謝謝

回答

2
define(`BC', `syscmd(echo "scale=6; print $1" | bc)') 

則:

BC(ONEPOINTTWO*TWO) 
=> 2.4