summaryrefslogtreecommitdiff
path: root/1241/CH2/EX2.45
diff options
context:
space:
mode:
authorpriyanka2015-06-24 15:03:17 +0530
committerpriyanka2015-06-24 15:03:17 +0530
commitb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch)
treeab291cffc65280e58ac82470ba63fbcca7805165 /1241/CH2/EX2.45
downloadScilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz
Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2
Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip
initial commit / add all books
Diffstat (limited to '1241/CH2/EX2.45')
-rwxr-xr-x1241/CH2/EX2.45/exa2_45.sce20
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//