# Best approach for formatting result values?

**URL:** <https://forum.opentap.io/t/best-approach-for-formatting-result-values/122>\
**Category:** Technical\
**Tags:** ks8400-editor\
**Created:** [November 13, 2020, 4:53pm UTC](https://forum.opentap.io/t/best-approach-for-formatting-result-values/122 "2020-11-13T16:53:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![GoranJohnsson](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/goranjohnsson/32/140_2.png) [@GoranJohnsson](https://forum.opentap.io/u/GoranJohnsson)\
**Post date:** [November 13, 2020, 4:53pm UTC](https://forum.opentap.io/t/best-approach-for-formatting-result-values/122/1 "2020-11-13T16:53:56Z")

</div>

What is the best way to control numeric format for TestStep results? Say I want the value to be shown with two fractional digits (0.62) and perhaps also with a unit (0.62dB). Should I add a FormattedResult property in addition to the Result property?

 ![image](https://us1.discourse-cdn.com/flex020/uploads/opentap/original/1X/22d325c507e5a75084f35a186f05f7a028ed08c2.png)

---

<div class="post-metadata">

**Author:** ![brennen\_direnzo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/brennen_direnzo/32/6_2.png) [@brennen\_direnzo](https://forum.opentap.io/u/brennen_direnzo)\
**Post date:** [November 13, 2020, 9:00pm UTC](https://forum.opentap.io/t/best-approach-for-formatting-result-values/122/2 "2020-11-13T21:00:39Z")

</div>

@GoranJohnsson have you looked at the Unit attribute? I believe that solves most of your problems. It will easily allow for units and engineering prefixes, but there is also a StringFormat setting that will allow you to define units of precision, hex, binary, etc.

The Units attribute example is here:

> <https://gitlab.com/OpenTAP/opentap/-/blob/master/sdk/Examples/PluginDevelopment/TestSteps/Attributes/UnitAttributeExample.cs>

We leverage the standard .NET String Format syntax:

> **[Standard numeric format strings](https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings)**
>
> In this article, learn to use standard numeric format strings to format common numeric types into text representations in .NET.

---

<div class="post-metadata">

**Author:** ![GoranJohnsson](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/goranjohnsson/32/140_2.png) [@GoranJohnsson](https://forum.opentap.io/u/GoranJohnsson)\
**Post date:** [November 17, 2020, 4:13pm UTC](https://forum.opentap.io/t/best-approach-for-formatting-result-values/122/3 "2020-11-17T16:13:16Z")

</div>

Great, seems to do the work! It is a challenge to find out all possibilities and capabilities…

 ![image](https://us1.discourse-cdn.com/flex020/uploads/opentap/original/1X/c186cdcb4a84c000fe6e5ed264aa6351868f630a.png)

---

<div class="post-metadata">

**Author:** ![david-wsd](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/david-wsd/32/204_2.png) [@david-wsd](https://forum.opentap.io/u/david-wsd)\
**Post date:** [November 19, 2020, 6:20pm UTC](https://forum.opentap.io/t/best-approach-for-formatting-result-values/122/4 "2020-11-19T18:20:10Z")

</div>

Hi @GoranJohnsson, just curious, how did you get that result in the Step Settings panel, with what appears to be a radio button? Is that a custom IControlProvider, or does TAP have some built-in functionality I’m not aware of?

---

<div class="post-metadata">

**Author:** ![GoranJohnsson](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/goranjohnsson/32/140_2.png) [@GoranJohnsson](https://forum.opentap.io/u/GoranJohnsson)\
**Post date:** [November 20, 2020, 9:24am UTC](https://forum.opentap.io/t/best-approach-for-formatting-result-values/122/5 "2020-11-20T09:24:35Z")

</div>

@david-wsd Are you referring to the value format or the “radiobutton”?

The value format comes from the settings attribute:  
[Output]  
[Unit(“dB”,UseEngineeringPrefix:true,StringFormat:“F2”)]  
public double Result { get; private set; }

The “radiobutton” is just the standard output icon

---

<div class="post-metadata">

**Author:** ![david-wsd](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/david-wsd/32/204_2.png) [@david-wsd](https://forum.opentap.io/u/david-wsd)\
**Post date:** [November 20, 2020, 6:29pm UTC](https://forum.opentap.io/t/best-approach-for-formatting-result-values/122/6 "2020-11-20T18:29:45Z")

</div>

@GoranJohnsson Yes, the radio button. You answered my question, thanks! The Output attribute is what I was looking for.
