diff options
Diffstat (limited to '1241/CH2/EX2.45/exa2_45.sce')
-rwxr-xr-x | 1241/CH2/EX2.45/exa2_45.sce | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/1241/CH2/EX2.45/exa2_45.sce b/1241/CH2/EX2.45/exa2_45.sce new file mode 100755 index 000000000..b1ca47afd --- /dev/null +++ b/1241/CH2/EX2.45/exa2_45.sce @@ -0,0 +1,20 @@ +//Example 2-45//
+//add 3 to -2 in one's complement using 8 bits//
+clc
+//clears the window//
+clear
+//clears all the existing variables//
+x=3
+y=bitcmp(2,8)
+//complement of the decimal number 2//
+z=x+y+1
+//carry is added//
+a=dec2bin(z)
+//binary conversion//
+disp('binary form of the number obtained by adding 3 to -2')
+disp(a)
+//result is displayed//
+disp('msb is discarded,8 bit representation is the answer in binary form')
+a=dec2bin(z-(2^8))
+disp(a)
+//Final result is displayed//
|