开发者

an expression in tcl

I have a quest开发者_如何学JAVAion about the following statement in tcl

set hello [format %x [expr { 2**($D - 1)}]]

the proc takes $D as a parameter, I pass it as 1, but it complains syntax error in expression " 2**($D - 1)": unexpected operator *

can anyone helps?


Older versions of Tcl do not have an exponentiation operator **. You will need to use the pow function.

set hello [format %x [expr {int(pow(2, $D - 1))}]]

Do note that pow() returns a floating-point value

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜