Limit decimals


ethushara

Recommended Posts

Hi,

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.

 

BR,

Thushara

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

Archived

This topic is now archived and is closed to further replies.