Inductive programming incorporates all approaches which are concerned with learning programs or algorithms from incomplete (formal) specifications. Possible inputs in an IP system are a set of training inputs and corresponding outputs or an output evaluation function, describing the desired behavior of the intended program, traces or action sequences which describe the process of calculating specific outputs, constraints for the program to be induced concerning its time efficiency or its complexity, various kinds of background knowledge such as standard data types, predefined functions to be used, program schemes or templates describing the data flow of the intended program, heuristics for guiding the search for a solution or other biases.
Output of an IP system is a program in some arbitrary programming language containing conditionals and loop or recursive control structures, or any other kind of Turing-complete representation language.
In many applications the output program must be correct with respect to the examples and partial specification, and this leads to the consideration of inductive programming as a special area inside automatic programming or program synthesis, usually opposed to 'deductive' program synthesis, where the specification is usually complete.
In other cases, inductive programming is seen as a more general area where any declarative programming or representation language can be used and we may even have some degree of error in the examples, as in general machine learning, the more specific area of structure mining or the area of symbolic artificial intelligence. A distinctive feature is the number of examples or partial specification needed. Typically, inductive programming techniques can learn from just a few examples.
The diversity of inductive programming usually comes from the applications and the languages that are used: apart from logic programming and functional programming, other programming paradigms and representation languages have been used or suggested in inductive programming, such as functional logic programming, constraint
programming, probabilistic programming
Research on the inductive synthesis of recursive functional programs started in the early 1970s and was brought onto firm theoretical foundations with the seminal THESIS system of Summers[6] and work of Biermann.[7] These approaches were split into two phases: first, input-output examples are transformed into non-recursive programs (traces) using a small set of basic operators; second, regularities in the traces are searched for and used to fold them into a recursive program. The main results until the mid 1980s are surveyed by Smith.[8] Due to
Computer Arithmetic: Number Representation and Binary Operations
1. Computer Arithmetic
By
Roll No. 2,Roll No.10
Department of CS & IT
University of Azad Jammu & Kashmir, MZD
To
Prof. Dr. Wajid Aziz Loun
Chairman, DCS & IT/Prof. of Subject
Advance Computer Architecture
University of Azad Jammu & Kashmir, MZD
2. Presentation Topics
Part I: Number Representation
Part II: Addition / Subtraction
Part III: Multiplication
Part IV: Division
3. Arithmetic & Logic Unit
• Does the calculations
• Handles integers
• May handle floating point (real) numbers
4. Integer Representation
• In binary number system, an arbitrary number can be represented with
– Zero and one
– The minus sign
– And period, or radix point
– e.g.
• For computer storage and processing
– Only have 0 & 1 to represent everything
– Positive numbers stored in binary. (For example 41=00101001)
– No minus sign
– No period
• In general, for n-bit sequence of binary digits an-1 an-2 … a1, ao interpreted
as unsigned integer A will have value
å-
=
=
1
0
2
n
i
i
A i a
5. What’s ALU?
1. ALU stands for: Arithmetic Logic Unit
2. ALU is a digital circuit that performs
Arithmetic (Add, Sub, . . .) and Logical (AND,
OR, NOT) operations.
3. John Von Neumann proposed the ALU in
1945 when he was working on EDVAC.
Computer Arithmetic, Number
Representation
7. Introduction to Numbering Systems
• We are all familiar with the decimal number
system (Base 10). Some other number
systems that we will work with are:
– Binary ® Base 2
– Octal ® Base 8
– Hexadecimal ® Base 16
8. Characteristics of Numbering Systems
1) The digits are consecutive.
2) The number of digits is equal to the size of the
base.
3) Zero is always the first digit.
4) When 1 is added to the largest digit, a sum of zero
and a carry of one results.
5) Numeric values determined by the have implicit
positional values of the digits.
9. Significant Digits
Binary: 11101101
Most significant digit Least significant digit
Hexadecimal: 1D63A7A
Most significant digit Least significant digit
10. Binary Number System
• Also called the “Base 2 system”
• The binary number system is used to model the
series of electrical signals computers use to
represent information
• 0 represents the no voltage or an off state
• 1 represents the presence of voltage or an
on state
11. Binary Numbering Scale
Base 2
Number
Base 10
Equivalent Power Positional
Value
000 0 20 1
001 1 21 2
010 2 22 4
011 3 23 8
100 4 24 16
101 5 25 32
110 6 26 64
111 7 27 128
12. Binary Addition
4 Possible Binary Addition Combinations:
(1) 0 (2) 0
+0 +1
00 01
Carry Sum
(3) 1 (4) 1
+0 +1
01 10
Note that leading
zeroes are frequently
dropped.
13. Decimal to Binary Conversion
• The easiest way to convert a decimal number to its
binary equivalent is to use the Division Algorithm
• This method repeatedly divides a decimal number by
2 and records the quotient and remainder
– The remainder digits (a sequence of zeros and ones) form
the binary equivalent in least significant to most
significant digit sequence
14. Division Algorithm
Convert 67 to its binary equivalent:
6710 = x2
Step 1: 67 / 2 = 33 R 1 Divide 67 by 2. Record quotient in next row
Step 2: 33 / 2 = 16 R 1 Again divide by 2; record quotient in next row
Step 3: 16 / 2 = 8 R 0 Repeat again
Step 4: 8 / 2 = 4 R 0 Repeat again
Step 5: 4 / 2 = 2 R 0 Repeat again
Step 6: 2 / 2 = 1 R 0 Repeat again
Step 7: 1 / 2 = 0 R 1 STOP when quotient equals 0
1 0 0 0 0 1 12
15. Binary to Decimal Conversion
• The easiest method for converting a binary
number to its decimal equivalent is to use the
Multiplication Algorithm
• Multiply the binary digits by increasing powers
of two, starting from the right
• Then, to find the decimal number equivalent,
sum those products
16. Multiplication Algorithm
Convert (10101101)2 to its decimal equivalent:
Binary 1 0 1 0 1 1 0 1
Positional Values x x x x x x x x
27 26 25 24 23 22 21 20
Products 128 + 32 + 8 + 4 + 1
17310
17. Octal Number System
• Also known as the Base 8 System
• Uses digits 0 - 7
• Readily converts to binary
• Groups of three (binary) digits can be used to
represent each octal digit
• Also uses multiplication and division
algorithms for conversion to and from base 10
18. Decimal to Octal Conversion
Convert 42710 to its octal equivalent:
427 / 8 = 53 R3 Divide by 8; R is LSD
53 / 8 = 6 R5 Divide Q by 8; R is next digit
6 / 8 = 0 R6 Repeat until Q = 0
6538
19. Octal to Decimal Conversion
Convert 6538 to its decimal equivalent:
6 5 3
x x 2 81 80
x8
384 + 40 + 3
42710
Octal Digits
Positional Values
Products
20. Octal to Binary Conversion
Each octal number converts to 3 binary digits
To convert 6538 to binary, just
substitute code:
6 5 3
110 101 011
21. Hexadecimal Number System
• Base 16 system
• Uses digits 0-9 &
letters A,B,C,D,E,F
• Groups of four bits
represent each
base 16 digit
22. Decimal to Hexadecimal Conversion
Convert 83010 to its hexadecimal equivalent:
830 / 16 = 51 R14
51 / 16 = 3 R3
3 / 16 = 0 R3
33E16
= E in Hex
23. Hexadecimal to Decimal Conversion
Convert 3B4F16 to its decimal equivalent:
Hex Digits
3 B 4 Fx
x x
163 162 161 160
12288 +2816 + 64 +15
15,18310
Positional Values
Products
x
24. Binary to Hexadecimal Conversion
• The easiest method for converting binary to
hexadecimal is to use a substitution code
• Each hex number converts to 4 binary digits
25. Substitution Code
Convert 0101011010101110011010102 to hex using the
4-bit substitution code :
5 6 A E 6 A
0101 0110 1010 1110 0110 1010
56AE6A16
26. Substitution Code
Substitution code can also be used to convert binary to
octal by using 3-bit groupings:
2 5 5 2 7 1 5 2
010 101 101 010 111 001 101 010
255271528
27. Complementary Arithmetic
• 1’s complement
– Switch all 0’s to 1’s and 1’s to 0’s
Binary # 10110011
1’s complement 01001100
28. Complementary Arithmetic
• 2’s complement
– Step 1: Find 1’s complement of the number
Binary # 11000110
1’s complement 00111001
– Step 2: Add 1 to the 1’s complement
00111001
+ 00000001
00111010
29. Signed Magnitude Numbers
110010.. …00101110010101
Sign bit
0 = positive
1 = negative
31 bits for magnitude
This is your basic
Integer format
30. Sign-Magnitude
• Left most bit is sign bit
– 0 means positive
– 1 means negative
• +18 = 00010010
• -18 = 10010010
• The general case can be expressed as follows
• Problems
ü
=
å
a if a
2 0
-
– Need to consider both sign and magnitude in arithmetic
– Two representations of zero (+0 and -0)
+010 = 00000000
-010 = 10000000
ï ïþ
ï ïý
ï ïî
ï ïí ì
- =
=
å
=
-
-
=
-
2
0
1
2
0
1
2 1
n
i
i n
i
n
i
i n
i
a if a
A
31. Negation (Sign Magnitude Representation)
• In sign magnitude representation, the sign bit
is inverted for forming negative of an integer.
– For 8 bit sign magnitude representation
+1810 = 00010010
-1810 = 10010010
– For 16 bit sign magnitude representation
+1810 =0000000000010010
-1810 =1000000000010010
32. Two’s Compliment
• The general expression for two’s complement
representation is
A n a a
• +3 = 00000011
• +2 = 00000010
• +1 = 00000001
• +0 = 00000000
• -1 = 11111111
• -2 = 11111110
• -3 = 11111101
å-
2 1 2
=
= - - +
-
2
0
1
n
i
i
i
n
33. Negation (Twos Complement Representation)
• In twos complement representation, negation of
an integer can be formed with following rules.
– Take the Boolean complement of each bir of integer
(including sign bit).
– Add 1 treating the result as an unsigned integer.
• The two step process is referred to as twos
complement operation.
+18=00010010
Bitwise Complement =11101101
+ 1
11101110= -18
34. Negation Special Case 1
• The negation of 0 is 0.
0 = 00000000
Bitwise not 11111111
Add 1 to LSB +1
Result 100000000=0
• Overflow is ignored, so:
• The result of negation of 0 is 0.
35. Negation Special Case 2
• The negation of the bit pattern followed by n-1
zeros results back the same number.
-128 = 10000000
Bitwise not 01111111
Add 1 to LSB +1
Result 10000000=-128
• Monitor MSB (sign bit)
• It should change during negation
• Such anomaly is unavoidable.
36. Value Box for Conversion between Twos Complement Binary
and Decimal
-128 64 32 16 8 4 2 1
An Eight Position Twos Complement Value Box
-128 64 32 16 8 4 2 1
1 0 0 0 0 0 1 1
-128 +2 +1 =-125
Converting Binary 10000011 to Decimal
-128 64 32 16 8 4 2 1
1 0 0 0 1 0 0 0
-128 +8 =-120
Converting Decimal -120 to Binary
37. Conversion Between Lengths
• Positive number pack with leading zeros
+18 = 00010010
+18 = 00000000 00010010
• Negative numbers pack with leading ones
-18 = 10010010
-18 = 11111111 10010010
• i.e. pack with MSB (sign bit)
38. Addition and Subtraction
• Normal binary addition
• Monitor sign bit for overflow
• Take twos compliment of subtrahend and add
to minuend
– i.e. a - b = a + (-b)
• So we only need addition and complement
circuits