Download BME303: Introduction to Computing - Hexadecimal, Floating Point, and Boolean Algebra - Pro and more Study notes Biology in PDF only on Docsity!
BME303 Intro. to Computing Chapter 2 – cont’d
BME303 Intro. to Computing Hexadecimal? 0001001010101011 0001 0010 1010 1011 1 2 A^
B^2
1 12AB – a convenient way to represent binary strings
2 A^ B
BME303 Intro. to Computing
Hexadecimal Notation Working with long stringsof 1s and 0s is difficultWe use hexadecimal (or hex) notation asa form of shorthand11010110 = 0xD6 = # ???
1101 0110 = 0xD6 = # ??? Hex is a 16-base number systemHow to convert to/from hex? hint: use binary as middle-man What about sign?D^6 bbbbbbbb^7 6 5 4 3 2 1 01 1 0 1 0 1 1
BME303 Intro. to Computing Hexadecimal Numbers
Convert binary 0011011011010101 to hex 0x36D50011 0110 1101 0101^3 6 D^
5
Binary^ Hex^0000 00001 10010 20011 30100 40101
0110 6 0111 7 1000 8 1001 9 1010 A 1011 B 1100 C 1101 D^1110 E^1111 F^5
BME303 Intro. to Computing Floating Point
Computers represent real numbers using Floating Point notationsDecimal: 2007 = 2.007·
Binary: 100.11 = 1.0011·
S IEEE Standard : (−1)·1.fraction·
exponent−127^ (1^ ≤^ exponent^ ≤^ 254)
S exponent (8-bit)^ fraction (23-bit) 31 30 29 28 27 26 25 24 23 22 21
20 19 18 17 16 15 14 13 12 11 10
9 8 7 6 5 4 5 2 1 0
32 bits total; exponent is an unsigned 8-bit integer
BME303 Intro. to Computing Floating Point
S(−1)·1.fraction·2 Three step process:- convert the decimal number to a binary number- write binary number in “normalized” scientific notation- find the exponential term
IEEE Standard for Floating Point Arithmetic (“rules”)exponent−127^ (1^ ≤^ exponent^ ≤^ 254)
-^ find the exponential term - store the number in the proper formatS exponent (8-bit)^ fraction (23-bit) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17
16 15 14 13 12 11 10 9 8 7 6
5 4 5 2 1 0
BME303 Intro. to Computing Floating Point: Example
• Exponent field is 00000000 - #0• Exponent field is 11111111 - #inf
BME303 Intro. to Computing Floating Point Notation
S exponent (8-bit)^ fraction (23-bit) 31 30 29 28 27 26 25 24 23 22 21
20 19 18 17 16 15 14 13 12 11 10
9 8 7 6 5 4 5 2 1 0
Conversion: Binary to decimal
Sexponent−127 (−1)·1.fraction·
(1^ ≤^ exponent^ ≤^ 254)
BME303 Intro. to Computing Floating Point Notation Conversion: Decimal to Binary 0 133−127^ (−1)·1.1011·2= +1101100 = 108
Sexponent−127^ (−1)·1.fraction·2(
≤^ exponent^ ≤^ 254)
S exponent (8-bit)^ fraction (23-bit) 31 30 29 28 27 26 25 24 23 22 21
20 19 18 17 16 15 14 13 12 11 10
9 8 7 6 5 4 5 2 1 0
-^ First convert to binary •^ Then convert to exp and fraction
BME303 Intro. to Computing Floating Point Notation Convert Decimal 0.625 to Binary Step 1 : .625 x 2 = 1.25, the first binary digit to the right of the point is a 1. Step 2 : .25 x 2 = 0.50, the second binary digit to the right of the point is a 0.
.25 x 2 =^0 .50, the second binary digit to the right of the point is a
Step 3 : .50 x 2 = 1.00, the third binary digit to the right of the point is a 1. Step 4 : We are finished in Step 3,because we had 0 as the fractional part of our result there.Hence the representation of .625 = .101 b.
BME303 Intro. to Computing Text: ASCII Characters
•American Standard Code for Information Interchange•ASCII: Maps 128 characters to 7-bit code.–^ both printable and non-printable (ESC, DEL, …) characters^00 nul^10 dle^20 sp
30 0 40 @^50 P^60
`^70 p 01 soh^11 dc1^21!^31
41 A^51 Q^61 a^71 q 02 stx^12 dc2^22 "^32
42 B^52 R^62 b^72 r 03 etx^13 dc3^23 #^33
43 C^53 S^63 c^73 s 04 eot^14 dc4^24 $^34
44 D^54 T^64 d^74 t 04 eot^14 dc4^24 $^34
44 D^54 T^64 d^74 t 05 enq^15 nak^25 %^35
45 E^55 U^65 e^75 u 06 ack^16 syn^26 &^36
46 F^56 V^66 f^76 v 07 bel^17 etb^27 '^37
47 G^57 W^67 g^77 w 08 bs^18 can^28 (^38
48 H^58 X^68 h^78 x 09 ht^19 em^29 )^39
49 I^59 Y^69 i^79 y 0a^ nl^ 1a^ sub^ 2a^ *^ 3a^ :^
4a^ J^ 5a^ Z^ 6a^ j^ 7a^ z 0b^ vt^ 1b^ esc^ 2b^ +^ 3b^ ;^
4b^ K^ 5b^ [^ 6b^ k^ 7b^ { 0c^ np^ 1c^ fs^ 2c^ ,^ 3c^ <^
4c^ L^ 5c^ ^ 6c^ l^ 7c^ | 0d^ cr^ 1d^ gs^ 2d^ -^ 3d^ =^
4d^ M^ 5d^ ]^ 6d^ m^ 7d^ } 0e^ so^ 1e^ rs^ 2e^.^ 3e^ >^
4e^ N^ 5e^ ^^ 6e^ n^ 7e^ ~ 0f^ si^ 1f^ us^ 2f^ /^ 3f^?^
4f^ O^ 5f^ _^ 6f^ o^ 7f^ del
BME303 Intro. to Computing Text: ASCII Characters ASCII Symbol Names NUL null SOH start of heading STX start of text ETX end of text EOT end of transmission
ENQ^ enquiry ACK^ acknowledge BEL^ bell BS^ backspace TAB^ horizontal tab NL^ new line (or LF, line feed) VT^ vertical tab
BME303 Intro. to Computing Boolean Algebra
•^ Boolean logic is a branch of mathematics that deals withrules for manipulating the two logical values: true
and false^23
•^ Named after George Boole (1815-1864), an Englishmathematician, who was first to develop and describe aformal system to work with truth values•^ Why is Boolean logic so relevant to computers?^ – direct mapping to binary digits– 1 = true, 0 = false– Devices for basic logical operations
BME303 Intro. to Computing Boolean Expression
-^ A Boolean expression is a condition•^ A Boolean expression is any expression that evaluates to eithertrue or false^ – Is the expression 1+3 a Boolean condition? •^ Examples of Boolean expressions:^ 5 > 3 (true, or 1) 5 > 3 (true, or 1) xA > x2X < YY = 20052003 > 2005 (false, or 0) • Bits may be interpreted as logical values (sometimes referred to as truth values ), where 1 means TRUE and 0 means FALSE