Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
rein_nigul
Contributor
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
jonathandienst
Partner - Champion III
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

View solution in original post

3 Replies
ashfaq_haseeb
Champion III
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

jonathandienst
Partner - Champion III
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
flipside
Partner - Specialist II
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