We have problems with some mathematical calculations.
If I add a dword to an integer (less than 0) and assign the result to a usual then I get an overflow.
Code: Select all
[Fact];
METHOD Test_CastUsualToInt() AS VOID STRICT
LOCAL Number1 AS INT
LOCAL Number2AsDword AS DWORD
LOCAL Number2AsInt AS INT
LOCAL Summe1 AS USUAL
LOCAL Summe2 AS USUAL
LOCAL Summe3 AS INT
LOCAL Summe4 AS INT
Number1 := -55
Number2AsDword := 1
Number2AsInt := 1
Summe1 := Number1 + Number2AsDword <== Summe1 = {4294967242} (Float) ???
Summe2 := Number1 + Number2AsInt
Summe3 := Number1 + Number2AsDword
Summe4 := Number1 + Number2AsInt
Assert.Equal((int)Summe1, -54) <== fails: actual value -2147483648
Assert.Equal((int)Summe2, -54)
Assert.Equal(Summe3, -54)
Assert.Equal(Summe4, -54)
Regards
Thomas