Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Assignment and Kind

gelarimer
Beginner
778 Views

iret below is defind as a 4 byte integer, and Loword(), a win32 macro, returns a 2 byte integer. Should the assignement be stated as,

iret = Loword(wParam)

or,

iret = Int4(Loword(wParam))

Thank you for a reply.

0 Kudos
5 Replies
Steven_L_Intel1
Employee
778 Views
Either one is ok. Fortran defines implicit conversion between numeric types and kinds. But you'll get sign-extension which you may not want. Consuder using zext instead of int4.
0 Kudos
gelarimer
Beginner
778 Views

Thank you.

Also, I noticedin the documentation for INT (Chap. 9 Intrinsic Procedures) that the table with Specific names is missing the names for the 1st twoitems. Can you tell me what these Specific names are?

0 Kudos
Steven_L_Intel1
Employee
778 Views
There aren't specific names for those. Specific names are a relic of Fortran 66 and should generally be avoided.

Use generics, with the optional KIND= specifier if needed. For example:

INT (X,1)
0 Kudos
Jugoslav_Dujic
Valued Contributor II
778 Views
You have to be very careful with LOWORD/HIWORD. I'm not sure what's the exact prototype of VF-supplied ones, but I tend to use the following statement functions instead, as I've been badly beaten with it:

INTEGER XLOWORD, XHIWORD, SLOWORD, SHIWORD

XLOWORD(i) = IAND(i, Z'FFFF') !Unsigned versions
XHIWORD(i) = ISHL(i, -16)
SLOWORD(i) = INT(INT(IAND(i, Z'FFFF'),2)) !Signed versions
SHIWORD(i) = INT(INT(ISHL(i, -16),2))

The usage depends on the context, and what the API documentation says that the result should be casted into -- WORD means "unsigned", short means "unsigned".
The difference comes to light when the e.g. bit 15 of the loword/hiword is set. (E.g. Hex 0000FFFF - The "unsigned" versions will return 65535, and signed -1).

For example, mouse messages (WM_MOUSEMOVE) can contain negative coordinates when the mouse is captured; in this case, signed versions are called for. If you, OTOH, use the signed version for WM_COMMAND, your control IDs greater than 32767 will not work.

I (hope I) have the complete and correct list of usages per window message (that's the most common place where *LOWORD is used).
0 Kudos
gelarimer
Beginner
778 Views
Thanks Steve, Jugoslav. Info was very helpful. Jugoslav, thanks for the detailed info on using LOWORD/HIWORD: something I had not thought about before now.
0 Kudos
Reply