Forum Discussion
Kevin_Raison_74
Nimbostratus
Dec 08, 2005Exponentiation, involution
Can someone tell me how to accomplish pow(x,y) in F5's TCL implementation?
Thanks.
Kevin Raison
- 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_74
Nimbostratus
I 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_115
Nimbostratus
Raison, - Kevin_Raison_74
Nimbostratus
Thanks. 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.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects