Unexpected Format Expression Behavior

Would someone check me on this? Ignition Version 8.1.24.

When adding a format transform using a pattern with the % symbol the value is automatically multiplied by 100. I would expect the return to just be the pattern with the % tacked on.

Is/was this a bug that’s been addressed am I just can’t find reference to it, or is it expected behavior??

Same behavior on 8.1.20:

Not sure if it's a bug, but I agree, it's not what I would expect...

Oh, yea, I encountered that before !
Made me go "huh ?"

This is expected behavior. The user manual page on Format Transforms provides an example of the formatting that gets applied when using %.

3 Likes

I’ll accept that, but just seems a bit of an odd choice to me, especially considering you can select the Percent format, which I would expect to have this behavior.

Oh well now I know.

That doc page talks about the percent format for numeric types, not about putting a % sign in a pattern format.
That behavior is highly unintuitive.

I'll admit, I did read through the OP a bit too quickly. However, checking the formatting reference page in the user manual also indicates the behavior is expected.

Edit: Also, the last example in the table shows the pattern that should be used to not multiply the input by 100.

Take it up with Java:
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/DecimalFormat.html

Symbol Location Localized? Meaning
0 Number Yes Digit
# Number Yes Digit, zero shows as absent
. Number Yes Decimal separator or monetary decimal separator
- Number Yes Minus sign
, Number Yes Grouping separator
% Prefix or suffix Yes Multiply by 100 and show as percentage

I tried to call them but it somehow multiplied the phone number by 42.

7 Likes

That should have still yielded an answer (the answer). :grin: