changing decimal places programmatically

how do i change the decimal place of a decimal variable using code? For example, after manipulating the variable, result looks something like 0.325, i only want it to display two decimal points. Reason i want it done programatically is because i have to add a string value to the variable. So it would look like +0.325. Any help will be greatly appreciated.

Check out the ROUND function

NewNumber := ROUND(Number [, Precision] [, Direction])

the Precision allows you to specify the decimal places to use.


would the fomat for precision be 2:2? for example

Number := ROUND(2.07,2:2)

Hi, it would be 0.01 to get 2 decimal places,0.001 to get 3 decimal places etc…


Thank you very much, it works like a charm.

Just another hint: If you want to tell the system the number of decimals (e.g. write “3” for three decimals) instead of “0.001” you may use

1 / (POWER(10, 3)); // = 0.001
1 / (POWER(10, 5)); // = 0.00001
1 / (POWER(10, 0)); // = 1