[LC++]a bit [OT]: float-dificulty
Chris Vine
chris at cvine.freeserve.co.uk
Mon Jul 24 05:39:05 UTC 2006
On Sunday 23 July 2006 21:42, Julien Claassen wrote:
> Hi Crhis!
> Unfortunitely it's a bit more complicated than a simple loop. I use it in
> a set function, which can be triggered from in/decrement functions and by
> just entering a value. Should I
> 1. just add 0.0001 to my max value, for this is the highest precision
> allowed with the functions or
> 2. look for some kind of imprecision-function, which can truncate a value
> to a given number of digits?
> I think 2 would be cleaner. Is there a function like that, which is
> efficient. This is all for a UI-library.
> Kindest regards and thanks!
> Julien
Boost has something on this, which might be of value:
http://www.boost.org/libs/test/doc/components/test_tools/floating_point_comparison.html
But I think this is also a useful explanation and gives you some imprecision
approachs which avoid a third party library:
http://www.cygnus-software.com/papers/comparingfloats/Comparing%20floating%20point%20numbers.htm
Chris
More information about the tuxCPProgramming
mailing list