Limit decimals


Recommended Posts


Please let me know how can i limit the decimal points in a value resulted from a calculation. When i create frequent email with some results of calculations, the emails comes with so many decimal points in the value as below.

Plant output(kW) : 518

Plant Factor - Daily : 30.75261904762

Plant Factor - Monthly : 49.14841614907


So please let me know how to limit this decimal points to 2 or 1.




Link to comment
Share on other sites

Depends on where you are doing it.  If you are simply using a variable value component, you can use the Precision parameter and it will display just that many decimals.  Elsewhere, you can use the format() function to format the data however you like.  Format() works just like the printf() function in C / C++ which has been around a long time.  There are many examples on the web, or in the DAQFactory User's guide.  But for example, if you have a variable "DailyPlantFactor" that you want to format to 2 decimals, you would do:

format("%.2f", DailyPlantFactor)


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.