Forum Discussion
Magnum_IP
Nimbostratus
Feb 07, 2013Hex to Dec in an iRule
Can anybody help?
I need to convert a a hex number to decimal in an irule. The hex number can be in one of 2 formats eg.
0x01 0xf4
01f4
I would like to convert this to its dec...
Joel_Moses
Nimbostratus
Feb 07, 2013This isn't too hard.
For the first format, you'll want to bundle both hex values into a single one (normalize them) and process it like you would the second format. For the second format, it's very simple:set hex "0x01f4"
set decimal [expr $hex]
or
set hex "0x01f4"
scan $hex %x decimal
That would produce "500" as you want in $decimal.
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