Forum Discussion
Nathan_Pearce_4
May 21, 2010Historic F5 Account
Math problem (possible human error)
when RULE_INIT {
log local0. "Maths Test: 57 + 22: [expr {57 +22}]. 57 + 022: [expr {57 + 022}]"
}
Returns:
: Maths Test: 57 + 22: 79. 57 + 022: 75
Can anyone explain why this might be?
Tested on LTM VE but looking for verification on other platforms.
- Actually, that's not an error. When you are attempting to add "022", the TCL interpreter is treating that number as octal. octal 022 is 18 and 57 + 18 equals 75. The manual page for expr explains the rules on interpretation of numbers and their formats
- BTW, if you do want to ensure that a number is treated as an integer, you can use the scan command
[expr 57 + [scan 022 %d]]
- Nathan_Pearce_4Historic F5 AccountFantastic. Thanks Joe. The 022 I amusing is not a number I have control over (three digit value extracted from payload) so I was thinking about performing a trimleft on any zero's but your solution is much more elegant.
- Nathan_Pearce_4Historic F5 AccountThat was the last piece of the puzzle for a credit card/payments system transaction switch. You can find it in the Finance Group:
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