Quad Word
Home * Programming * Data * Quad Word
According to Intel's definition of a x86 16-bit Word, a Quad Word refers a 64-bit word.
long long or long
Microsoft 64-bit C-compiler long is still 32-bit Double Word, while 64-bit GCC uses 64-bit Quad Words as longs. Other compiler require "long long" for 64-bit types.
typedef unsigned long QWORD; typedef unsigned long long QWORD;
Bitboards
Quad words are used as bitboard datatype:
typedef QWORD U64; typedef QWORD Bitboard;
Ranges
language | type | min | max |
---|---|---|---|
C, C++ | unsigned long long | 0 | 18,446,744,073,709,551,615 |
hexadecimal | 0x0000000000000000 | 0xFFFFFFFFFFFFFFFF | |
C, C++, Java |
long long | -9,223,372,036,854,775,808 | 9,223,372,036,854,775,807 |
hexadecimal | 0x8000000000000000 | 0x7FFFFFFFFFFFFFFF |
Alignment
Quad Words stored in memory should be stored at byte addresses divisible by eight. Otherwise at runtime it will cause a miss-alignment exception on some processors, or a huge penalty on others.
Endianness
Main article: Endianness.
Litte-endian Layout
The little-endian memory layout, as typical for Intel cpus. For instance the quad word integer 0x0102030405060708
Address | Byte | Significance |
---|---|---|
0x0000 | 0x08 | LS Byte |
0x0001 | 0x07 | |
0x0002 | 0x06 | |
0x0003 | 0x05 | |
0x0004 | 0x04 | |
0x0005 | 0x03 | |
0x0006 | 0x02 | |
0x0008 | 0x01 | MS Byte |
Big-endian Layout
The big-endian memory layout, as typical for Motorola cpus. For instance the quad word integer 0x0102030405060708
Address | Byte | Significance |
---|---|---|
0x0000 | 0x01 | MS Byte |
0x0001 | 0x02 | |
0x0002 | 0x03 | |
0x0003 | 0x04 | |
0x0004 | 0x05 | |
0x0005 | 0x06 | |
0x0006 | 0x07 | |
0x0007 | 0x08 | LS Byte |