Sign in to follow this  

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.




Share this post

Link to post
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)


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this