Page 1 of 1

Empower Custom Field Round Operator

Posted: Fri Apr 09, 2010 12:29 pm
by johan.gustafsson
Hello,

Is there anybody out there who knows how the
ROUND operator works when you use it in a
Custom Field.
I think that you must use it like this
ROUND(Field,x)
Where field is the number you want to round and
x is the number of signicant figuers you want.
I'we tried some different things to get 3 significant number
x=3
x=0.001
x=1E-3

But they all give me rubbich as result, but still a result

Anybody.........
Please.......

Best regards / Johan

Posted: Fri Apr 09, 2010 12:50 pm
by DR
We typically use it as a modifier to a regular calculation.
ie
Retention Time/CCalRef1[Retention Time] (generating a relative retention time)
becomes
ROUND(Retention Time/CCalRef1[Retention Time],-2)

the same thing limited to 2 decimal places - either way, a calculated field (no, I do not know why it's -2 instead of 2, I just found a working example).

Gererally speaking, I prefer limiting precision either when writing the custom calculation or in the appropriate column of a report's table(s).

As far as i know, all of these options limit you to a specific number of decimal places, they know nothing of significant figures...

rounding

Posted: Fri Apr 09, 2010 1:59 pm
by EmpowerGuru
Your example will round at three places and replace the remaining precision with zeros. The round function works fine.

You can also truncate using the round function

hi

Posted: Fri Apr 23, 2010 1:57 am
by vishious
hi guys
How do you get it to truncate?
You said that round -2 will truncate to 3 then round to 2
But how do we just truncate?

And another thing was in the report when we put precision 2 it rounds to 2decimals
How do we make it truncate at 2?
Should i just put a precision of 3?

vish

Posted: Fri Apr 23, 2010 1:01 pm
by DR
Altering precision simply alters how many decimal places a number is displayed to, with the last place being rounded. The number itself is not altered for calculation purposes.

Using the round function actually alters the number and this can alter calculated results, so use this function with caution.

Posted: Mon Aug 30, 2010 1:55 pm
by EmpowerGuru
Truncating:

If you subtract half of the precision you want to round to, and then round, it is equivalent to truncating. The only problem is that the number will be truncated but be followed by a string of zeros.

So, to truncate to two decimals place, subtract 0.005, then round to 2 places.