Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
When I write
ceil(0.29999999999999, 0.1)
I expect
0.3
--> OK
When I write
ceil(0.3, 0.1)
I expect
0.3
--> OK
When I write
ceil(ceil(0.29999999999999, 0.1), 0.1)
I expect
0.3
--> KO, QlikView gives me
0.4
Because
ceil(0.29999999999999, 0.1)
returns in fact
0.30[...]01
Why?
ps: the workaround
ceil(0.299999 * 10) / 10
works.
See this blog post: Rounding Errors
See this blog post: Rounding Errors
I said
ps: the workaround
- ceil(0.299999 * 10) / 10
works.
but in facts, when I'm dealing with interval match, it doesn't work.
I have some calculated scores.
I want to round them to the upper 1/10th and apply to them a label:
Interval:
LOAD * INLINE [
From, Start, Label
0, 0, None
0.1, 0.3, Few
0.4, 1, Many
1.1, , Too much
];
Values:
LOAD
*,
//ceil(A / B, 0.1) AS Value
ceil(A * 10 / B) / 10 AS Value
;
LOAD * INLINE [
Id, A, B
1, 0, 10
2, 1, 10
3, 29999, 100000
];
IM:
IntervalMatch (Value)
LOAD
From,
Start
RESIDENT Interval;
For my Id "3", the score is "29999 / 100000", that is "0.29999" that should be rounded at "0.3" (upper 1/10th), so the Label should be "Few".
But as the round workaround doesn't returns "0.3" nor "0.4" (but "0.30...01"), my line #3 has no Label