On Tuesday, 25 August 2015 at 14:54:41 UTC, Steven Schveighoffer wrote:
On 8/25/15 9:51 AM, "=?UTF-8?B?Ik3DoXJjaW8=?= Martins\" <[email protected]>\"" wrote:
     [...]

Sorry, I misunderstood what epsilon was (I think it's the smallest incremental value for a given floating point type with an exponent of 1). Because your number is further away than this value, it doesn't help.

You need to add something to correct for the error that might exist. The best thing to do is to add a very small number, as that will only adjust truly close numbers.

In this case, the number you could add is 0.1, since it's not going to affect anything other than a slightly-off value. It depends on where you expect the error to be.

As bachmeier says, it's not something that's easy to get right.

     [...]

these work because you have converted to double, which appears to round up.

-Steve

I didn't convert to double. My computations are all in double to start with, as you can see for my explicit types everywhere.

If you compile it with *GDC* it works fine. If you compile a port with clang, gcc or msvc, it works right as well. I suspect it will also work fine with LDC.

Reply via email to