-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Number getComparableValue with maximumFractionDigits tests, fix. #192
Number getComparableValue with maximumFractionDigits tests, fix. #192
Conversation
ad1cbce
to
137c4da
Compare
@nomego @JockeCK @megheaiulian This is ready for review. |
cosmoz-omnitable-column-number.html
Outdated
return; | ||
} | ||
|
||
const decimals = this.minimumFractionDigits; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be maximumFractionDigits
? (We need min/max fraction tests obviously)
Why do we need the pow/parseInt? Aren't we passed this JS float stuff with .toFixed()? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nomego in the issue: #176
we have the: " 46,768 value with two decimals is 46,76
The user sets both to and from filter as 46,76.
This results that at least not the row with the value 46,768 is not shown."
My answer is: I have tried with toFixed but it rounds up the value (to "46.77" and this value is not in the 46.76 interval ). We need to truncate to two decimals without rounding.
https://stackoverflow.com/questions/4187146/truncate-number-to-two-decimal-places-without-rounding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, now I get it! And I wonder if the case was actually correct to begin with.
If we filter out values between 46,75 - 46,76, we shouldn't show a value with 46,768 since it's outside the range. However, if 46,768 is displayed as 46,76 then that's the error, it should be 46,77. But we should show 46,75xx.
Problem is with 46,7499 - it's outside the range but will be represented as 46,75. Same with 46,760001. I guess we should consider them 46,75 and include them, but that warrants rounding, not cutting off digits.
Also needs rebase |
137c4da
to
a25b09b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look good to me!
@nomego I have implemented some tests from your latest review. Also I have used toFixed again. This is ready for review. |
713370c
to
d4aebaf
Compare
Needs a rebase after #195 is merged. |
test: filter comparison uses minimumFractionDigits
46.768 should'n show in this range
d4aebaf
to
0c7a246
Compare
spaces
0c7a246
to
96aa216
Compare
fixes: #176
Implemented Test: item with age: 46.768 and amount: 2581 should be in the filtered items when filtering from 46.76 to 46.76 Done.
In cosmoz-omnitable-column-number.html added getComparableValue and added the check for minimumFractionDigits. Value is truncated to the specified decimals (2 in the test). Done.
Rebased on latest changes from master. Done.
Replaced minimumFractionDigits with maximumFractionDigits in column and range test. Done.
Implement Test: If we filter out values between 46,75 - 46,76, we shouldn't show a value with 46,768 since it's outside the range. Done.
restore toFixed to round up instead of truncate to n digits. Done.
Implement test: But we should show 46,75xx. Done.
Verify if: However, if 46,768 is displayed as 46,76 then that's the error, it should be 46,77. Done.