Similarly, the number 1.625 would be stored as 101E0 (where, again, a leading 1 is implied in the mantissa). So, this means that a 1 will always occur before the “point,” and so, because we know that it must always be there, we don’t need to store it.Ĭonsidering this, 6.5 would be stored as 101E2 (where a leading 1 is implied in the mantissa). Now, the mantissa can always be written as a number between 1 and 2 the exponent just needs to be modified accordingly.
Similarly, the number 1.625 would be written as 1101E0 (mantissa 1101 and exponent 0). So, the number 6.5 could be written as 1101E2 (in other words, mantissa 1101 and exponent 2). So, a mantissa of 11 (binary) is interpreted as 1.5 (decimal). One more thing to note is that, in the IEEE floating point standard, the mantissa is always considered to have the “point” to occur between the first and second bits. The same is true for floating-point numbers stored binary, except that the mantissa is multiplied by 2 raised to the exponent (as apposed to 10 raised to the exponent as done in decimal). The 1.234 part is called the mantissa and the 3 is called the exponent, so we can write this 1.234E+3 (the 10 is implied and so doesn’t need to be stored). Mantissas and ExponentsĬonsider the decimal number 1234 this may be represented as 1.234 x 10 3. All floating point numbers, in VB, are stored as either IEEE 32-bit (4 byte) floating-point number (for single) or as IEEE 64-bit (8 byte) floating-point number (for double).įirst, let’s look, briefly, at floating point numbers. Floating Point NumbersĪt last!! A VB data type that conforms to standard of some sort. Remember that the bytes occur in little-endian format.
#Visual basic data types windows#
Because the long is 32-bits, it has become the obvious choice to use when needing to store pointers for Windows (a 32-bit OS).
Negative numbers are represented using the “two’s complement” of the number. Thus, an integer is stored as 2 bytes, and has a range of -32,768 to 32,767. (This is true of a C++ integer.) But, it seems that somewhere along the line VB’s integer got stuck in the stone age and was cast in stone as a 16-bit number. So, traditionally, on a 16-bit architecture an integer is 16 bits, on 32-bit OS it is 32 bits, and so forth. Traditionally, an integer is defined as one “word” of an operating system. IntegerĪn Integer in VB is defined in a most unfortunate fashion. However, it should be noted that any non-zero value is also interpreted as TRUE. I think it stems from legacy 16-bit computer architecture.)Ī FALSE in boolean is stored as 0 (in other words, all bits are 0).Ī TRUE in boolean is stored as -1 (in other words, all bits are 1). (In actual fact, you could get away with using only 1 bit, so 2 bytes is, in my opinion, overkill. BooleanĪ boolean variable is represented by 2 bytes. Note: Bytes can’t be used to represent negative numbers (at least, not directly). ByteĪ byte is simply a single byte of memory-8 bits. The following data types are all pretty simple in how they are stored: Byte, Boolean, Integer, and Long.
A few UNIX systems use big-endian format. Most operating systems (for example, DOS and all versions of Windows (so far)) are designed to run using little-endian format. In big-endian format, a multi-byte value is stored in memory from the highest byte (the “big end”) to the lowest.įor example, the value 0x12345678 is stored, in big-endian format, as shown here: 0x12 In little-endian format, a multi-byte value is stored in memory from the lowest byte (the “little end”) to the highest.įor example, the value 0x12345678 is stored, using little-endian format, as shown here. In a 32-bit operating system (for example, Win 95 and Win NT), the size of the pointer is 32 bits (4 bytes) and has a range of 0 to 4,294,967,296 (approx 4 Gigs).īTW: In a few years, when memory sizes exceed 4 Gig, we are going to need new 64-bit operating systems. But, briefly put, a pointer is a block of memory that stores a value of memory location where some other data exists. There is no way I can explain the intricacies of pointers here. These are all marked with BTW (by the way). This article describes how VB stores Bytes, Boolean, Integer, Long, Single, Double, Strings ( Fixed- and Variable-Length), Currency, Date, Variants, Arrays, and UDTs.īTW: I have put in a few points of interest.