Linx Main Linx Help

2 decimal places

Hi Support,

I need to display a decimal only to 2 places after the comma or dot
How do i do it?

Thank you

Hi Brian,

I’m assuming you’ve got a Decimal object (MyNumber1) with a value (i.e. 3.1474436)

Then you want to use it as a String with only 2 decimals.

In your String’s assignment, you can do the following expression:

= MyNumber1.ToString(“0.##”)

This will give “3.15”

Please let me know if this doesn’t work for you.

Regards,
Dawie

Thank you for the feedback Dawie.
What confused me here is that in the expression editor it does not give you the option of ToString then you type .(dot)
image

Also be aware of the difference between using # and 0:
“#” will output the digit of one exists.
“0” will output the digit of one exists and 0 if not.

e.g.
Where decimal = 1.2
0.## will output 1.2
0.0# will output 1.2
0.00 will output 1.20

Noted thank you Gawie

Great news. With the new version of Linx (5.16) some nice updates were made on the String functions. For instance, you can now do ToString(“0.00”) on doubles and decimals, and Linx will help you with Intellisense. Get the latest version https://linx.software.