diff options
Diffstat (limited to '3860/CH1/EX1.21/Ex1_21.sce')
-rw-r--r-- | 3860/CH1/EX1.21/Ex1_21.sce | 18 |
1 files changed, 18 insertions, 0 deletions
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)
|