Linx Main Linx Help

2 decimal places

#1

Hi Support,

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

Thank you

0 Likes

#2

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

0 Likes

#3

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

0 Likes

#4

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

0 Likes

#5

Noted thank you Gawie

0 Likes

#6

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.

0 Likes