# Format pattern for binary and hex display values

**URL:** <https://forum.inductiveautomation.com/t/format-pattern-for-binary-and-hex-display-values/8318>\
**Category:** Ignition\
**Created:** [April 16, 2014, 1:06am UTC](https://forum.inductiveautomation.com/t/format-pattern-for-binary-and-hex-display-values/8318 "2014-04-16T01:06:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![iamthebull](https://avatars.discourse-cdn.com/v4/letter/i/58f4c7/32.png) [@iamthebull](https://forum.inductiveautomation.com/u/iamthebull)\
**Post date:** [April 16, 2014, 1:06am UTC](https://forum.inductiveautomation.com/t/format-pattern-for-binary-and-hex-display-values/8318/1 "2014-04-16T01:06:05Z")

</div>

Please add format patterns that will display integer values in binary or hex.

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [April 16, 2014, 2:46pm UTC](https://forum.inductiveautomation.com/t/format-pattern-for-binary-and-hex-display-values/8318/2 "2014-04-16T14:46:48Z")

</div>

The number format patterns in Ignition are [Java format patterns](http://docs.oracle.com/javase/tutorial/i18n/format/decimalFormat.html#numberpattern) which don’t have a pattern for hex or binary display.

You could use Python to convert the integer to hex and display it as a string. The following will do that:`myInt = system.tag.read("Random/RandomInteger1").value
event.source.parent.getComponent('Label').text = hex(myInt)`

If you need to do this in an expression, you should request a toHex() and toBinary() function that would take an int and return a string.

---

<div class="post-metadata">

**Author:** ![iamthebull](https://avatars.discourse-cdn.com/v4/letter/i/58f4c7/32.png) [@iamthebull](https://forum.inductiveautomation.com/u/iamthebull)\
**Post date:** [April 16, 2014, 9:23pm UTC](https://forum.inductiveautomation.com/t/format-pattern-for-binary-and-hex-display-values/8318/3 "2014-04-16T21:23:41Z")

</div>

Ok…

Please add toHex() and toBinary() expression functions that would take an int and return a hex or binary string respectively representing the integer value.

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [April 16, 2014, 9:40pm UTC](https://forum.inductiveautomation.com/t/format-pattern-for-binary-and-hex-display-values/8318/4 "2014-04-16T21:40:21Z")

</div>

I should have looked before I typed. 🙂

For 7.7, we’ve already implemented toHex() and fromHex() as expression functions. We expect that to be released sometime this quarter.

I’ll put a note in that you would like to have toBinary() as well.

---

<div class="post-metadata">

**Author:** ![iamthebull](https://avatars.discourse-cdn.com/v4/letter/i/58f4c7/32.png) [@iamthebull](https://forum.inductiveautomation.com/u/iamthebull)\
**Post date:** [April 16, 2014, 9:41pm UTC](https://forum.inductiveautomation.com/t/format-pattern-for-binary-and-hex-display-values/8318/5 "2014-04-16T21:41:47Z")

</div>

Perfect. Thanks.

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [April 30, 2014, 4:35pm UTC](https://forum.inductiveautomation.com/t/format-pattern-for-binary-and-hex-display-values/8318/6 "2014-04-30T16:35:19Z")

</div>

More new expression functions have been added to Ignition 7.7:  
[ul]toBinary(int)  
fromBinary(string)  
toOctal(int)  
fromOctal(string)[/ul]

Hope this does everything you need.

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [April 30, 2014, 7:28pm UTC](https://forum.inductiveautomation.com/t/format-pattern-for-binary-and-hex-display-values/8318/7 "2014-04-30T19:28:10Z")

</div>

Thanks! Those will be useful on occasion, saving some Python scripting.
