Docsity

Limits on Computing: Understanding Large Numbers and Floating-Point Arithmetic, Slides of Artificial Intelligence

Toggle sidebar
bg1
1
CSCI 100
Think Like Computers
Lecture 3
Fall 2008
Linux
•ls [file-or-dir]
•ls –l [file-or-dir]
•cd directorypath
•mkdir dir
•rmdir dir
•cp … (copy)
•mv … (move, rename)
•rm … (remove)
•Path:
dir/subdir/subsubdir
•Special file/dir:
. and ..
~, ~username
•Wildcards
*
?
•Help:
man …
Remote Login
•Use secure shell (ssh) to connect to
csgateway.clarku.edu
•Use secure ftp (sftp) to transfer files
(download/upload)
Homework
•Create your own homepage
Create the directory ~/public_html
Create the file ~/public_html/index.html
Change the permissions so that they are
accessible to others
chmod
Change file access mode
•chmod : change read, write, execute/directory
search permissions for user/group/others
•-rwxrwxrwx and drwxrwxrwx
-rw------ means the file is not executable, can be
read/write by the user (owner only)
drwxr-xr-x means the directory can be read/searched
by everyone, but modified only by owner
•So, all web pages/files should be -rw-r--r--,
and all web directory should be drwx--x--x
•This is done by:
chmod go+r file_name
chmod go+x directory_name
•There are limitations imposed by the hardware
on the representations of both integer numbers
and real numbers
If the word length is 32 bits, the range of integer
numbers that can be represented is -2,147,483,648 to
2,147,483,647
There are software solutions, however, that allow
programs to overcome these limitations
For example, we could represent a very large number
as a list of smaller numbers
Limits on Arithmetic
Docsity.com
pf3
pf4
pf5

Partial preview of the text

Download Limits on Computing: Understanding Large Numbers and Floating-Point Arithmetic and more Slides Artificial Intelligence in PDF only on Docsity!

CSCI 100

Think Like Computers

Lecture 3

Fall 2008

Linux

  • ls [file-or-dir]
  • ls –l [file-or-dir]
  • cd directorypath
  • mkdir dir
  • rmdir dir
  • cp … (copy)
  • mv … (move, rename)
  • rm … (remove)
    • Path: Š dir/subdir/subsubdir
    • Special file/dir: Š. and .. Š ~, ~ username
    • Wildcards Š * Š?
    • Help: Š man …

Remote Login

  • Use secure shell (ssh) to connect to

csgateway.clarku.edu

  • Use secure ftp (sftp) to transfer files

(download/upload)

Homework

  • Create your own homepage Š Create the directory ~/public_html Š Create the file ~/public_html/index.html

Š Change the permissions so that they are accessible to others Š chmod

Change file access mode

  • chmod : change read, write, execute/directory search permissions for user/group/others
  • -rwxrwxrwx and drwxrwxrwx Š -rw------ means the file is not executable, can be read/write by the user (owner only) Š drwxr-xr-x means the directory can be read/searched by everyone, but modified only by owner
  • So, all web pages/files should be -rw-r--r--, and all web directory should be drwx--x--x
  • This is done by: Š chmod go+r file_name Š chmod go+x directory_name - There are limitations imposed by the hardware on the representations of both integer numbers and real numbers Š If the word length is 32 bits, the range of integer numbers that can be represented is -2,147,483,648 to 2,147,483, Š There are software solutions, however, that allow programs to overcome these limitations Š For example, we could represent a very large number as a list of smaller numbers

Limits on Arithmetic

Limits on Arithmetic

Representing very large numbers

Limits on Arithmetic

Real numbers are stored as an integer

along with information showing the location

of the radix point

  • Let’s assume that we have a computer in which each memory location is the same size and is divided into a sign plus five decimal digits
  • When a real variable is declared or a real constant is defined, the number stored there has both a whole number part and a fractional part

Limits on Arithmetic

  • The range of the numbers we can

represent with five digits is -99,

through +99,999:

Limits on Arithmetic

  • The precision (the maximum number of digits that can be represented) is five digits, and each number within that range can be represented exactly
  • What happens if we allow one of these digits (let’s say the leftmost one, in red) to represent an exponent?
  • For example

Š represents the number +2,345 * 10^3

Limits on Arithmetic

  • The range of numbers we can now

represent is much larger:

-9,999 * 109 to +9,999 * 109

or

-9,999,000,000,000 to +9,999,000,000,

  • We can represent only four significant

digits

Limits on Arithmetic

  • The four leftmost digits are correct, and the balance of the digits are assumed to be zero
  • We lose the rightmost, or least significant , digits

Limits on Communications

  • Error-detecting codes determine that an

error has occurred during the transmission

of data and then alert the system

  • Error-correcting codes not only determine

that an error has occurred but try to

determine the correct value actually

Limits on Communications

  • Parity bits are used to detect that an error

has occurred between the storing and

retrieving of a byte or the sending and

receiving of a byte

Parity bit An extra bit that is associated with each byte, used to ensure that the number of 1 bits in a 9-bit value (byte plus parity bit) is odd (or even) across all bytes

Limits on Communications

  • Odd parity requires the number of 1s in a byte plus parity bit to be odd For example ƒ If a byte contains the pattern 11001100, the parity bit would be 1, thus giving an odd number of 1s ƒ If the pattern were 11110001, the parity bit would be 0, giving an odd number of 1s
  • Even parity uses the same scheme, but the number of 1 bits must be even

Limits on Communications

  • Check digits Š A software variation of the same scheme is to sum the individual digits of a number, and then store the unit’s digit of that sum with the number Š For example, given the number 34376, the sum of the digits is 23, so the number would be stored as 34376–
  • Error-correcting codes Š If enough information about a byte or number is kept, it is possible to deduce what an incorrect bit or digit must be

Complexity of Software

  • Commercial software contains errors

Š The problem is complexity Š Software testing can demonstrate the presence of bugs but cannot demonstrate their absence ƒ As we find problems and fix them, we raise our confidence that the software performs as it should ƒ But we can never guarantee that all bugs have been removed

Software Engineering

  • A guideline for the number of errors per lines of code that can be expected Š Standard software: 25 bugs per 1,000 lines of program Š Good software: 2 errors per 1,000 lines Š Space Shuttle software: < 1 error per 10,000 lines

Formal Verification

  • The verification of program correctness, independent of data testing, is an important area of theoretical computer science research
  • Formal methods have been used successfully in verifying the correctness of computer chips
  • It is hoped that success with formal verification techniques at the hardware level can lead eventually to success at the software level

Notorious Software Errors

  • AT&T Down for Nine Hours Š In January of 1990, AT&T’s long-distance telephone network came to a screeching halt for nine hours, because of a software error in an upgrade to the electronic switching systems

Notorious Software Errors

  • Therac-

Š Between June 1985 and January 1987, six known accidents involved massive overdoses by the Therac-25, leading to deaths and serious injuries Š There was only a single coding error, but tracking down the error exposed that the whole design was seriously flawed

Notorious Software Errors

  • Mariner 1 Venus Probe This probe, launched in July of 1962, veered off course almost immediately and had to be destroyed The problem was traced to the following line of Fortran code:

D O 5 K = 1. 3 The period should have been a comma. An $18.5 million space exploration vehicle was lost because of this typographical error