Archived

This topic is now archived and is closed to further replies.

Turner Brown

What are WORDs and DWORDs?

Recommended Posts

All of the windows programs I''m looking at have a bunch of DWORDs in them. I''m assuming they are a type of struct, but I''m not sure of their use exactly. I looked them up in my compiler''s help section, and all I could find was that a WORD is 16 bits and a DWORD is 32 bits. I haven''t had too much trouble with them, since most of the tutorials I''m using just sort of get them as a return value from a function, and put them back into a different function as a parameter right away - I''ve never seen them actually read, or used, or manipulated directly. So my questions are, what are a WORDs and DWORDs? What are they used for? How can I manipulate them, compare them, etc? And will I ever need to be able to that? Thanks in Advance

Share this post


Link to post
Share on other sites
Well WORD and DWORD are not data structures persay, they are data types, and you use them the same as you would BYTE. I assume you have used the BYTE type before...same idea, just a little bigger:

Byte = 8 bits
Word = 16 bits
DWord = 32 bits

Hope that helps.

Edited by - Xorcist on March 16, 2001 9:27:15 PM

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
A WORD is typically an unsigned 16-bit integer. A DWORD is an unsigned 32-bit integer.

If you look in windef.h you''ll find them declared like this:

typedef unsigned short WORD;
typedef unsigned long DWORD;

The C++ specification doesn''t guarantee that types will always be the same size. For example, some compilers treat integers as 32 bits, while others only use 16 bits.

WORD and DWORD will always be defined to use 16 bit and 32 bit quantities, respectively.

- Matt

Share this post


Link to post
Share on other sites
I don''t think so... as far as I know, BYTE, WORD, and DWORD are all unsigned types, where as SHORTINT, INT, and LONGINT are. The difference is this:

Valid DWORD values range from 0..4294967295
Valid LONGINT values range from –2147483648..2147483647

Share this post


Link to post
Share on other sites