vbUINT32 Integer Type


Topics:

OverviewOverview
Conditional Directives
FunctionsType Definitions
Functions


Overview

The vbUINT32 class is used to represent 32 bit unsigned integers independently of the operating system or hardware platform used. vbUINT32 types are implemented to overcome the big and little endian byte ordering problems encountered when writing integer values to a common database file or device accessed by several different types of machines. It works by separating a 32-bit value into four separate byte values and reordering the bytes lowest-order to highest-order. A vbUINT32 type has a base 10 limit of 4,294,967,295.

The term "endian" is used to describe the order in which multi-byte numbers are stored in the computer's memory. This is specific to each microprocessor. The Intel x86 family is little-endian, meaning that the lowest-order byte is stored first. Hewlett-Packard's PA-RISC and Sun's SuperSPARC are big-endian, meaning the highest-order byte is stored first. The Silicon Graphics MIPS and IBM/Motorola Power PC processors are both little and big endian (bi-endian).

Value

Big-Endian

Little-Endian

0x12345678

0x12345678

0x78563412

0x1234

0x1234

0x3412

0x5678

0x5678

0x7856

"ABC"

41 42 43

41 42 43

With big-endian ordering, the address of the multi-byte value is its most significant byte (its big end.) With little-endian ordering, the address of the multi-byte value is its least significant byte (its little end.) Character stings are stored in memory exactly as they appear regardless of the byte ordering used. In a data structure the order of bytes in memory will differ depending on the byte ordering and the particular data type used. If the contents of a data structure are written to disk or a device, the byte ordering will affect the data when it is moved to another platform.


Conditional Directives

__USE_NATIVE_INT_TYPES__ - This conditional directive allows the use of native integer types in place of platform independent integer types and is indented to be used for debugging purposes only.


Type Definitions

__SBYTE__ - Type definition for 8-bit signed values.
__UBYTE__ - Type definition for 8-bit unsigned values.
__WORD__ - Type definition for native integer types.
__UWORD__ - Type definition for native unsigned integer types.
__LWORD__ - Type definition for native 32-bit signed integer types.
__ULWORD__ - Type definition for native 32-bit unsigned integer types.
__SWORD__ - Type definition for native 16-bit signed integer types.
__USWORD__ - Type definition for native 16-bit unsigned integer types.
__DPFLOAT__ - Type definition for native 64-bit double precision floating points types.


Functions

vbUINT32::vbUINT32()
vbUINT32::PackBits()
vbUINT32::UnPackBits()
vbUINT32::operator LWORD()
vbUINT32 Overloaded Operators

vbUINT32::vbUINT32(__ULWORD__ val = 0) - Class constructor responsible for separating the 32-bit value into four separate byte values when the object is constructed.

vbUINT32::vbUINT32(const vbUINT32& ob) - Class copy constructor that copies the byte values from the object specified to the object being constructed.

__ULWORD__ vbUINT32::PackBits() - Public member function responsible for reordering the bytes from lowest-order to highest-order. It works by separating the four-byte array into four separate __ULWORD__ values. These values are masked with a bitwise AND, left shifted into position, and then added together to form a single 32-bit value that will remain consistent regardless of the original byte ordering used.

void vbUINT32::UnPackBits(__ULWORD__ val) - Public member function responsible for separating a 32-bit value into four separate byte values. It works by masking the individual byte values with a bitwise AND, then right shifting the bytes into a four-byte array.

operator vbUINT32::__ULWORD__() - Conversion function used to convert a vbUINT32 type into a __ULWORD__ type.

Overloaded operators:
The vbUINT32 class has several overloads of arithmetic and comparison operators. Each version is overloaded for the following data types: vbUINT32, __LWORD__, __ULWORD__, __WORD__, __SWORD__, __ULWORD__, __USWORD__, __SBYTE__, and __UBYTE__.

Arithmetic operators that modify their operand:
- (Postfix and Prefix) operator++
- (Postfix and Prefix) operator--
- operator+=
- operator-=
- operator*=
- operator/=

Comparison operators:
- operator==
- operator!=
- operator<
- operator>
- operator<=
- operator>=


End Of Document