You are currently reviewing an older revision of this page.
Original Article Date: Sep 8, 2003
This is a re-write of an older article and explores how you can calculate the decimal equivalent of a binary number with an slant towards raster imagery. Although not really MicroStation stuff,it may help you understand what 1010 and 1101 really means. (With special thanks to the guy I'm married to for explaining this stuff to me!)
A bit is the smallest unit of information that is understood by a computer and is either on which is represented by the number 1 or off which is the number 0.
Value
No. of Bits
No. of Colours
20
0
1
NULL
21
2
22
4
00
23
3
8
000
24
16
0000
25
5
32
00000
26
6
64
000000
27
7
128
0000000
28
256
00000000
216
18
65,536
000000000
224
16,777,216
Got it?
Note, even though the above chart shows 0's in the last column - it could also be 1's or any combination of 0's and 1's. In an 8 bit image, each pixel is described as having 1 of a possible 256 colours which is composed of eight 0's and 1's to represent that colour number in the palette. Similarily, a 4-bit image would have a maximum colour count of 16.
Image Type
1 Bit
4 Bit
8 Bit
24 Bit
16 Million
In 4 bit image each pixel is described by four values which in turn represents one colour from a total of 16 available colours. The binary number of each colour is as follows:
Binary Number
Colour Number
0001
0010
0011
0100
0101
0110
0111
1000
1001
9
1010
10
1011
11
1100
12
1101
13
1110
14
1111
15
Digit Position
Binary
Decimal Equivalent
On/Off Status
Off
On
In this case the colour number is 8 + 4 + 0 + 1 = 13 To sum things up, you can calculate the decimal value of a 4-bit binary number, with this little formula: Decimal Number = 23 + 22 + 21 + 20 Remember though, that if the the place value is a 0, it's essentially turned off and ignored. Also, any number raised to the power of zero is always one. Likewise, any number raised to the first power is the number of the base itself.
AskInga Article #47