How numbers are shown in a UUT report can be customized per value when creating the report. It can also be overridden when viewing the report using the format dropdown in the top right corner.
Format
The UUT report uses C-style printf formatting for numbers.
%[flags][width][.precision]specifier
In printf '%' is used to start a format, since it can have multiple arguments to format in the same text. The UUT report only has one argument, the value, so the format always starts with %.
[flags] is optional and can be used to add prefixes like +/- or 0x.
Flags | Description | Example |
- | Add padding after the number instead of before |
00154, 15400 |
+ | Adds a + if number is positive, - if number is negative | +154, -3092 |
(space) | Adds a space if the number does not have a sign | +154, -3092, 67 |
# | Adds the prefix for the number system, or for decimal formats a decimal point will always be shown. |
0x9a, 0b10011010, 67. |
0 | Uses 0 as padding instead of spaces | 00154 |
[width] is optional and a number that will be the minimum characters shown, i.e. with 5, 100 and 1000 will be shown as 00100 and 01000.
[.precision] is optional and a dot followed by how many decimals digits to show. For integer formats this is like [width] but with 0's instead of spaces.
specifier is required and is how a number should be shown.
Specifier | Description | Example |
d or i | Signed integer | 154, -3092 |
u | Unsigned integer | 154, 3092 |
b | Binary | 10011010, 110000010100 |
o | Octal | 232, 6024 |
x | Hexadecimal, lowercase | 9a, c14 |
X | Hexadecimal, uppercase | 9A, C14 |
f | Decimal number | 154.2, -3092.52 |
e | Scientific notation | 1.542e+2, -3.09252e+3 |
c | Shows the ASCII character for that number | Ü |
Examples
Format | Value | Output |
%i | 154.2, -3092.52 | 154, -3092 |
%12b | 154, 3092 | 000010011010, 110000010100 |
%#X | 154, 3092 | 0x009A, 0x0C14 |
%.2f | 152.2, -3092.52 | 152.20, -3092.52 |
%+e | 152.2, -3092.52 | +1.522e+2, -3.09252e+3 |
%c | 152 | Ü |
How to set format in WATS Client API
From WATS Client 6.1, most number properties in a UUTReport and it's steps have an accompanying -Format property. Ex. NumericLimitTest.NumericValue and NumericLimitTest.NumericValueFormat, Step.StepErrorCode and Step.StepErrorCodeFormat, UUTReport.ExecutionTime and UUTReport.ExecutionTimeFormat.
How to set format in WSXF/WSJF
From WATS 2022.1, most number properties in a WSXF or WSJF report has a -Format property. See WATS Standard JSON Format and WATS Standard XML Format for more information.
How to set format in TestStand
TestStand has settings that can be opened by selecting Edit Numeric Format in the Properties dialog for number variables. It also uses C-style printf formatting. From WATS Client 6.1, the TestStand add-on will use these settings in the report where it is supported.
Comments
0 comments
Please sign in to leave a comment.