Data Types

The same bit-sequence can look like a wide variety of numbers, depending on how it is interpreted. The numbers below are all from exactly the same bit-sequences, but are displayed with a variety of representations.
(Note: This page was desigend to work great on iPhones.)

AbCdEfGh->bAcDfEhG:
AbcdEfgh->dcbAhgfE:
Abcdefgh->hgfedcbA:
Ab..no->on..bA:
MSBLSB
0000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000
0000 0000 0000 0000 0000 0000 0000 0000
nullnull nullnull nullnull nullnull nullnull nullnull nullnull nullnull
Storage format: IEEE Floating Point Display format: Automatic Integer/Fraction/Scientific [sign][exponent][mantissa]
115112
11564
11152
1823
0000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000
Storage format: Unsigned Binary Display format: Hexidecimal
0000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000
Storage format: Unsigned Binary Display format: Decimal
0000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000
Storage format: Unsigned Binary Display format: Octal
0000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000
Storage format: Unsigned Binary Display format: ASCII(z) not available
0000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000
Storage format: Twos Compliment Binary Display format: Decimal
Storage format: Ones Compliment Binary not yet available
Storage format: Binary Coded Decimal not yet available

Using the converter

The above converter is for changing from almost any data type to any other. If, for example, you wish to convert IEEE Float, 32-bit to a list of decimal byte values, you can enter the number in the IEEE Float section on the 32-bit row (four entry boxes), then read the decimal equivalents under Unsigned Decimal, on the 8-bit row (16 entry boxes; the last row).

The bit-sequence for the current value is repeated often for quick reference. The other numbers are the various interpretations of the same bit-sequence.

Primitive Data Type Ranges

Storage typeBitsMinimumMaximumSmallest Increments
IEEE Floating Point128-1.2e+49321.2e+49326.5e-4966
80-1.2e+49321.2e+49321.8e-4951
64-1.8e+3081.8e+3084.9e-324
32-3.4e+383.4e+381.4e-45
Unsigned Binary12803.4e+381
6401.8e+19 (18,446,744,073,709,551,615)1
3204.3e+9 (4,294,967,295)1
16065,5351
802561
2's Compliment128-1.7e+381.7e+381
64-9.2e+18 (-9,223,372,036,854,775,808)9.2e+18 (9,223,372,036,854,775,807)1
32-2.1e+9 (-2,147,483,648)2.1e+9 (2,147,483,647)1
16-32,76832,7681
8-1281271

Primitive Data Types by Language

Storage typeBitsJava-ScriptCRSLogix5000LabViewOthers coming; need to verify
IEEE Floating Point128
80
64doubledouble
32varfloatREALfloat
Unsigned Binary128u128
64unsigned long longu64
32unsigned longu32
16unsigned shortu16
8unsigned charu8
2's Compliment128i128
64signed long longLINTi64
32varsigned longDINTi32
16signed shortINTi16
8signed charSINTi8

Ranting about data types vs. storage and display formats

Most people new to data types confuse storage formats with display formats. True: there are some combinations that work and some that don't. But they are not the same thing.

The most common misconception comes when someone receives a number "in hex" then wants to store it "in decimal". This usually means that the number is received as a bit-stream, either in unisgned binary or twos compliment binary. But they plan to display it later using decimal. What really happens is that the bit-stream is stored exactly as it is. It is neither hex nor decimal; it's just bits. Then, when the program should display it as decimal, it must be converted to a list of characters to display. The characters correspond to Arabic numerals using base 10.

The most common Storage Formats:

The most common Display Formats:

I should probably point out there is such a thing as 'fixed point'. Fixed point mixes up both storage formats and display formats. Generally, a fixed point number doesn't know it's fixed point in storage. But it does affect the true value of a number in the same way as units do. For example, if a value is stored as 456 cents, it is also $4.56. The number and its storage don't understand cents or dollars, or know a decimal belongs before the last two digits. The display format should be adjusted to handle that part. It is closely tied to storage formats, though, because the true value is affected, and the product of two fixed point numbers makes another fixed point number with the decimal in a new place.

Copyright

This content (and associated scripts) are copyright 2011, Gray Computer Systems. The general information is public domain. Feel free to read the scripts and learn from them--you are even welcome to copy snippets from them. And feel free to use this page and link to it from other pages. Just please don't copy large portions or take credit for the work.