diff options
Diffstat (limited to '1241/CH2/EX2.31/exa2_31.sce')
-rwxr-xr-x | 1241/CH2/EX2.31/exa2_31.sce | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/1241/CH2/EX2.31/exa2_31.sce b/1241/CH2/EX2.31/exa2_31.sce new file mode 100755 index 000000000..7df6134b3 --- /dev/null +++ b/1241/CH2/EX2.31/exa2_31.sce @@ -0,0 +1,26 @@ +//Example 2-31//
+// -4,-15,-17 in two’s complement form//
+clc
+//clears the console//
+clear
+//clears all existing variables//
+x=2^12
+//Smallest nine bit number//
+p=4
+q=15
+r=17
+u=x-p
+v=x-q
+w=x-r
+//subtraction//
+a=dec2bin(u)
+b=dec2bin(v)
+c=dec2bin(w)
+//binary conversion of the decimal number//
+disp(' -4 in two’s complement form is ')
+disp(a)
+disp(' -15 in two’s complement form is ')
+disp(b)
+disp(' -17 in two’s complement form is ')
+disp(c)
+//answers in binary form//
|