What is DWORD?

What is a DWORD and why use it? I read that its basically an unsigned long. But why used unsignedlong/dword when i can just use something simple like int?
This hasnt really aswered my question although it was somewat helpful
What my question is asking: What is a DWORD (aside from it being a double word) and why use it as opposed to int or unsigned long or long or any other data types like that. My second question is: why use unsigned long or long or other data types when I can simply use int or var? That link answered the 2nd question but not the first.
DWORD is a typedef for, as you mentioned, 'double word' sized integers. It's a way of sizing them, rather than giving bit numbers. In general:
8 bit = BYTE
16 bit = WORD
32 bit = DWORD
64 bit = QWORD (quad-word).

They are useful, because that way you know you have, for example, 32 bits worth of space to store information in. On the other hand, just using int means that you might have 32, but you could just as well only have 16 bits of data (depending on the compiler and target architecture).

EDIT:
Actually, I just did some more reading and it turns out I was kind of wrong :)

See this: https://en.wikipedia.org/wiki/Word_(computer_architecture)

Basically, the gist of it is that a WORD is traditionally the size of a memory pointer, the 'most natural' size of data that can be read. DWORD is twice that size, QWORD is four times, etc.

Now, traditionally that would be 16 bits of data; a legacy to the 16 bit MSDOS days. Nowadays, though, it's generally 32 bit or 64 bit, according to your computer's architecture. So, really, a DWORD on modern computers should be 128 bit!

However, for 'backwards compatibility reasons', the size of each has stayed the same. So, the WORD type is 16 bits, even though it technically should be 64 bits, like a computer word.

TLDR; what I wrote above is technically correct, just not for the reasons I gave.

Also, I should have mentioned that typically you shouldn't use them; they're rather obscure and only really make sense to use if you're interfacing with the WinAPI.
Last edited on
hmm, i see. interesting
Topic archived. No new replies allowed.