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 /1733/CH9 | |
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 '1733/CH9')
-rwxr-xr-x | 1733/CH9/EX9.1/9_1.sce | 6 | ||||
-rwxr-xr-x | 1733/CH9/EX9.10/9_10.sce | 15 | ||||
-rwxr-xr-x | 1733/CH9/EX9.11/9_11.sce | 16 | ||||
-rwxr-xr-x | 1733/CH9/EX9.12/9_12.sce | 26 | ||||
-rwxr-xr-x | 1733/CH9/EX9.13/9_13.sce | 26 | ||||
-rwxr-xr-x | 1733/CH9/EX9.14/9_14.sce | 27 | ||||
-rwxr-xr-x | 1733/CH9/EX9.15/9_15.sce | 10 | ||||
-rwxr-xr-x | 1733/CH9/EX9.16/9_16.sce | 38 | ||||
-rwxr-xr-x | 1733/CH9/EX9.17/9_17.sce | 6 | ||||
-rwxr-xr-x | 1733/CH9/EX9.18/9_18.sce | 6 | ||||
-rwxr-xr-x | 1733/CH9/EX9.19/9_19.sce | 6 | ||||
-rwxr-xr-x | 1733/CH9/EX9.2/9_2.sce | 6 | ||||
-rwxr-xr-x | 1733/CH9/EX9.20/9_20.sce | 6 | ||||
-rwxr-xr-x | 1733/CH9/EX9.3/9_3.sce | 6 | ||||
-rwxr-xr-x | 1733/CH9/EX9.4/9_4.sce | 10 | ||||
-rwxr-xr-x | 1733/CH9/EX9.5/9_5.sci | 11 | ||||
-rwxr-xr-x | 1733/CH9/EX9.6/9_6.sci | 11 | ||||
-rwxr-xr-x | 1733/CH9/EX9.7/9_7.sce | 12 | ||||
-rwxr-xr-x | 1733/CH9/EX9.8/9_8.sce | 21 | ||||
-rwxr-xr-x | 1733/CH9/EX9.9/9_9.sce | 8 |
20 files changed, 273 insertions, 0 deletions
diff --git a/1733/CH9/EX9.1/9_1.sce b/1733/CH9/EX9.1/9_1.sce new file mode 100755 index 000000000..cc5dc8084 --- /dev/null +++ b/1733/CH9/EX9.1/9_1.sce @@ -0,0 +1,6 @@ +//9.1
+clc;
+x=10;
+disp('The binary number is')
+a=dec2bin(x);
+disp('',a)
\ No newline at end of file diff --git a/1733/CH9/EX9.10/9_10.sce b/1733/CH9/EX9.10/9_10.sce new file mode 100755 index 000000000..087e06234 --- /dev/null +++ b/1733/CH9/EX9.10/9_10.sce @@ -0,0 +1,15 @@ +//9.10
+clc;
+c=24;
+xc= bitcmp (c ,8);
+A=xc+1;
+B=16;
+Ans=A+B;
+a=dec2bin(Ans)
+disp(a)
+disp('Since the MSB is 1 so the number is negative and equal to -8')
+
+Ans=A-B;
+a=dec2bin(Ans)
+disp(a)
+disp('Since the MSB is 1 so the number is negative and equal to -40')
\ No newline at end of file diff --git a/1733/CH9/EX9.11/9_11.sce b/1733/CH9/EX9.11/9_11.sce new file mode 100755 index 000000000..57ee2fad2 --- /dev/null +++ b/1733/CH9/EX9.11/9_11.sce @@ -0,0 +1,16 @@ +//9.11
+clc;
+c=60;
+xc= bitcmp (c ,8);
+A=xc+1;
+d=28;
+xd= bitcmp (d ,8);
+B=xd+1;
+Ans=B+A;
+a=dec2bin(Ans)
+disp(a)
+disp('Since the MSB is 1 so the number is negative and equal to -88')
+Ans=B-A;
+a=dec2bin(Ans,8)
+disp(a)
+disp('Since the MSB is 0 so the number is positive and equal to +32')
\ No newline at end of file diff --git a/1733/CH9/EX9.12/9_12.sce b/1733/CH9/EX9.12/9_12.sce new file mode 100755 index 000000000..8bda2fe42 --- /dev/null +++ b/1733/CH9/EX9.12/9_12.sce @@ -0,0 +1,26 @@ +// 9.12
+clc;
+q =0;
+b =0;
+s =0;
+a =0.6875; // accepting the decimal input from user
+d = modulo (a ,1) ;
+a = floor ( a ) ;
+while (a >0)
+x = modulo (a ,2) ;
+b = b + (10^ q ) * x ;
+ a = a /2;
+ a = floor ( a ) ;
+ q = q +1;
+ end
+ for i =1:10
+ // for fractional part
+d = d *2;
+ q = floor ( d ) ;
+ s = s + q /(10^ i ) ;
+ if d >=1 then
+ d =d -1;
+ end
+end
+m=b+s;
+printf("Equivalent binary number=%.4f",m)
diff --git a/1733/CH9/EX9.13/9_13.sce b/1733/CH9/EX9.13/9_13.sce new file mode 100755 index 000000000..1246d90d2 --- /dev/null +++ b/1733/CH9/EX9.13/9_13.sce @@ -0,0 +1,26 @@ +// 9.13
+clc;
+q =0;
+b =0;
+s =0;
+a =0.634; // accepting the decimal input from user
+d = modulo (a ,1) ;
+a = floor ( a ) ;
+while (a >0)
+x = modulo (a ,2) ;
+b = b + (10^ q ) * x ;
+ a = a /2;
+ a = floor ( a ) ;
+ q = q +1;
+ end
+ for i =1:10
+ // for fractional part
+d = d *2;
+ q = floor ( d ) ;
+ s = s + q /(10^ i ) ;
+ if d >=1 then
+ d =d -1;
+ end
+end
+m=b+s;
+printf("Equivalent binary number=%.7f",m)
diff --git a/1733/CH9/EX9.14/9_14.sce b/1733/CH9/EX9.14/9_14.sce new file mode 100755 index 000000000..b3d27729d --- /dev/null +++ b/1733/CH9/EX9.14/9_14.sce @@ -0,0 +1,27 @@ +// 9.14
+clc;
+clear;
+q =0;
+b =0;
+s =0;
+a =39.12; // accepting the decimal input from user
+d = modulo (a ,1) ;
+a = floor ( a ) ;
+while (a >0)
+x = modulo (a ,2) ;
+b = b + (10^ q ) * x ;
+ a = a /2;
+ a = floor ( a ) ;
+ q = q +1;
+ end
+ for i =1:10
+ // for fractional part
+d = d *2;
+ q = floor ( d ) ;
+ s = s + q /(10^ i ) ;
+ if d >=1 then
+ d =d -1;
+ end
+end
+m=b+s;
+printf("Equivalent binary number=%.7f",m)
diff --git a/1733/CH9/EX9.15/9_15.sce b/1733/CH9/EX9.15/9_15.sce new file mode 100755 index 000000000..3bf47433b --- /dev/null +++ b/1733/CH9/EX9.15/9_15.sce @@ -0,0 +1,10 @@ +//9.15
+clc;
+a='1011010101';
+d=bin2dec(a);
+c='100011010';
+b=bin2dec(c);
+e=d+b;
+f=dec2bin(e);
+disp('addition of binary numbers =')
+disp(f)
\ No newline at end of file diff --git a/1733/CH9/EX9.16/9_16.sce b/1733/CH9/EX9.16/9_16.sce new file mode 100755 index 000000000..71c94eac5 --- /dev/null +++ b/1733/CH9/EX9.16/9_16.sce @@ -0,0 +1,38 @@ +//9.16
+clc;
+p =1;
+ q =1;
+ z =0;
+ b =0;
+ w =0;
+ f =0;
+bin =11001.001011; // binary input
+d = modulo (bin ,1) ;
+d= d *10^10;
+ a = floor ( bin ) ;
+ while (a >0)
+ r = modulo (a ,10) ;
+ b(1,q) = r ;
+ a=a /10;
+ a= floor ( a ) ;
+ q = q +1;
+ end
+ for m =1: q -1
+ c=m -1;
+ f=f+b(1,m) *(2^ c);
+ end
+ while (d >0)
+ e = modulo (d ,2)
+ w (1 , p ) = e
+ d = d /10;
+ d = floor ( d )
+ p = p +1;
+ end
+ for n =1: p -1
+ z = z + w (1 , n ) *(0.5) ^(11 - n ) ;
+ end
+ z = z *10000;
+ z = round ( z ) ;
+ z = z /10000;
+ x=f+z;
+ printf("Equivalent decimal number=%.6f",x)
\ No newline at end of file diff --git a/1733/CH9/EX9.17/9_17.sce b/1733/CH9/EX9.17/9_17.sce new file mode 100755 index 000000000..c1449b713 --- /dev/null +++ b/1733/CH9/EX9.17/9_17.sce @@ -0,0 +1,6 @@ +//9.17
+clc;
+a='8A3';
+disp('The decimal no. is')
+x=hex2dec(a);
+disp('',x)
diff --git a/1733/CH9/EX9.18/9_18.sce b/1733/CH9/EX9.18/9_18.sce new file mode 100755 index 000000000..4629b2d50 --- /dev/null +++ b/1733/CH9/EX9.18/9_18.sce @@ -0,0 +1,6 @@ +//9.18
+clc;
+a=268;
+disp('The hexa decimal no. is')
+x=dec2hex(a);
+disp('',x)
diff --git a/1733/CH9/EX9.19/9_19.sce b/1733/CH9/EX9.19/9_19.sce new file mode 100755 index 000000000..6e8883b52 --- /dev/null +++ b/1733/CH9/EX9.19/9_19.sce @@ -0,0 +1,6 @@ +//9.19
+clc;
+a=5741;
+disp('The hexa decimal no. is')
+x=dec2hex(a);
+disp('',x)
diff --git a/1733/CH9/EX9.2/9_2.sce b/1733/CH9/EX9.2/9_2.sce new file mode 100755 index 000000000..dbe96a851 --- /dev/null +++ b/1733/CH9/EX9.2/9_2.sce @@ -0,0 +1,6 @@ +//9.2
+clc;
+x=25;
+disp('The binary number is')
+a=dec2bin(x);
+disp('',a)
\ No newline at end of file diff --git a/1733/CH9/EX9.20/9_20.sce b/1733/CH9/EX9.20/9_20.sce new file mode 100755 index 000000000..85d004c43 --- /dev/null +++ b/1733/CH9/EX9.20/9_20.sce @@ -0,0 +1,6 @@ +//9.20
+clc;
+a='D70';
+disp('The decimal no. is')
+x=hex2dec(a);
+disp('',x)
diff --git a/1733/CH9/EX9.3/9_3.sce b/1733/CH9/EX9.3/9_3.sce new file mode 100755 index 000000000..07a7638b6 --- /dev/null +++ b/1733/CH9/EX9.3/9_3.sce @@ -0,0 +1,6 @@ +//9.3
+clc;
+a='101110';
+disp('The decimal no. is')
+x=bin2dec(a);
+disp('',x)
diff --git a/1733/CH9/EX9.4/9_4.sce b/1733/CH9/EX9.4/9_4.sce new file mode 100755 index 000000000..38ad63aa7 --- /dev/null +++ b/1733/CH9/EX9.4/9_4.sce @@ -0,0 +1,10 @@ +//9.4
+clc;
+x=15;
+disp('The binary number of decimal 15 is')
+a=dec2bin(x);
+disp('',a)
+x=31;
+disp('The binary number of decimal 31 is')
+a=dec2bin(x);
+disp('',a)
\ No newline at end of file diff --git a/1733/CH9/EX9.5/9_5.sci b/1733/CH9/EX9.5/9_5.sci new file mode 100755 index 000000000..6fcb642c2 --- /dev/null +++ b/1733/CH9/EX9.5/9_5.sci @@ -0,0 +1,11 @@ +//9.5
+clc;
+a='11001';
+b=bin2dec(a);
+c='10001';
+f=bin2dec(c);
+d=b-f;
+s=dec2bin(d);
+disp('Subtraction of two binary numbers=')
+disp(s)
+
diff --git a/1733/CH9/EX9.6/9_6.sci b/1733/CH9/EX9.6/9_6.sci new file mode 100755 index 000000000..4d90c1e5a --- /dev/null +++ b/1733/CH9/EX9.6/9_6.sci @@ -0,0 +1,11 @@ +//9.6
+clc;
+a='1010';
+b=bin2dec(a);
+c='0111';
+f=bin2dec(c);
+d=b-f;
+s=dec2bin(d);
+disp('Subtraction of two binary numbers=')
+disp(s)
+
diff --git a/1733/CH9/EX9.7/9_7.sce b/1733/CH9/EX9.7/9_7.sce new file mode 100755 index 000000000..65ffc5b89 --- /dev/null +++ b/1733/CH9/EX9.7/9_7.sce @@ -0,0 +1,12 @@ +//9.7
+clc;
+a=8;
+b=dec2bin(a);
+disp(b)
+disp('The 16 bit signed binary number of +8=0000 0000 0000 1000')
+disp('The 16 bit signed binary number of -8=1000 0000 0000 1000')
+a=165;
+b=dec2bin(a);
+disp(b)
+disp('The 16 bit signed binary number of +165=0000 0000 1010 0101')
+disp('The 16 bit signed binary number of -165=1000 0000 1010 0101')
diff --git a/1733/CH9/EX9.8/9_8.sce b/1733/CH9/EX9.8/9_8.sce new file mode 100755 index 000000000..2f01e1cbf --- /dev/null +++ b/1733/CH9/EX9.8/9_8.sce @@ -0,0 +1,21 @@ +//9.8
+clc;
+a='0001 1111';
+disp(a)
+disp('Since the MSB is 0 so this is a positive number and its 2 s complement representation is')
+b=bin2dec(a);
+disp(b)
+a='1110 0101';
+disp(a)
+disp('Since the MSB is 1 so this is a negative number and its 2 s complement representation is')
+c=bin2dec(a);
+xc= bitcmp (c ,8);
+b=xc+1;
+disp(b)
+a='1111 0111';
+disp(a)
+disp('Since the MSB is 1 so this is a negative number and its 2 s complement representation is')
+c=bin2dec(a);
+xc= bitcmp (c ,8);
+b=xc+1;
+disp(b)
\ No newline at end of file diff --git a/1733/CH9/EX9.9/9_9.sce b/1733/CH9/EX9.9/9_9.sce new file mode 100755 index 000000000..956646f9e --- /dev/null +++ b/1733/CH9/EX9.9/9_9.sce @@ -0,0 +1,8 @@ +//9.9
+clc;
+disp('The largest 8 bit positive number is +127 and is represented in binary as')
+a='0111 1111';
+disp(a)
+disp('The largest 8 bit negative number is -128 and is represented in binary as')
+a='1000 0000';
+disp(a)
|