I made some changes to the Hiword and Loword wiki pages because they were using UInteger whose size depends on the CPU size. The C code in the RTLib is using CUINT to force the numbers to be 32bit, so I changed the code to show use of ULong instead so it will always be 32bit.
Let me know if there are any problems there.
HiWord/LoWord
Re: HiWord/LoWord
OK, but I have not seen the corresponding commit in github yet ?
Re: HiWord/LoWord
When I compile the following (in 64-bit), I always see UINTEGER type variables:
Must we wait for a new fbc build ?
Code: Select all
#print typeof(HiByte(0))
#print typeof(LoByte(0))
#print typeof(HiWord(0))
#print typeof(LoWord(0))
Re: HiWord/LoWord
The code converts what ever you pass to it into a C UInteger: 32bits. It then masks out 16 of those bits. Even if you pass in an 64bits it is converting to 32. Even if it is returning 64 bits, it is still only working with 32. The Docs should then be changed to say it Expands to an Integer, not long, The description of the Macro at the top of the page was incorrect, still.
Re: HiWord/LoWord
And for LOBYTE and HIBYTE ?
For LOWORD and HIWORD documentation pages, maybe we can define the macros as:
For LOWORD and HIWORD documentation pages, maybe we can define the macros as:
Code: Select all
#define Hiword( expr ) Cuint((Cast(Ulong, expr) and &hFFFF0000) shr 16)
#define Loword( expr ) Cuint(Cast(Ulong, expr) and &h0000FFFF)
Re: HiWord/LoWord
Upon further reflection, the initial text of the doc is literally correct. The Cast to UInteger is what is happening behind the scenes in the compiler.
However, the macros only ever touch the bottom (most significant) 32bits of any number passed in, regardless of size. If you pass it a 64bit integer, the top 32bits are completely ignored.
It might as well be Casting to ULong because all other data is ignored. Is that what is intended? I am unsure how I feel about that, if it is. I will change to document back to reflect the original, but I think there might be grounds for discussion on what those macros should be doing.
However, the macros only ever touch the bottom (most significant) 32bits of any number passed in, regardless of size. If you pass it a 64bit integer, the top 32bits are completely ignored.
It might as well be Casting to ULong because all other data is ignored. Is that what is intended? I am unsure how I feel about that, if it is. I will change to document back to reflect the original, but I think there might be grounds for discussion on what those macros should be doing.