Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello
Please look into attached .qvw file.
There is a text object within, rounding numbers to two decimal places, some of them correctly, some of them incorrectly.
Can anybody explain it?
Is it known bug?
QV 11.20.12018.0 SR3 64-bit
Many thanks in advance.
Vlastimil
Taking Bill Markham 's idea further. You could add a much smaller number, to ensure you don't get a different number to what you expect.
You can also put this into a variable. So, if you create a variable called vMyRound with the following in:
round($1 + 0.0000000001, $2)
You can then call it in an expression like this:
$(vMyRound(14.235, 0.01))
The technique of passing parameters into a variable is incredibly useful, thanks to Stephen Redmond for bringing it to my attention some time back.
Steve
The short answer is: No it is not an error. This is expected behaviour of software that uses a binary number representation internally. What happens is that Round() rounds to nearest binary number - not to nearest decimal number.
Read the blog post behind Massimo's link, and you will understand.
HIC
Thanks to all.
Vlasta
Hi
This expression works, as in adding 0.001 to number and rounding to 0.01.
round( (1.235+0.0001 ), 0.01 )
It is horrible frig, maybe somebody will have a more elegant solution.
Best Regards, Bill
Taking Bill Markham 's idea further. You could add a much smaller number, to ensure you don't get a different number to what you expect.
You can also put this into a variable. So, if you create a variable called vMyRound with the following in:
round($1 + 0.0000000001, $2)
You can then call it in an expression like this:
$(vMyRound(14.235, 0.01))
The technique of passing parameters into a variable is incredibly useful, thanks to Stephen Redmond for bringing it to my attention some time back.
Steve