Jos Timanta Tarigan wrote: > well in my case its a huge problem especially in the boundary. im doing a 2D > world animation and in my case 0.0000001 is not moving and 0 is moving so its > really significant :D > i think i decided to trick this by using a small value as comparison eg if x > < 0.001 then move ;) >
Rather than artificial decimal-based rounding, you should be comparing floating point numbers using a delta value. Essentially two numbers are the same if they are within a specific range of each other: this can be anything you want but typically is very small. Combined with simplifying your input equations to remove extraneous computations which create rounding errors to begin with, you can probably get it close enough. Computers are really not designed for floating point operations anyway: they certainly do them and do them quickly, but you will never get precision that would make a mathematician happy. -- John Gaughan http://www.jtgprogramming.org/
