Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
sundarakumar
Specialist II
Specialist II

Calculation logic in text box


Hi Experts,

I tried writing the below in a text box

=101.02-101.01

The result 0.0099999999999909.

What could be the reason for this, how is this calculation being made in the back end.

Am using SR12.

Thanks in advance.

-Sundar

1 Solution

Accepted Solutions
petter
Partner - Champion III
Partner - Champion III

QlikView is using 8 byte IEEE 754 double precison floating point number format. It does not represent every possible value accurately. So the number you get is correctly calculated according to the number format and precision you can expect. You should use rounding for display and final reporting purposes. Have a look at Wikipedia and other sources about IEEE 754. Microsoft Excel also stick to this standard as most commercial software also does. It is a very good trade-off between speed, space and necessary precision.

View solution in original post

6 Replies
Clever_Anjos
Employee
Employee

Use round

=round(101.02-101.01,0.01)

maxgro
MVP
MVP

What could be the reason for this, how is this calculation being made in the back end.

Rounding Errors

petter
Partner - Champion III
Partner - Champion III

QlikView is using 8 byte IEEE 754 double precison floating point number format. It does not represent every possible value accurately. So the number you get is correctly calculated according to the number format and precision you can expect. You should use rounding for display and final reporting purposes. Have a look at Wikipedia and other sources about IEEE 754. Microsoft Excel also stick to this standard as most commercial software also does. It is a very good trade-off between speed, space and necessary precision.

petter
Partner - Champion III
Partner - Champion III

If you try the exact same calculation in Excel and increase the number of displayed decimals sufficiently you will get the same number in fact:

0,0099999999999909
sundarakumar
Specialist II
Specialist II
Author

Thanks All lot more to learn

sundarakumar
Specialist II
Specialist II
Author

Thanks for the reply, wanted to know what the logic was. Got it