diff options
author | priyanka | 2015-06-24 15:03:17 +0530 |
---|---|---|
committer | priyanka | 2015-06-24 15:03:17 +0530 |
commit | b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch) | |
tree | ab291cffc65280e58ac82470ba63fbcca7805165 /1241/CH2/EX2.35 | |
download | Scilab-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.35')
-rwxr-xr-x | 1241/CH2/EX2.35/exa2_35.sce | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/1241/CH2/EX2.35/exa2_35.sce b/1241/CH2/EX2.35/exa2_35.sce new file mode 100755 index 000000000..32d771fec --- /dev/null +++ b/1241/CH2/EX2.35/exa2_35.sce @@ -0,0 +1,31 @@ +//Example 2-35//
+//-4 in two's complement by third method//
+clc
+//clears the console//
+clear
+//clears all existing variables//
+a=00000100
+c=0
+z=0
+for i=1: 8
+ x(i)=modulo(a,10)
+ a=a/10
+ a=floor(a)
+end
+for i=1: 8
+ if c>1 then
+ break
+ end
+ if x(i)==1 then
+ for k=i+1: 8
+ x(k)=bitcmp(x(k),1)
+ c=c+1
+ end
+ end
+end
+for i=1: 8
+ z=z+x(i)*10^(i-1)
+end
+disp('-4 in twos complement is :')
+disp(z)
+//answer is displayed//
|