Page 1 of 1

RoundTo()

Posted: Mon Jun 06, 2011 4:07 pm
by djrikki
Hi,

Either amend the current Round() function or provide a new function RoundTo().

The new/amended function will allow rounding to a number of decimal places - not just a straight integer round up.

Eg.

value = 21.1234

Round(value, 2) result = 21.12
Round(value, 3) result = 21.123
Round(value) result = 21

Re: RoundTo()

Posted: Tue Jun 07, 2011 2:05 am
by PEB
Try adding this one line to your script:
---
Function p_RoundTo(StartValue, DecimalPlaces) Return(Round(StartValue*10^DecimalPlaces)/10^DecimalPlaces) EndFunction
---

Now if value = 21.1234
p_RoundTo(value, 2) will give you 21.12
p_RoundTo(value, 3) will give you 21.123
p_RoundTo(value) will give you 21