Number Systems II MA1S1. Tristan McLoughlin. November 30, 2013

Similar documents
Chapter 7. Binary, octal and hexadecimal numbers

ASCII Code - The extended ASCII table

OOstaExcel.ir. J. Abbasi Syooki. HTML Number. Device Control 1 (oft. XON) Device Control 3 (oft. Negative Acknowledgement

1.1. INTRODUCTION 1.2. NUMBER SYSTEMS

2a. Codes and number systems (continued) How to get the binary representation of an integer: special case of application of the inverse Horner scheme

CMSC 313 Lecture 03 Multiple-byte data big-endian vs little-endian sign extension Multiplication and division Floating point formats Character Codes

Chapter 3. Information Representation

DATA REPRESENTATION. Data Types. Complements. Fixed Point Representations. Floating Point Representations. Other Binary Codes. Error Detection Codes

EXPERIMENT 8: Introduction to Universal Serial Asynchronous Receive Transmit (USART)

1. Character/String Data, Expressions & Intrinsic Functions. Numeric Representation of Non-numeric Values. (CHARACTER Data Type), Part 1

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 02, SPRING 2013

Fundamentals of Programming (C)

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 02, FALL 2012

EXPERIMENT 7: Introduction to Universal Serial Asynchronous Receive Transmit (USART)

FD-011WU. 2D Barcode Reader User Guide V1.6CC

MK D Imager Barcode Scanner Configuration Guide

Characters Lesson Outline

Data Representation and Binary Arithmetic. Lecture 2

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 02, FALL 2012

Number System (Different Ways To Say How Many) Fall 2016

CPS 104 Computer Organization and Programming Lecture-2 : Data representations,

Binary Numbers. The Basics. Base 10 Number. What is a Number? = Binary Number Example. Binary Number Example

Experiment 3. TITLE Optional: Write here the Title of your program.model SMALL This directive defines the memory model used in the program.

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

Chapter 2 Bits, Data Types, and Operations

Chapter 2 Bits, Data Types, and Operations

Exercises Software Development I. 03 Data Representation. Data types, range of values, internal format, literals. October 22nd, 2014

Oberon Data Types. Matteo Corti. December 5, 2001

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

Unit 3, Lesson 2 Data Types, Arithmetic,Variables, Input, Constants, & Library Functions. Mr. Dave Clausen La Cañada High School

Chapter 2 Bits, Data Types, and Operations

Under the Hood: Data Representation. Computer Science 104 Lecture 2

Numbers and Computers. Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras

The following are the data types used in the C programming language:

Number Representations

5/17/2009. Digitizing Discrete Information. Ordering Symbols. Analog vs. Digital

plc numbers Encoded values; BCD and ASCII Error detection; parity, gray code and checksums

EE 109 Unit 3. Analog vs. Digital. Analog vs. Digital. Binary Representation Systems ANALOG VS. DIGITAL

Chapter 2 Number System

The Binary Number System

EE 109 Unit 2. Analog vs. Digital. Analog vs. Digital. Binary Representation Systems ANALOG VS. DIGITAL

BD-6500BT Bluetooth 2D Barcode Scanner Configuration Guide

3.1. Unit 3. Binary Representation

Number Systems Base r

2D Barcode Reader User Guide V 1.2.1

Unit 3. Analog vs. Digital. Analog vs. Digital ANALOG VS. DIGITAL. Binary Representation

Number Systems for Computers. Outline of Introduction. Binary, Octal and Hexadecimal numbers. Issues for Binary Representation of Numbers

Fundamental Data Types

Chapter 2 Bits, Data Types, and Operations

Fundamentals of Programming

Chapter 2 Bits, Data Types, and Operations

Chemistry Hour Exam 2

EE 109 Unit 2. Binary Representation Systems

Data Representa5on. CSC 2400: Computer Systems. What kinds of data do we need to represent?

Data Representa5on. CSC 2400: Computer Systems. What kinds of data do we need to represent?

UNIT 2 NUMBER SYSTEM AND PROGRAMMING LANGUAGES

Lecture (09) x86 programming 8

ASSIGNMENT 5 TIPS AND TRICKS

FA269 - DIGITAL MEDIA AND CULTURE

S-Series Sensor ASCII Protocol v8.1.0

Bits and Bytes. Data Representation. A binary digit or bit has a value of either 0 or 1; these are the values we can store in hardware devices.

If your CNC machine memory is full, the PocketDNC gives you more storage, enabling you to store and reload proven programs at a later date.

CS341 *** TURN OFF ALL CELLPHONES *** Practice NAME

Number Systems MA1S1. Tristan McLoughlin. November 27, 2013

Chapter 8. Characters and Strings

Characters & Strings in C

Mounting Dimensions / Viewing 2 Mounting Options 3. Wiring Configuration 4. Quick Set up Procedure 5. Changing Intensity 6.

CPSC 301: Computing in the Life Sciences Lecture Notes 16: Data Representation

n NOPn Unary no operation trap U aaa NOP Nonunary no operation trap i

Serial I/O. 4: Serial I/O. CET360 Microprocessor Engineering. J. Sumey

Representing Things With Bits

2D Hand-held Barcode Scanner User Guide

PD1100 STAND-ALONE PROGRAMMING & USER S GUIDE. use the freedom

CSE-1520R Test #1. The exam is closed book, closed notes, and no aids such as calculators, cellphones, etc.

Positional Number System

A GUIDE TO RS-232 COMMUNICATION WITH FX PLCS

Do not start the test until instructed to do so!

Source coding and compression

Chapter 1. Hardware. Introduction to Computers and Programming. Chapter 1.2

Do not start the test until instructed to do so!

Simple Data Types in C. Alan L. Cox

Hardware. ( Not so hard really )

CSE-1520R Test #1. The exam is closed book, closed notes, and no aids such as calculators, cellphones, etc.

Variables and data types

This is great when speed is important and relatively few words are necessary, but Max would be a terrible language for writing a text editor.

Coding Theory. Networks and Embedded Software. Digital Circuits. by Wolfgang Neff

IPDA014-2D. Embedded 2D Barcode Scan Engine. User Guide

Do not start the test until instructed to do so!

Acquirer JCB EMV Test Card Set

PureScan - ML1. Configuration Guide. Wireless Linear Imager Wireless Laser scanner - 1 -

Appendix A Developing a C Program on the UNIX system

Digital Representation

Introduction. Chapter 1. Hardware. Introduction. Creators of Software. Hardware. Introduction to Computers and Programming (Fall 2015, CSUS)

4/14/2015. Architecture of the World Wide Web. During this session we will discuss: Structure of the World Wide Web

User s Manual. Xi3000 Scanner. Table of Contents

Midterm Exam, Fall 2015 Date: October 29th, 2015

2D BARCODE SCANNER CA-SC-20200B

Table of Contents Sleep Settings How to Configure the Scanner. 7 Chapter 2 System Setup

Review. Single Pixel Filters. Spatial Filters. Image Processing Applications. Thresholding Posterize Histogram Equalization Negative Sepia Grayscale

Introduction to Decision Structures. Boolean & If Statements. Different Types of Decisions. Boolean Logic. Relational Operators

Transcription:

Number Systems II MA1S1 Tristan McLoughlin November 30, 2013 http://en.wikipedia.org/wiki/binary numeral system http://accu.org/index.php/articles/18 http://www.binaryconvert.com http://en.wikipedia.org/wiki/ascii

Simple computer programs that use integers will be limited to the range of integers from 2 31 up to 2 31 1 (which is the number that has 31 1 s in binary). However, it is possible to write programs that will deal with a larger range of integers. You can arrange your program to use more than 32 bits to store each integer, for example to use several rows of 32 bits. However, the program will then generally have to be able to implement its own carrying rules and so forth for addition and subtraction of these bigger integers. So you will not simply be able to use the ordinary plus and times that you can use with regular integers.

Why octal and Hex? We can now explain why computer people are fond of base 16 or hex. Octal looks easier to read (no need to worry about the new digits a for ten, etc) but in computers we are frequently considering 32 bits at a time. Using the 3 binary for one octal rule this allows us to write out the 32 bits quickly, but it takes us eleven octal digits. The messy part is that we really don t quite use the eleventh octal digit fully. It can be at most (11) 2 = 3. With hex, we have a 4 binary digits for one hex rule and 32 binary digits or bits exactly uses up 8 hex digits.

ASCII Computers use binary for everything, not just numbers. For example, text is encoded in binary by numbering all the letters and symbols. The most well used method for doing this is called ASCII (an acronym that stands for American Standard Code for Information Interchange). and it uses 7 binary digits or bits for each letter.

ASCII On a UNIX system, you can find out what the ASCII code is by typing the command: man ascii at the command line prompt. Another place to find this information is at http://en.wikipedia.org/wiki/ascii. Essentially what you will find is...

The first 32 characters in the ASCII-table are unprintable control codes and are used to control peripherals such as printers. DEC OCT HEX BIN Symbol HTML Number HTML Name Description 0 000 00 00000000 NUL � Null char 1 001 01 00000001 SOH  Start of Heading 2 002 02 00000010 STX  Start of Text 3 003 03 00000011 ETX  End of Text 4 004 04 00000100 EOT  End of Transmission 00 0 00000101 ENQ � Enquiry 6 006 06 00000110 ACK  Acknowledgment 7 007 07 00000111 BEL  Bell 8 010 08 00001000 BS  Back Space 9 011 09 00001001 HT Horizontal Tab 10 012 0A 00001010 LF Line Feed 11 013 0B 00001011 VT  Vertical Tab 12 014 0C 00001100 FF  Form Feed 13 01 0D 00001101 CR Carriage Return 14 016 0E 00001110 SO  Shift Out / X-On 1 017 0F 00001111 SI  Shift In / X-Off 16 020 10 00010000 DLE  Data Line Escape 17 021 11 00010001 DC1  Device Control 1 (oft. XON) 18 022 12 00010010 DC2  Device Control 2 19 023 13 00010011 DC3  Device Control 3 (oft. XOFF) 20 024 14 00010100 DC4  Device Control 4 21 02 1 00010101 NAK  Negative Acknowledgement 22 026 16 00010110 SYN  Synchronous Idle 23 027 17 00010111 ETB  End of Transmit Block 24 030 18 00011000 CAN  Cancel 2 031 19 00011001 EM  End of Medium http://www.ascii-code.com/ Page 1 of 7

There first 32 items are codes for invisible or non-printible objects that are useful in organising messages of text etc.

Safari Power Saver Click to Start Flash Plug-in ASCII control characters (character code 0-31) The first 32 characters in the ASCII-table are unprintable control codes and are used to control peripherals such as printers. ASCII Code - The extended ASCII table DEC OCT HEX BIN Symbol HTML Number HTML Name Description 02 000 031 00 19 00000000 00011001 NUL EM �  End Null of char Medium 126 001 032 01 1A 00000001 00011010 SOH SUB   Substitute Start of Heading 227 002 033 02 1B 00000010 00011011 STX ESC   Escape Start of Text 328 003 034 03 1C 00000011 00011100 ETX FS   File End Separator of Text 429 004 03 04 1D 00000100 00011101 EOT GS   Group End of Separator Transmission 30 00 036 0 1E 00000101 00011110 ENQ RS �  Record EnquirySeparator 631 006 037 06 1F 00000110 00011111 ACK US   Unit Acknowledgment Separator 7 007 07 00000111 BEL  Bell Safari Power Saver 8 010 08 00001000 BS  Back Space Click to Start Flash Plug-in 9 011 09 00001001 HT Horizontal Tab 10 012 0A 00001010 LF Line Feed 11 013 0B 00001011 VT  Vertical Tab 12 014 0C 00001100 FF  Form Feed ASCII printable characters (character code 32-127) Codes 13 32-127 01 are 0D common 00001101 for all the different CR variations of the ASCII table, they are Carriage called Return printable characters, represent 14 016 letters, 0E digits, 00001110 punctuation marks, SO and a few  miscellaneous symbols. You Shift will Out find / almost X-On every character your keyboard. Character 127 represents the command DEL. 1 017 0F 00001111 SI  Shift In / X-Off DEC 16 OCT 020 HEX 10 BIN 00010000 Symbol DLE HTML Number  HTML Name Description Data Line Escape 32 17 040 021 20 11 00100000 00010001 DC1  Space Device Control 1 (oft. XON) 28/1

The remaining, no. 32-127, are printable objects like punctuation...

printers. your keyboard. Character 127 represents the command DEL. DEC DEC OCT OCT HEX HEX BIN BIN Symbol Symbol HTML HTML Number HTML HTML Name Name Description 032 000 040 0020 00000000 00100000 NUL � Null Space char 133 001 041 0121 00000001 00100001 SOH! ! Start Exclamation of Heading mark 234 002 042 0222 00000010 00100010 STX "  " " Start Double of Text quotes (or speech marks) 33 003 043 0323 00000011 00100011 ETX #   End Number of Text 436 004 044 0424 00000100 00100100 EOT $  $ End Dollar of Transmission 37 00 04 02 00000101 00100101 ENQ % � % Enquiry Procenttecken 638 006 046 0626 00000110 00100110 ACK &  & & Acknowledgment Ampersand 739 007 047 0727 00000111 00100111 BEL '  ' Bell Single quote 840 010 00 0828 00001000 00101000 BS (  ( Back Open Space parenthesis (or open bracket) 941 011 01 0929 00001001 00101001 HT ) ) Horizontal Close parenthesis Tab (or close bracket) 1042 012 02 0A2A 00001010 00101010 LF * * Line Asterisk Feed 1143 013 03 0B2B 00001011 00101011 VT +  + Vertical Plus Tab 1244 014 04 0C2C 00001100 00101100 FF, , Form Comma Feed 134 01 0 0D2D 00001101 00101101 CR -  Carriage Hyphen Return 1446 016 06 0E2E 00001110 00101110 SO. . Shift Period, Out dot / X-On or full stop 147 017 07 0F2F 00001111 00101111 SI /  / Shift Slash In or / X-Off divide 1648 020 060 1030 00010000 00110000 DLE 0  0 Data ZeroLine Escape 1749 021 061 1131 00010001 00110001 DC1 1  1 Device One Control 1 (oft. XON) 180 022 062 1232 00010010 00110010 DC2 2  � Device Two Control 2 1 063 33 00110011 3  Three 19 2 023 064 13 34 00010011 00110100 DC3 4   Device Control 3 (oft. XOFF) Four 20 3 024 06 14 3 00010100 00110101 DC4   Device Control 4 Five 21 4 02 066 1 36 00010101 00110110 NAK 6   Negative Acknowledgement Six 22 026 067 16 37 00010110 00110111 SYN 7  &#; Synchronous Idle Seven

... numbers... and letters both upper case

The first 32 characters in the ASCII-table are unprintable control codes and are used to control periph ASCII control characters (character code 0-31) printers. 63 077 3F 00111111?? Question mark DEC 64 OCT 100 HEX 40 BIN 01000000 Symbol @ HTML Number @ HTML Name Description At symbol 6 0 101 000 41 00 01000001 00000000 A NUL  � Uppercase Null char A 66 1 102 001 42 01 01000010 00000001 B SOH B  Uppercase Start of Heading B 67 2 103 002 43 02 01000011 00000010 C STX C  Uppercase Start of Text C 68 3 104 003 44 03 01000100 00000011 D ETX D  Uppercase End of Text D 69 4 10 004 4 04 01000101 00000100 E EOT E  Uppercase End of Transmission E 70 106 00 460 01000110 00000101 F ENQ F � Uppercase Enquiry F 716 107 006 4706 01000111 00000110 G ACK G  Uppercase Acknowledgment G 727 110 007 4807 01001000 00000111 H BEL H  Uppercase Bell H 738 111 010 4908 01001001 00001000 I BS I  Uppercase Back Space I 749 112 011 4A09 01001010 00001001 J HT J Uppercase Horizontal J Tab ASCII Code - The extended ASCII table 710 113 012 4B0A 01001011 00001010 K LF  Uppercase Line FeedK 7611 114 013 4C0B 01001100 00001011 L VT L  Uppercase Vertical Tab L 7712 11 014 4D0C 01001101 00001100 M FF M  Uppercase Form Feed M 7813 116 01 4E0D 01001110 00001101 N CR N Uppercase Carriage NReturn 7914 117 016 4F0E 01001111 00001110 O SO O  Uppercase Shift Out O/ X-On 801 120 017 00F 01010000 00001111 P SI P  Uppercase Shift In / PX-Off 8116 121 020 110 01010001 00010000 Q DLE Q  Uppercase Data Line QEscape 8217 122 021 211 01010010 00010001 R DC1 R  Uppercase Device Control R 1 (of

... and lower case...

codes and are used to control peripherals such ASCII control characters (character code 0-31) The first 32 characters in the ASCII-table are unprintable control ASCII Code printers. - The extended ASCII table 110 DEC 16 OCT HEX 6E 01101110 BIN Symbol n HTML n Number HTML Name Description Lowercase n 111 0 17 000 6F 00 00000000 01101111 NUL o � o Null Lowercase char o 112 1 160 001 70 01 00000001 01110000 SOH p  p Start Lowercase of Heading p 113 2 161 002 71 02 00000010 01110001 STX q  q Start Lowercase of Text q 3 114 003 162 03 72 00000011 01110010 ETX r  r End of Text Lowercase r 4 11 004 163 04 73 00000100 01110011 EOT s   End of Transmission Lowercase s 116 00 164 0 74 00000101 01110100 ENQ t � t Enquiry Lowercase t 6 117 006 16 06 7 00000110 01110101 ACK u  u Acknowledgment Lowercase u 7 118 007 166 07 76 00000111 01110110 BEL v  v Bell Lowercase v 8 010 08 00001000 BS  Back Space 119 167 77 01110111 w w Lowercase w 9 011 09 00001001 HT Horizontal Tab 120 10 170 012 78 0A 01111000 00001010 x LF x Lowercase x Line Feed 121 11 171 013 79 0B 01111001 00001011 y VT y  Lowercase y Vertical Tab 122 12 172 014 7A 0C 01111010 00001100 z FF z  Lowercase z Form Feed 123 13 173 01 7B 0D 01111011 00001101 { CR { Opening brace Carriage Return 124 14 174 016 7C 0E 01111100 00001110 SO  Vertical bar Shift Out / X-On 12 1 17 017 7D 0F 00001111 01111101 SI }   Shift Closing In / X-Off brace 126 16 176 020 7E 10 00010000 01111110 DLE ~  ~ Data Equivalency Line Escape sign - tilde 127 17 177 021 7F 11 00010001 01111111 DC1   Device Delete Control 1 (oft. XON) 18 022 12 00010010 DC2  Device Control 2 Safari Power Saver Click to Start Flash Plug-in 19 023 13 00010011 DC3  Device Control 3 (oft. XOFF)

Obviously it s not likely useful to remember all this, but you can see that the symbol A (capital A) is given a code (101) 8 = (41) 16 = (6) 10 and that the rest of the capital letters follow A in the usual order. This means that A uses the 7 bits 1000001 in ASCII but computers almost invariably allocate 8 bits to store each letter. If you look, you will see that there are no codes for accented letters like á or è (which you might need in Irish or French), no codes for the Greek or Russian letters, no codes for Arabic or Hindu. In fact 8 bits (or 26 total symbols) is nowhere near enough to cope with all the alphabets of the World. This is a reflection of the fact that ASCII goes back to the early days of computers when memory was relatively very scarce compared to now, and also when the computer industry was mostly American. The modern system (not yet universally used) is called UNICODE and it allocates 16 bits for each character. Even with 2 16 = 636 possible codes, there is a difficulty accommodating all the worlds writing systems (including Chinese, Japanese, mathematical symbols, etc).

Converting fractions to binary So far we have talked about integers both positive and negative. We now look at a way to convert fractions to binary. You see if we start with, say 34 we can say that is 6 + 4. We know 6 = (110)2 and if we could work out how to represent 4 as 0. something in binary then we would have 34 = 6 + 4 = (110. something)2. To work out what something should be, we work backwards from the answer.

Say the digits we want are b 1, b 2, b 3,... and so 4 = (0.b1b2b3b4 )2 We don t know any of b 1, b 2, b 3,... yet but we know they should be base 2 digits and so each one is either 0 or 1. We can write the above equation as a formula and we have If we multiply both sides by 2, we get 4 = b1 2 + b2 2 2 + b3 2 3 + b4 2 4 + 8 = b1 + b2 2 + b3 2 2 + b4 2 3 + In other words multiplying by 2 just moves the binary point and we have 8 = (b1.b2b3b4 )2

Now if we take the whole number part of both sides we get 1 on the left and b 1 on the right. So we must have b 1 = 1. But if we take the fractional parts of both sides we have 3 = (0.b2b3b4 )2 We are now in a similar situation to where we began (but not with the same fraction) and we can repeat the trick we just did. Double both sides again 6 = (b2.b3b4b )2 Take whole number parts of both sides: b 2 = 1. Take fractional parts of both sides. 1 = (0.b3b4b )2 We can repeat our trick as often as we want to uncover as many of the values b 1, b 2, b 3, etc as we have the patience to discover.

What we have is a method, in fact a repetitive method where we repeat similar instructions many times. We call a method like this an algorithm, and this kind of thing is quite easy to programme on a computer because one of the programming instructions in almost any computer language is REPEAT (meaning repeat a certain sequence of steps from where you left off the last time).

In this case we can go a few more times through the steps to see how we get on. Double both sides again. 2 = (b3.b4bb6 )2 Whole number parts: b 3 = 0. Fractional parts: Double both sides again. 2 = (0.b4bb6 )2 4 = (b4.bb6b7 )2 Whole number parts: b 4 = 0. Fractional parts: 4 = (0.bb6b7 )2 This is getting monotonous, but you see the idea. You can get as many of the b s as you like.

In fact, if you look carefully, you will see that it has now reached repetition and not just monotony. We are back to the same fraction as we began with 4. If we compare 4 = (0.bb6b7 )2 to the starting one 4 = (0.b1b2b3b4 )2 we realise that everything will unfold again exactly as before. We must find b = b 1 = 1, b 6 = b 2 = 1, b 7 = b 3 = 0, b 8 = b 4 = 0, b 9 = b = b 1 and so we have a repeating pattern of digits 1100. So we can write the binary expansion of 4 down fully as a repeating pattern and our original number as 4 = (0.1100)2 34 = (110.1100)2

Floating point format storage We have seen that in order to cope with numbers that are allowed to have fractional parts, computers use a binary version of the usual decimal point. We called it a binary point as decimal refers to base 10. Recall that what we mean by digits after the decimal point has to do with multiples of 1/10, 1/100 = 1/10 2 = 10 2, etc. So the number 367.986 means 367.986 = 3 10 2 + 6 10 + 7 + 9 10 + 8 10 2 + 6 10 3 We use the binary point in the same way with powers of 1/2. So (101.1101) 2 = 1 2 2 + 0 2 + 1 + 1 2 + 1 2 2 + 0 2 3 + 1 2 4 As in the familiar decimal system, every number can be written in binary using a binary point and as for decimals, there can sometimes be infinitely many digits after the point.

Binary Scientific Notation What we do next is use a binary version of scientific notation. The usual decimal scientific notation is like this 4321.67 =.432167 10 4 We refer to the.4321 part (a number between 1 and 10 or between -1 and -10 for negative numbers) as the mantissa. The power (in this case the 4) is called the exponent. Another decimal example is 0.00678 =.678 10 3 and here the mantissa is.678 while the exponent is 3.

This is all based on the fact that multiplying or dividing by powers of 10 simply moves the decimal point around. In binary, what happens is that multiplying or dividing by powers of 2 moves the binary point. (101) 2 = 1 2 2 + 0 2 + 1 (10.1) 2 = 1 2 + 0 + 1 = (101)2 2 1 2 (1101.11) 2 = (1.10111) 2 2 3 This last is an example of a number in the binary version of scientific notation. The mantissa is (1.110111) 2 and we can always arrange (no matter what number we are dealing with) to have the mantissa between 1 and 2. In fact always less than 2, and so of the form 1.something. The exponent in this last example is 3 the power that goes on the 2. For negative numbers we would need a minus sign in front.

What can thus write every number in this binary version of scientific notation. That saves us from having to record where to put the binary point, because it is always in the same place. Or really, the exponent tells us how far to move the point from that standard place. Computers then normally allocate a fixed number of bits for storing such numbers. The usual default is to allocate 32 bits in total (though 64 is quite common also). Within the 32 bits they have to store the mantissa and the exponent. The mantissa is already in binary, but we also need the exponent in binary. So in (1.10111) 2 2 3 the mantissa is +(1.110111) 2 while the exponent is 3 = (11) 2. Computers usually allocate 24 bits for storing the mantissa (including its possible sign) and the remaining 8 bits for the exponent.

In our example, 24 bits is plenty for the mantissa and we would need to make it longer to fill up the 24 bits: (1.110111000... ) 2 will be the same as (1.110111) 2. However, there are numbers that need more than 24 binary digits in the mantissa, and what we must then do is round off. In fact, we have to chop off the mantissa after 23 binary places (or more usually we will round up or down depending on whether the digit in the next place is 1 or 0). Filling out the example number (1.110111) 2 2 3 into 32 bits using this system, we might get: 0 1 1 1 0 1 1 1 0... 0 0... 0 1 1 1 2 3 4 6 7 8 9... 24 2... 30 31 32 We are keeping bit 1 for a possible sign on the mantissa and we also need to allow the possibility of negative exponents. For example (0.000111) 2 = (1.11) 2 2 4 is negative and so has a negative mantissa (1.11) 2. Because it is less than 1 in absolute value, it also has a negative exponent 4 = (100) 2.

To be a bit more accurate about how computers really do things, they normally put the sign bit (of the mantissa) first (or in their idea of the most prominent place), then put the 8 bits of the exponent next and the remaining 23 bits of the mantissa at the end. So a better picture for (1.110111) 2 2 3 is this: 0 0 0 1 1 1 1 1 0 1 1 1 0... 0 0 1 2 7 8 9 10 11 12 13 14 1 16 17... 31 32 ± exponent mantissa less sign This is just explained for the sake of greater accuracy but is not our main concern.

The web site: http://accu.org/index.php/articles/18 goes into quite a bit of detail about how this is done. What you get on http://www.binaryconvert.com (under floating point) tells you the outcome in examples but there are many refinements used in practice that are not evident from that and that also we won t discuss. The method we have sketched is called single precision floating point storage. There are some details we have not gone into here(such as how to store 0). Another common method, called double precision, uses 64 bits to store each number, 3 for the mantissa (including one for the sign) and 11 for the exponent.