Qlik Community

Ask a Question

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Our next Qlik Insider session will cover new key capabilities. Join us August 11th REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
syahfira
Partner
Partner

Bug in Class() Function

Hi. I have found a bug with the QS Class() function.

The bug is about the some numbers are not falling into its class itself.

For example : 0.3, 0.6, 0.7.
Please find tables I have created in QVF attached  for reference.
But, for other numbers, it fall perfectly on its respective interval. Hence, this is consider as bug?
Please correct me if am wrong.
 
Thank you 😍
Labels (3)
1 Solution

Accepted Solutions
tresesco
MVP
MVP

Hi,

This seems to be a NOT bug, but a known issue for floating point comparison for equality. Decimal numbers can't be precisely represented in binary format. Therefore, comparing decimals for equality in binary is unsafe. And in your sample test you must have noticed the bug (you noticed) is exactly where the check is for equality. 

 

For better understanding you might want to have look at the very well-thought writing here :https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/ 

View solution in original post

5 Replies
sunny_talwar

The app attached is without data loaded into it... and we can't reload because we don't have the source... can you provide the source file or the app with data loaded into it

syahfira
Partner
Partner
Author

Hi Sunny, sorry for the previous attachment.
I have attached the correct qvf file.
Thank you.
tresesco
MVP
MVP

Hi,

This seems to be a NOT bug, but a known issue for floating point comparison for equality. Decimal numbers can't be precisely represented in binary format. Therefore, comparing decimals for equality in binary is unsafe. And in your sample test you must have noticed the bug (you noticed) is exactly where the check is for equality. 

 

For better understanding you might want to have look at the very well-thought writing here :https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/ 

View solution in original post

syahfira
Partner
Partner
Author

Hi Tresesco, thanks so much for the reply. Now, I understand about these floating points. 

Managed to make the class() function work for my set analysis.

 class rounding.jpg

tresesco
MVP
MVP

Good to know. Please close the thread by giving 'Like' and/or choosing as correct answer.