summaryrefslogtreecommitdiff
path: root/3860/CH1
diff options
context:
space:
mode:
Diffstat (limited to '3860/CH1')
-rw-r--r--3860/CH1/EX1.10/Ex1_10.sce7
-rw-r--r--3860/CH1/EX1.10/Ex1_10.txt4
-rw-r--r--3860/CH1/EX1.11/Ex1_11.sce6
-rw-r--r--3860/CH1/EX1.11/Ex1_11.txt4
-rw-r--r--3860/CH1/EX1.12/Ex1_12.sce15
-rw-r--r--3860/CH1/EX1.12/Ex1_12.txt8
-rw-r--r--3860/CH1/EX1.13/Ex1_13.sce24
-rw-r--r--3860/CH1/EX1.13/Ex1_13.txt12
-rw-r--r--3860/CH1/EX1.15/EX1_15.sce42
-rw-r--r--3860/CH1/EX1.15/Ex1_15.txt30
-rw-r--r--3860/CH1/EX1.16/Ex1_16.sce9
-rw-r--r--3860/CH1/EX1.16/Ex1_16.txt7
-rw-r--r--3860/CH1/EX1.17/Ex1_17.sce15
-rw-r--r--3860/CH1/EX1.17/Ex1_17.txt10
-rw-r--r--3860/CH1/EX1.18/EX1_18.sce14
-rw-r--r--3860/CH1/EX1.18/Ex1_18.txt7
-rw-r--r--3860/CH1/EX1.19/EX1_19.sce14
-rw-r--r--3860/CH1/EX1.19/Ex1_19.txt8
-rw-r--r--3860/CH1/EX1.20/Ex1_20.sce13
-rw-r--r--3860/CH1/EX1.20/Ex1_20.txt7
-rw-r--r--3860/CH1/EX1.21/Ex1_21.sce18
-rw-r--r--3860/CH1/EX1.21/Ex1_21.txt12
-rw-r--r--3860/CH1/EX1.6/Ex1_6.sce5
-rw-r--r--3860/CH1/EX1.6/Ex1_6.txt3
-rw-r--r--3860/CH1/EX1.7/Ex1_7.sce5
-rw-r--r--3860/CH1/EX1.7/Ex1_7.txt4
-rw-r--r--3860/CH1/EX1.8/Ex1_8.sce5
-rw-r--r--3860/CH1/EX1.8/Ex1_8.txt4
-rw-r--r--3860/CH1/EX1.9/Ex1_9.sce6
-rw-r--r--3860/CH1/EX1.9/Ex1_9.txt4
30 files changed, 322 insertions, 0 deletions
diff --git a/3860/CH1/EX1.10/Ex1_10.sce b/3860/CH1/EX1.10/Ex1_10.sce
new file mode 100644
index 000000000..77c68e835
--- /dev/null
+++ b/3860/CH1/EX1.10/Ex1_10.sce
@@ -0,0 +1,7 @@
+//Example 1.10 Conversion from Hexadecimal to Binary.
+clc; //clears the command window.
+clear; // clears the variable browser.
+x="2EA";
+z = hex2dec(x) //Converts Hexadecimal number into decimal number.
+disp('Decimal equivalent of hexadecimal number:')
+disp(z) // displays the converted decimal number
diff --git a/3860/CH1/EX1.10/Ex1_10.txt b/3860/CH1/EX1.10/Ex1_10.txt
new file mode 100644
index 000000000..65122a221
--- /dev/null
+++ b/3860/CH1/EX1.10/Ex1_10.txt
@@ -0,0 +1,4 @@
+
+ Decimal equivalent of hexadecimal number:
+
+ 746. \ No newline at end of file
diff --git a/3860/CH1/EX1.11/Ex1_11.sce b/3860/CH1/EX1.11/Ex1_11.sce
new file mode 100644
index 000000000..8d59874a7
--- /dev/null
+++ b/3860/CH1/EX1.11/Ex1_11.sce
@@ -0,0 +1,6 @@
+//Example 1.11 Conversion from decimal number to Hexadecimal number.
+clc;
+x = 746;
+z = dec2hex(x); //hexadecimal equivalent of decimal number
+disp('The hexadecimal number is = ');
+disp(z) // answer in hexadecimal form
diff --git a/3860/CH1/EX1.11/Ex1_11.txt b/3860/CH1/EX1.11/Ex1_11.txt
new file mode 100644
index 000000000..7c2066852
--- /dev/null
+++ b/3860/CH1/EX1.11/Ex1_11.txt
@@ -0,0 +1,4 @@
+
+ The hexadecimal number is =
+
+ 2EA \ No newline at end of file
diff --git a/3860/CH1/EX1.12/Ex1_12.sce b/3860/CH1/EX1.12/Ex1_12.sce
new file mode 100644
index 000000000..d14494f32
--- /dev/null
+++ b/3860/CH1/EX1.12/Ex1_12.sce
@@ -0,0 +1,15 @@
+//Example 1.12 Addition of two Binary numbers
+clc // clears the console window
+clear // clears the variable browser
+m = bin2dec('0110'); //conversion from binary to decimal
+n = bin2dec('0111');
+k= m + n; //addition of decimal numbers
+a = dec2bin(k);//conversion from decimal to Binary
+// displays the binary addition.
+disp(a,'Addition of two Binary number 0110 and 0111 is = ')
+p = bin2dec('1101'); //conversion from binary to decimal
+q = bin2dec('0101');
+r= p + q; //addition of decimal numbers
+s = dec2bin(r);//conversion from decimal to Binary
+// displays the binary addition.
+disp(s,'Addition of two Binary number 1101 and 0101 is = ')
diff --git a/3860/CH1/EX1.12/Ex1_12.txt b/3860/CH1/EX1.12/Ex1_12.txt
new file mode 100644
index 000000000..5b7a53043
--- /dev/null
+++ b/3860/CH1/EX1.12/Ex1_12.txt
@@ -0,0 +1,8 @@
+
+ Addition of two Binary number 0110 and 0111 is =
+
+ 1101
+
+ Addition of two Binary number 1101 and 0101 is =
+
+ 10010 \ No newline at end of file
diff --git a/3860/CH1/EX1.13/Ex1_13.sce b/3860/CH1/EX1.13/Ex1_13.sce
new file mode 100644
index 000000000..5d9bd5bf9
--- /dev/null
+++ b/3860/CH1/EX1.13/Ex1_13.sce
@@ -0,0 +1,24 @@
+//Example 1.13: storage format for negative numbers in two’s complement using three-step approach:
+clc // clears the console window
+clear // clears the variable browser1
+//***************************************************************************
+x= bitcmp (5,4)// complement of decimal number 5 in 4 bit representation.
+y=1;
+z=x+y //1 is added to the complement.
+a= dec2bin (z) //binary equivalent of decimal number.
+disp ( '-5 in 2''s complement form is=')
+disp (a)// 2's complement result.
+//**************************************************************************
+j= bitcmp (1,4)// complement of decimal number 1 in 4 bit representation.
+k=1;
+l=j+k //1 is added to the complement.
+m= dec2bin (l) //binary equivalent of decimal number.
+disp ( '-1 in 2''s complement form is=')
+disp (m)// 2's complement result.
+//**************************************************************************
+p= bitcmp (0,4)// complement of decimal number 0 in 4 bit representation.
+q=1;
+r=p+q //1 is added to the complement.
+s= dec2bin (r-(2^4),4) //binary equivalent of decimal number.
+disp ( '-0 in 2''s complement form is=')
+disp (s)// 2's complement result.
diff --git a/3860/CH1/EX1.13/Ex1_13.txt b/3860/CH1/EX1.13/Ex1_13.txt
new file mode 100644
index 000000000..64acb8f86
--- /dev/null
+++ b/3860/CH1/EX1.13/Ex1_13.txt
@@ -0,0 +1,12 @@
+
+ -5 in 2's complement form is=
+
+ 1011
+
+ -1 in 2's complement form is=
+
+ 1111
+
+ -0 in 2's complement form is=
+
+ 0000 \ No newline at end of file
diff --git a/3860/CH1/EX1.15/EX1_15.sce b/3860/CH1/EX1.15/EX1_15.sce
new file mode 100644
index 000000000..247b65b58
--- /dev/null
+++ b/3860/CH1/EX1.15/EX1_15.sce
@@ -0,0 +1,42 @@
+//Example 1.15: add -5 to 7, -5 and +5 , -5 and +3
+clc//clears the console
+clear //clears all existing variables
+//****************************************************************************
+x=bitcmp(5,4) //finds complement of 5
+y=1;
+u=x+y //1 is added to the complement
+v=7;
+w=u+v
+a=dec2bin(w) //binary conversion of the decimal number
+disp(' binary form of the number obtained by adding 7 to -5 ')
+disp(a) //result is displayed
+disp(' the msb is discarded,so four bit representation in binary form =')
+a=dec2bin(w-(2^4),4)
+disp(a) //final result is displayed.
+disp('*****************************************************************')
+//****************************************************************************
+x=bitcmp(5,4) //finds complement of 5
+y=1;
+u=x+y //1 is added to the complement
+v=5;
+w=u+v
+a=dec2bin(w) //binary conversion of the decimal number
+disp(' binary form of the number obtained by adding +5 to -5 ')
+disp(a) //result is displayed
+disp(' the msb is discarded,so four bit representation in binary form =')
+a=dec2bin(w-(2^4),4)
+disp(a) //final result is displayed.
+disp('*****************************************************************')
+//****************************************************************************
+x=bitcmp(5,4) //finds complement of 5
+y=1;
+u=x+y //1 is added to the complement
+v=3;
+w=u+v
+a=dec2bin(w,5) //binary conversion of the decimal number
+disp(' binary form of the number obtained by adding +3 to -5 ')
+disp(a) //result is displayed
+disp(' the msb is discarded,so four bit representation in binary form =')
+a=dec2bin(w,4)
+disp(a) //final result is displayed.
+disp('*****************************************************************')
diff --git a/3860/CH1/EX1.15/Ex1_15.txt b/3860/CH1/EX1.15/Ex1_15.txt
new file mode 100644
index 000000000..716786861
--- /dev/null
+++ b/3860/CH1/EX1.15/Ex1_15.txt
@@ -0,0 +1,30 @@
+
+ binary form of the number obtained by adding 7 to -5
+
+ 10010
+
+ the msb is discarded,so four bit representation in binary form =
+
+ 0010
+
+ *****************************************************************
+
+ binary form of the number obtained by adding +5 to -5
+
+ 10000
+
+ the msb is discarded,so four bit representation in binary form =
+
+ 0000
+
+ *****************************************************************
+
+ binary form of the number obtained by adding +3 to -5
+
+ 01110
+
+ the msb is discarded,so four bit representation in binary form =
+
+ 1110
+
+ ***************************************************************** \ No newline at end of file
diff --git a/3860/CH1/EX1.16/Ex1_16.sce b/3860/CH1/EX1.16/Ex1_16.sce
new file mode 100644
index 000000000..8203fcf4c
--- /dev/null
+++ b/3860/CH1/EX1.16/Ex1_16.sce
@@ -0,0 +1,9 @@
+//Example 1.16: Addition of two signed numbers +5 and +4
+clc;
+x=5;
+y=4;
+z=x+y;
+r = dec2bin(z); // binary equivalent of decimal number
+disp('The binary number is = ');
+disp(r)
+disp('The answer produced is clearly wrong because the correct answer (+9) is out of range. Overflow occurs when the sum is out of range. For 4-bit signed numbers,that range is -8 <= sum <= 7.')
diff --git a/3860/CH1/EX1.16/Ex1_16.txt b/3860/CH1/EX1.16/Ex1_16.txt
new file mode 100644
index 000000000..5e4000b04
--- /dev/null
+++ b/3860/CH1/EX1.16/Ex1_16.txt
@@ -0,0 +1,7 @@
+
+ The binary number is =
+
+ 1001
+
+ The answer produced is clearly wrong because the correct answer (+9) is out of range. Overflow occurs when the sum is out of range. For 4-bit signed numb
+ ers,that range is -8 <= sum <= 7. \ No newline at end of file
diff --git a/3860/CH1/EX1.17/Ex1_17.sce b/3860/CH1/EX1.17/Ex1_17.sce
new file mode 100644
index 000000000..ba39186cc
--- /dev/null
+++ b/3860/CH1/EX1.17/Ex1_17.sce
@@ -0,0 +1,15 @@
+//Example 1.17: Addition of two signed numbers -5 and -4
+clc;
+x=bitcmp(5,4) //finds complement of 5
+y=1;
+u=x+y //1 is added to the complement
+l=bitcmp(4,4) //finds complement of 5
+m=1;
+n=l+m //1 is added to the complement
+z=n+u;
+r = dec2bin(z); // binary equivalent of decimal number
+disp('The binary number is = ');
+disp(r)
+disp('The msb is discarded, and binary number becomes')
+disp('0111')
+disp('This time, two negetive numbers produced a sum that looks positive.')
diff --git a/3860/CH1/EX1.17/Ex1_17.txt b/3860/CH1/EX1.17/Ex1_17.txt
new file mode 100644
index 000000000..fb30e5006
--- /dev/null
+++ b/3860/CH1/EX1.17/Ex1_17.txt
@@ -0,0 +1,10 @@
+
+ The binary number is =
+
+ 10111
+
+ The msb is discarded, and binary number becomes
+
+ 0111
+
+ This time, two negetive numbers produced a sum that looks positive. \ No newline at end of file
diff --git a/3860/CH1/EX1.18/EX1_18.sce b/3860/CH1/EX1.18/EX1_18.sce
new file mode 100644
index 000000000..ae23d476c
--- /dev/null
+++ b/3860/CH1/EX1.18/EX1_18.sce
@@ -0,0 +1,14 @@
+//Example 1.18: add 7 to -5
+clc//clears the console
+clear //clears all existing variables
+x=bitcmp(5,4) //finds complement of 5
+y=1;
+u=x+y //1 is added to the complement
+v=7;
+w=u+v
+a=dec2bin(w) //binary conversion of the decimal number
+disp(' binary form of the number obtained by adding 7 to -5 ')
+disp(a) //result is displayed
+disp(' the msb is discarded,so four bit representation in binary form =')
+a=dec2bin(w-(2^4),4)
+disp(a) //final result is displayed.
diff --git a/3860/CH1/EX1.18/Ex1_18.txt b/3860/CH1/EX1.18/Ex1_18.txt
new file mode 100644
index 000000000..7379ed875
--- /dev/null
+++ b/3860/CH1/EX1.18/Ex1_18.txt
@@ -0,0 +1,7 @@
+ binary form of the number obtained by adding 7 to -5
+
+ 10010
+
+ the msb is discarded,so four bit representation in binary form =
+
+ 0010 \ No newline at end of file
diff --git a/3860/CH1/EX1.19/EX1_19.sce b/3860/CH1/EX1.19/EX1_19.sce
new file mode 100644
index 000000000..b668a1342
--- /dev/null
+++ b/3860/CH1/EX1.19/EX1_19.sce
@@ -0,0 +1,14 @@
+//Example 1.19: add 7 to -5
+clc//clears the console
+clear //clears all existing variables
+x=bitcmp(5,4) //computes bit by bit complement of 5
+y=1;
+u=x+y //1 is added to the complement
+v=7;
+w=u+v
+a=dec2bin(w) //binary conversion of the decimal number
+disp(' binary form of the number obtained by adding 7 to -5 ')
+disp(a) //result is displayed
+disp(' the msb is discarded,so four bit representation in binary form =')
+a=dec2bin(w-(2^4),4)
+disp(a) //final result is displayed.
diff --git a/3860/CH1/EX1.19/Ex1_19.txt b/3860/CH1/EX1.19/Ex1_19.txt
new file mode 100644
index 000000000..36bf6756e
--- /dev/null
+++ b/3860/CH1/EX1.19/Ex1_19.txt
@@ -0,0 +1,8 @@
+
+ binary form of the number obtained by adding 7 to -5
+
+ 10010
+
+ the msb is discarded,so four bit representation in binary form =
+
+ 0010 \ No newline at end of file
diff --git a/3860/CH1/EX1.20/Ex1_20.sce b/3860/CH1/EX1.20/Ex1_20.sce
new file mode 100644
index 000000000..7af8aef1a
--- /dev/null
+++ b/3860/CH1/EX1.20/Ex1_20.sce
@@ -0,0 +1,13 @@
+//Example 1.20: Addition of two unsigned numbers 14-10.
+clc;
+x=bitcmp(10,4) //finds complement of 5
+y=1;
+u=x+y //1 is added to the complement
+w=14
+z=w+u;
+r = dec2bin(z); // binary equivalent of decimal number
+disp('The binary number is = ');
+disp(r)
+disp('The msb is discarded, and binary number becomes')
+disp('0100')
+
diff --git a/3860/CH1/EX1.20/Ex1_20.txt b/3860/CH1/EX1.20/Ex1_20.txt
new file mode 100644
index 000000000..fb25f9cb1
--- /dev/null
+++ b/3860/CH1/EX1.20/Ex1_20.txt
@@ -0,0 +1,7 @@
+ The binary number is =
+
+ 10100
+
+ The msb is discarded, and binary number becomes
+
+ 0100 \ No newline at end of file
diff --git a/3860/CH1/EX1.21/Ex1_21.sce b/3860/CH1/EX1.21/Ex1_21.sce
new file mode 100644
index 000000000..f07a47cc5
--- /dev/null
+++ b/3860/CH1/EX1.21/Ex1_21.sce
@@ -0,0 +1,18 @@
+//Example 1.21: Overflow for unsigned numbers in Example 1.21(a) and for signed numbers in Example 1.21(b)
+clc;
+disp('Example 1.21(a)')
+x=bitcmp(7,4) //finds complement of 5
+y=1;
+u=x+y //1 is added to the complement
+w=5
+z=w+u;
+r = dec2bin(z); // binary equivalent of decimal number
+disp('The binary number is = ');
+disp(r)
+disp('Example 1.21(b)')
+x=7
+y=5;
+u=x+y //1 is added to the complement
+r = dec2bin(u); // binary equivalent of decimal number
+disp('The binary number is = ');
+disp(r)
diff --git a/3860/CH1/EX1.21/Ex1_21.txt b/3860/CH1/EX1.21/Ex1_21.txt
new file mode 100644
index 000000000..d307234cd
--- /dev/null
+++ b/3860/CH1/EX1.21/Ex1_21.txt
@@ -0,0 +1,12 @@
+
+ Example 1.21(a)
+
+ The binary number is =
+
+ 1110
+
+ Example 1.21(b)
+
+ The binary number is =
+
+ 1100 \ No newline at end of file
diff --git a/3860/CH1/EX1.6/Ex1_6.sce b/3860/CH1/EX1.6/Ex1_6.sce
new file mode 100644
index 000000000..49b4e2bb3
--- /dev/null
+++ b/3860/CH1/EX1.6/Ex1_6.sce
@@ -0,0 +1,5 @@
+//Example 1.6 Conversion from decimal number to binary number.
+clc; //clears the console
+x = dec2bin(746); // binary equivalent of decimal number
+disp('The binary number is = ');
+disp(x) // answer in binary form
diff --git a/3860/CH1/EX1.6/Ex1_6.txt b/3860/CH1/EX1.6/Ex1_6.txt
new file mode 100644
index 000000000..5dc3f140a
--- /dev/null
+++ b/3860/CH1/EX1.6/Ex1_6.txt
@@ -0,0 +1,3 @@
+ The binary number is =
+
+ 1011101010 \ No newline at end of file
diff --git a/3860/CH1/EX1.7/Ex1_7.sce b/3860/CH1/EX1.7/Ex1_7.sce
new file mode 100644
index 000000000..880188e56
--- /dev/null
+++ b/3860/CH1/EX1.7/Ex1_7.sce
@@ -0,0 +1,5 @@
+//Example 1.7 Conversion from decimal number to binary number.
+clc;
+x = dec2bin(746); // binary equivalent of decimal number
+disp('The binary number is = ');
+disp(x) // answer in binary form
diff --git a/3860/CH1/EX1.7/Ex1_7.txt b/3860/CH1/EX1.7/Ex1_7.txt
new file mode 100644
index 000000000..2c01fcf18
--- /dev/null
+++ b/3860/CH1/EX1.7/Ex1_7.txt
@@ -0,0 +1,4 @@
+
+ The binary number is =
+
+ 1011101010 \ No newline at end of file
diff --git a/3860/CH1/EX1.8/Ex1_8.sce b/3860/CH1/EX1.8/Ex1_8.sce
new file mode 100644
index 000000000..77e476d08
--- /dev/null
+++ b/3860/CH1/EX1.8/Ex1_8.sce
@@ -0,0 +1,5 @@
+//Example 1.8 Conversion from decimal number to binary number.
+clc;
+x = dec2bin(105); // binary equivalent of decimal number
+disp('The binary number is = ');
+disp(x) // answer in binary form
diff --git a/3860/CH1/EX1.8/Ex1_8.txt b/3860/CH1/EX1.8/Ex1_8.txt
new file mode 100644
index 000000000..c38cf6adc
--- /dev/null
+++ b/3860/CH1/EX1.8/Ex1_8.txt
@@ -0,0 +1,4 @@
+
+ The binary number is =
+
+ 1101001 \ No newline at end of file
diff --git a/3860/CH1/EX1.9/Ex1_9.sce b/3860/CH1/EX1.9/Ex1_9.sce
new file mode 100644
index 000000000..a540b9453
--- /dev/null
+++ b/3860/CH1/EX1.9/Ex1_9.sce
@@ -0,0 +1,6 @@
+//Example 1.9 Conversion from binary number to Hexadecimal number.
+clc;
+x = bin2dec('1011101010'); // decimal equivalent of binary number
+z = dec2hex(x); //hexadecimal equivalent of decimal number
+disp('The hexadecimal number is = ');
+disp(z) // answer in hexadecimal form
diff --git a/3860/CH1/EX1.9/Ex1_9.txt b/3860/CH1/EX1.9/Ex1_9.txt
new file mode 100644
index 000000000..7c2066852
--- /dev/null
+++ b/3860/CH1/EX1.9/Ex1_9.txt
@@ -0,0 +1,4 @@
+
+ The hexadecimal number is =
+
+ 2EA \ No newline at end of file