Download MetaTrader 5

problem with normalizedouble? - page 2

To add comments, please log in or register
Alain Verleyen
Alain Verleyen 2016.06.03 07:14  

Here and here: "except with zero never compare doubles for equality" (WHRoeder).

Yes except with 0, that means 0 is always 0.

By the way it's true for all integers up to 2^53 = 9,007,199,254,740,992 A double can represent all these integers accurately.

But what if you have two doubles a,b you shouldn't do if (a==b) but if (a-b==0.0) should work?

That's exactly the same.

But what if this works 99 times and then it fails?

No, it's not reliable, the documentation provides 2 ways to do it correctly (and a lot of posts on this forum).

To add comments, please log in or register