Forum Discussion
5 Replies
Sort By
- Colin_Walker_12Historic F5 AccountThis is done via the normal TCL operator "**". You can find more about it here:Click here - http://tmml.sourceforge.net/doc/tcl/expr.html
expr { $x**$y }
- Kevin_Raison_74NimbostratusI tried the ** operator, but my BigIP says,
- Not sure why the "**" operator doesn't work but it seems it doesn't and I've tested it in several stand-along tcl interpreters as well.
set y 2000 set e 9 set t 2 if { $t == 0 } { if { $e > 0 } { set m 0 } elseif { $e < 0 } { log local0. "undefined exponentiation!" } elseif { $e == 0 } { set m 1 } } elseif { $t == 1 } { set m 1 } elseif { $e == 0 } { set m 1 } elseif { ($t < -1) && ($e < 0) } { set m 0 } elseif { $t == -1 } { if { [expr ($e & 1)] == 0 } { set m 1 } else { set m -1 } } else { for {set i 1; set m $t} {$i<$e} {incr i} { set m [expr $m*$t]; } } set x [ expr { int($y * $m) } ] puts $m puts $x
- Brian_Gupta_115NimbostratusRaison,
- Kevin_Raison_74NimbostratusThanks. I had implemented the same thing, but found the performance to be less than desireable. In the end, bit shifting solved my problem with acceptable performance results.