LO, HI functions using WORD as parameter and MATH inside switches it to inetger;
Original Reporter info from Mantis: jamie @jamie
-
Reporter name: jamie philbrook
Original Reporter info from Mantis: jamie @jamie
- Reporter name: jamie philbrook
Description:
I just tracked down a bug that really took me a while to find.
The LO/HI functions when used with a WORD type and +/- enclosed operations
will convert the results to a integer which is a 32 bit.
The Lo will return the lower WORD and HI the UPPER word instead.
Steps to reproduce:
Var
V:WORD;
Begin
V := 320;
ByteResult := LO(V-1); //this returns 63, which is correct, but there is an error regardless.
ByteResult := HI(V-1); // This returns 0, it should be returning 1;
What has happen is the V-1 operation converted it to an integer and thus ended up using the Integer version of the Functions.
Since my return types are BYTE, only the lower order gets loaded and the compiler never complained about the return type not being compatible.
If I Cast...
LO(Word(V-1)), all is well.
With my old D3 this works as expected, there is no conversion of types and WORD type is maintain.
So either a Document addition is needed or this resolved?
I don't see any comments about it in the DOCS.
Mantis conversion info:
- Mantis ID: 31998
- OS: Windows
- Build: released with 51630 Laz
- Platform: 32/64 bit etc.
- Version: 3.0.0