http://proglit.com/. numbers by sa
TRANSCRIPT
http://proglit.com/
numbers
BY
SA
01bit
(one of two states)
number system(a scheme for symbolically and verbally
representing quantity)
unary(the tally system)
Aiwt$e#&!)9?
positional notation(represents arbitrarily large quantities
using a finite set of symbols)
decimalbase-10
(positional notation using 10 symbols)
Arabic numerals
0 1 2 3 4 5 6 7 8 9
3940
909
…0000000009
0910
8699987000
78seventy-eightseven eight
octalbase-8
(positional notation using 8 symbols)
0 1 2 3 4 5 6 7
0710
12345671011121314
123456789101112
octalbase-8
decimalbase-10
151617202122232425262730
131415161718192021222324
octalbase-8
decimalbase-10
317777320000
61 (decimal)061 (octal)
05673
hexadecimalhex
base-16
(positional notation using 16 symbols)
0 1 2 3 4 5 6 78 9 A B C D E F
0F10
123456789ABC
123456789101112
hexbase-16
decimalbase-10
DEF101112131415161718
131415161718192021222324
hexbase-16
decimalbase-10
191A1B1C1D1E1F2021222324
252627282930313233343536
hexbase-16
decimalbase-10
ADDBAD
BEADBEE
BEEF CAFE DEAD DEAF DEED FAD
FEED
0xADD0xBAD
0xBEAD0xBEE
0xBEEF 0xCAFE 0xDEAD 0xDEAF 0xDEED 0xFAD
0xFEED
0xA3BFFFFF0xA3C00000
binarybase-2
(positional notation using 2 symbols)
0 1
0110
11011
100101110111
10001001101010111100
123456789101112
binarybase-2
decimalbase-10
131415161718192021222324
binarybase-2
decimalbase-10
110111101111100001000110010100111010010101101101011111000
101b (binary)101 (decimal)
10101111b10110000b
http://proglit.com/
base conversions
36259
(30000) + (6000) + (200) + (50) + (9)
(3 * 10000) + (6 * 1000) + (2 * 100) + (5 * 10)
+ (9 * 1)
(3 * 104) + (6 * 103) + (2 * 102) + (5 * 101) + (9 * 100)
36259104 103 102 101 100
10000 1000 100 10 1
octal to decimal
03675
(03000) + (0600) + (070) + (05)
(03 * 01000) + (06 * 0100) + (07 * 010) + (05 * 01)
(03 * 0103) + (06 * 0102) + (07 * 0101) + (05 * 0100)
(3 * 83) + (6 * 82) + (7 * 81) + (5 * 80)
(3 * 512) + (6 * 64) + (7 * 8) + (5 * 1)
(1636) + (384) + (56) + (5)
03675 =
2081
decimal to octal
36256
(3 * 104) + (6 * 103)+ (2 * 102) + (5 * 101)+ (6 * 100)
(03 * 0124) + (06 * 0123)+ (02 * 0122) + (05 * 0121)+ (06 * 0120)
(03 * 023420) + (06 * 01750)
+ (02 * 0144) + (05 * 012)+ (06 * 01)
(072460) + (013560)+ (0310) + (062)+ (06)
36256=
0106640
hex to decimal
0x36E59
(0x3 * 164) + (0x6 * 163) + (0xE * 162) + (0x5 * 161) + (0x9 * 160)
(3 * 65536) + (6 * 4096) + (14 * 256) + (5 * 16) + (9 * 1)
(196608) + (24576) + (3584) + (80) + (9)
0x36E59 =
224857
binary to decimal
10101b
(1 * 24) + (0 * 23) + (1 * 22) + (0 * 21)+ (1 * 20)
(1 * 16) + (0 * 8) + (1 * 4) + (0 * 2)+ (1 * 1)
(16) + (0) + (4) + (0)+ (1)
10101b=21
10101101b
10101101b128 32 8 4 1
(128) + (32) + (8) + (4)+ (1)
10101101b=
173
22 423 824 1625 3226 6427 12828 25629 512210 1024211 2048212 4096213 8192214 16384215 32768216 65536217 131072218 262144219 524288220 1048576
decimal to binary
1) find biggest fitting power of two
2) subtract it out 3) repeat until left with 0
35872
3587232768 (215)
1???????????????b
35872 - 32768=
3104
31042048 (211)
10001???????????b
3104 – 2048=
1056
10561024 (210)
100011??????????b
1056 – 1024=32
3232 (25)
10001100001?????b
32 – 32=0
1000110000100000b
why use hex and octal?
octal to binary(and vice versa)
01234567
000001010011100101110111
octalbase-8
binarybase-2
03673
01234567
000001010011100101110111
octalbase-8
binarybase-2
03673011110111011b
1101010110b
001101010110b01526
hex to binary(and vice versa)
0123456789ABCDEF
0000000100100011010001010110011110001001101010111100110111101111
hexbase-16
binarybase-2
0x7E9011111101001b
1100101101b0x32D
recapEach digit is a coefficient of the number base raised to an increasing power.
One technique works for all number base conversions.
Shortcut conversions:• decimal to binary (sum powers of 2)• binary to decimal (subtract out powers of 2)• octal and binary (1 octal digit = 3 binary digits)• hex and binary (1 hex digit = 4 binary digits)
Effectively, hex and octal serve as a compacter way of writing binary.
http://proglit.com/
meaning relies upon agreement
integer(whole number)
58780
-87234
signed integer
unsigned integer
0, 1, 2, 3, 4, 5…0b, 1b, 10b, 11b, 100b, 101b…
n bits = 2n values1 bit = 2 values2 bits = 4 values3 bits = 8 values4 bits = 16 values5 bits = 32 values6 bits = 64 values7 bits = 128 values8 bits = 256 values
etc…
unsigned value range1 bit = 0..12 bits = 0..33 bits = 0..74 bits = 0..155 bits = 0..316 bits = 0..637 bits = 0..1278 bits = 0..255
etc…
10000011(negative three)
00000011(positive three)
sign bit
11111100(negative three)
00000011(positive three)
one’s complement
11111101(negative three)
00000011(positive three)
two’s complement
00000011(positive three)
11111101(negative three)
two’s complement
00000101(negative three in excess-8)
00001011(positive three in excess-8)
excess-n
00100111(negative three in excess-42)
00101101(positive three in excess-42)
excess-n
sign bit: -127 to +127one’s complement: -127 to +127two’s complement: -128 to +127
8-bit range
rational numbers2/51/987/1
-61/1738
radix-point notation(ratio written as an integer component and a
fractional component, separated by a radix point)
3/41/8-7/1138/20
0.750.125-7.06.9
36.259
(30) + (6)
+ (0.2) + (0.05)
+ (0.009)
(3 * 101) + (6 * 100) + (2 * 10-1) + (5 * 10-2) + (9 * 10-3)
36.259101 100 10-1 10-2 10-3
10 1 1/10 1/100 1/1000
062.73281 80 8-1 8-2 8-3
8 1 1/8 1/64 1/512
10.111b21 20 2-1 2-2 2-3
2 1 1/2 1/4 1/8
finite rational(rational with a fractional component which can be
expressed with a finite number of digits)
3/4-7/1138/201/3
738/61
0.75-7.06.90.33
12.0983606557…
a ratio with denominator 2a5b is finite in decimal a ratio with denominator 2a is finite in octal a ratio with denominator 2a is finite in hexa ratio with denominator 2a is finite in binary
all ratios which are finite in binary are also finite in decimal some ratios which are finite in decimal are also finite in binary
rational as two integers3/4
Numerator: 00000011 Denominator: 00000100
-7/13 Numerator: 11111001 Denominator: 00001101
fixed-point
57/8111.001b
Integer: 00000111 Fraction: 00100000
(the computing equivalentof radix-point notation)
scientific notationengineering notation 362.354 = 3.62354 * 102
0.00736234 = 7.36234 * 10-3
989777.1 = 9.897771 * 105
floating-point
21/21010.1b
1.0101b * 23
Significand: 10101000 Exponent: 00000011
(the computing equivalent of scientific notation)
6.75
6.75110b + 0.?b
0.753/4
3/41/2 + 1/42-1 + 2-2
6.75=
110.11b
110.11b=
1.1011b * 22
1.1011b * 22
Significand: 11011000Exponent: 00000010
IEEE floating-point(an international standard)
http://proglit.com/