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
精彩评论