Skip to main content
Solved

String Formatting leading zeros

  • November 21, 2019
  • 1 reply
  • 214 views

reidm35
Forum|alt.badge.img

Hi there,

I want to convert an attribute so it always has four digits, and two decimal places. As an example, if I have . 6.5 as the source, I want the output as 06.50.

I've used the expression 04.2f in a string formatter, but this doesn't seem to be working for all of my attributes

As an example if my source attribute is 50.7, it recognizes the format and the output is 50.70. But if I have an attribute with one single digit before the decimal place like 7.28 the output is still 7.28 and not 07.28

Let me know if you can help.

-Reid

Best answer by reidm35

Oops I figured it out! The proper input for the String Formatter is 05.2f as the decimal point is being used as a part of the string. 5 is the width and 2 is the precision.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

1 reply

reidm35
Forum|alt.badge.img
  • Author
  • 21 replies
  • Best Answer
  • November 21, 2019

Oops I figured it out! The proper input for the String Formatter is 05.2f as the decimal point is being used as a part of the string. 5 is the width and 2 is the precision.