Announcements
cancel
Showing results for
Did you mean:
Contributor

Rounding formula

Rounding  value

ROUND(0.225,0.01)=0.23

If i'am going to use

Round (0.045*5,0.01)= 0.22

Why are the results different?

1 Solution

Accepted Solutions
Partner - Champion III

Hi

Read Henric's post as suggested by Ashfaq.

0.045 * 5 is calculated internally as two binary numbers, so is almost, but not quite, equal to 0.225. In this case, it appears as if, internally, its something like 0.224999999999999999..., which is being rounded down (correctly), to 0.22.

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
3 Replies
Champion III

Did you check this

http://community.qlik.com/blogs/qlikviewdesignblog/2013/12/17/rounding-errors

=Ceil (0.045*5,0.01) will return you 0.23

Regards

ASHFAQ

Partner - Champion III

Hi

Read Henric's post as suggested by Ashfaq.

0.045 * 5 is calculated internally as two binary numbers, so is almost, but not quite, equal to 0.225. In this case, it appears as if, internally, its something like 0.224999999999999999..., which is being rounded down (correctly), to 0.22.

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Partner - Specialist II

Further to other answers, have you tried double-rounding ...

=round(round(0.045*5,'0.001'),'0.01')

... it works on that example, and a quick check for 1000 numbers in a table chart all worked correctly, however I would fully test it and following Henric's advice is probably the best advice.

flipside

Community Browser