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.)
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 type||Bits||Minimum||Maximum||Smallest Increments
|IEEE Floating Point||128||-1.2e+4932||1.2e+4932||6.5e-4966
|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
Primitive Data Types by Language
|Storage type||Bits||Java-Script||C||RSLogix5000||LabView||Others coming; need to verify
|IEEE Floating Point||128||
|64||unsigned long long||u64
|64||signed long long||LINT||i64
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:
- IEEE Floating Point
- A wide variety of numbers can be stored as floating point, including
integers, fractions, and infinity. The number is stored as a set of
digits (actually binary), and the location for a decimal point.
Floating point is very common, partly because IEEE standardized some of
the formats. 32-bit is commonly called single-precision, 16 half, 64
double, and 128 quad. Intel used 80-bit internally, but it isn't
commonly stored in 80-bit. 80-bit is sometimes called extended.
- Unsigned Binary
- A simple set of digits in base 2. If the LSB (on the right here, but
sometimes shown on the left) is '1', it has a value of 1. The next digit
(bit) can have a value of 2. Each digit in turn can be worth twice as
- Twos Compliment Binary
- The MSB (far left here) changes the meaning of the rest of the bits.
If it is '0', the rest can be treated as an Unsigned Binary. If it is
'1', the value stored is negative. In this case, the value can be found
the same way as for Unsigned Binary, except that the MSB counts as
negative it's value instead of positive. For example, in an 8-bit
number, the MSB counts as -128 instead of +128, so the bits 11111111 would
be displayed as a decimal value of -1. Twos compliment numbers can be
added in exactly the same way as unsigned binary--very easily. For this
reason, twos compliment has dominated modern electronics.
- Ones Compliment Binary (Very rarely used)
- The MSB (far left here) determines the sign. All the other bits
determine the value. Unlike twos compliment, the MSB does not change the
value in ones compliment. So, the bits 11111111 would be displayed as a
decimal value of -127. Ones compliment numbers do not add as easily as
twos compliment numbers.
1's complement is easier to convert for display than 2's complement. It
is much harder in every other way. I don't know of any application that
- Binary Coded Decimal (Rarely used)
- Groups of 4 bits make up decimal digits. Displaying a BCD value in
decimal is exactly the same as showing an unsigned binary in hexidecimal.
In fact, they are the same program here. Math on BCD numbers is much
more complicated, and makes it almost unusable in modern systems.
Addition is difficult; multiplication is nearly impossible. The bits
01000011 would be displayed as 43. If you want to add 8 to it, most
electronic adders would first add 01000011 and 00001000 and get
01001011 (which would probably be displayed as 4B), then it would do a BCD
patch-up to change it to 01010001, which would correctly be displayed as
BCD is almost never used in designs since about 1985. It was popular in
DMMs (digital multi-meters) or VOMs (Volt-Ohm meters), and a few analog
to digital converters made for DMMs, and was used in a few mainframes.
The most common Display Formats:
- Decimal Integer
- Very popular with humans.
- Hexidecimal Integer
- Mostly used when an operator wants to think in binary without getting
lost in the long stream of digits. Also common for programmers.
- Octal Integer
- More popular in the past; a little harder to manage than hex, but
avoids using letters as numeric values.
- Binary Integer
- Simplest way to show data, but a pain to read, copy, or type.
- Always decimal. The only reason to show a fraction in other bases is
to explain how numbers are stored in floating point.
Usually, computers don't really display numbers like 5/8. The fraction
format means it has a decimal. Sometimes, even Unsigned Binary can be
shown as a fraction if everyone agrees that the number is really a
fraction with the decimal in a fixed location. For example, a bank may
store a balance as an Unsigned Binary (integer) number of cents, but
display it as dollars with a '.' stuck in the right place.
- Scientific Notation
- Like a fraction, but with an additional exponent shift. A number like
'1.2e+4' can be read as '1.2 times 10 to the power of 4'. It is just
another way to write '12000'. But a number like '1.2e-8' is much easier
to write and read than '0.000000012'. Scientific notation is rarely
used for any format but floating point.
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.
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.