Negative HEX numbers no longer working in latest builds?

 

In MT5 Build 3091, the result of executing this line:

Print(-0xFF);

is this:

4294967041

In MT4, it is still the same as before:

-255


Why the change? Will it hold in later builds?

 
Andriy Moraru:

In MT5 Build 3091, the result of executing this line:

is this:

In MT4, it is still the same as before:


Why the change? Will it hold in later builds?

Print(StringFormat("%i", -0xFF));

I believe this will work on both MT4 and MT5.

My guess as to why the Print is behaving differently on both versions is because MT5 is using 64 bits numbers
and the sign bit is being put at the 32 bit instead of the 64 one, so it does looks like a compiler bug.
 
Alexandre Borela #:

I believe this will work on both MT4 and MT5.

My guess as to why the Print is behaving differently on both versions is because MT5 is using 64 bits numbers
and the sign bit is being put at the 32 bit instead of the 64 one, so it does looks like a compiler bug.

This isn't limited just to Print(). The following if-statement is also true in MT5 and false in MT4:

if (0 < -0xFF)
 
Andriy Moraru #:

This isn't limited just to Print(). The following if-statement is also true in MT5 and false in MT4:

It's definitely a compiler bug. A workaround for that case is to express the full 64 bit value.

if (0 < -0x00000000000000FF)
Reason: