Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

What is the best operator to use when comparing numbers?

Hi all, I was wondering whether the TCL language treats everything as a string and choosing the fastest (least load on the CPU, if it needs to do conversions) and most correct operator. for example:

set x 2
if {$x == 2}
if {$x eq 2}
if {$x eq "2"}   

Many thanks in advance, it would be good to put this discussion in the team to rest.

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Hi,

You are correct in regards to TCL having one data type (string).

This can be converted into an integer on the fly, with the operator '=='

If you don't need to do numerical operations, it is not recommended to do conversions.

Best Regards,

Morten

0