diff options
Diffstat (limited to '3860/CH1/EX1.17')
-rw-r--r-- | 3860/CH1/EX1.17/Ex1_17.sce | 15 | ||||
-rw-r--r-- | 3860/CH1/EX1.17/Ex1_17.txt | 10 |
2 files changed, 25 insertions, 0 deletions
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 |