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 /887/CH7 | |
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 '887/CH7')
-rwxr-xr-x | 887/CH7/EX7.1/7_1.sce | 5 | ||||
-rwxr-xr-x | 887/CH7/EX7.2/7_2.sce | 19 | ||||
-rwxr-xr-x | 887/CH7/EX7.3/7_3.sce | 9 | ||||
-rwxr-xr-x | 887/CH7/EX7.4/7_4.sce | 6 | ||||
-rwxr-xr-x | 887/CH7/EX7.5/7_5.sce | 10 | ||||
-rwxr-xr-x | 887/CH7/EX7.6/7_6.sce | 9 |
6 files changed, 58 insertions, 0 deletions
diff --git a/887/CH7/EX7.1/7_1.sce b/887/CH7/EX7.1/7_1.sce new file mode 100755 index 000000000..17e0c0842 --- /dev/null +++ b/887/CH7/EX7.1/7_1.sce @@ -0,0 +1,5 @@ +clc
+//ex7.1
+N=343; //decimal integer
+N2=dec2bin(N); //binary equivalent of N
+disp(N2,'Binary equivalent of 343 is')
diff --git a/887/CH7/EX7.2/7_2.sce b/887/CH7/EX7.2/7_2.sce new file mode 100755 index 000000000..e2bf5bfe9 --- /dev/null +++ b/887/CH7/EX7.2/7_2.sce @@ -0,0 +1,19 @@ +clc
+//ex7.2
+N=0.392; //decimal
+DP=N; //decimal part(no integer part)
+i=1;
+x=1;
+//Each decimal digit is stored in D(x)
+while (x<=9)
+DP=DP*2;
+D(x)= floor (DP);
+x=x+1;
+DP= modulo (DP ,1);
+end
+DP=0;
+for j=1: length (D)
+//bits of decimal part are multiplied with their position values and adding them
+ DP=DP+(10^(-1*j)*D(j));
+end
+disp(DP,'Binary form of 0.392 is')
diff --git a/887/CH7/EX7.3/7_3.sce b/887/CH7/EX7.3/7_3.sce new file mode 100755 index 000000000..b56e34b69 --- /dev/null +++ b/887/CH7/EX7.3/7_3.sce @@ -0,0 +1,9 @@ +clc
+//ex7.3
+N=343.392;
+//convert the integer and decimal parts into binary form separately
+B_1='101010111'; //for 343 from ex7.1
+B_2='0.011001'; //for 0.392 from ex7.2
+//combining these two
+B='101010111.011001'; //for N, given number
+disp(B,'binary form of 343.392')
diff --git a/887/CH7/EX7.4/7_4.sce b/887/CH7/EX7.4/7_4.sce new file mode 100755 index 000000000..42bad2413 --- /dev/null +++ b/887/CH7/EX7.4/7_4.sce @@ -0,0 +1,6 @@ +//ex7.4
+N_1=1000.111;
+N_2=1100.011;
+//Adding these two according to the rules of binary addition in fig7.6, we get
+disp("The result of addition of given two binary numbers is")
+disp("10101.010")
diff --git a/887/CH7/EX7.5/7_5.sce b/887/CH7/EX7.5/7_5.sce new file mode 100755 index 000000000..612d8d5b1 --- /dev/null +++ b/887/CH7/EX7.5/7_5.sce @@ -0,0 +1,10 @@ +clc
+//ex7.5
+//Given 317.2 (octal)and F3A.2 (hexadecimal)
+//From table 7.1 in text, corresponding octal forms of 3,1,7 and 2 are 011,001,111 and 010
+disp('The binary representation of 317.2(octal) is ')
+disp('011001111.010')
+disp('')
+//From table 7.1 in text, corresponding hexadecimal forms of F,3,A and 2 are 1111,0011,1010 and 0010
+disp('The binary representation of F3A.2(hexadecimal) is ')
+disp('111100111010.0010')
diff --git a/887/CH7/EX7.6/7_6.sce b/887/CH7/EX7.6/7_6.sce new file mode 100755 index 000000000..a8b246f72 --- /dev/null +++ b/887/CH7/EX7.6/7_6.sce @@ -0,0 +1,9 @@ +clc
+//ex7.6
+//Given 11110110.1(binary)
+//Working outward from the binary point, we form three-bit groups ==> 11110110.1=011 110 110. 100(we have appended leading and trailing zeros so that each group contains 3 bits)
+//And the corresponding numbers for 011,110,110 and 100 in octal system are 3,6,6 and 4
+disp('The octal representation of 11110110.1(binary) is 366.4')
+//Now we form four-bit groups appending leading and trailing zeros as needed ==> 11110110.1=1111 0110. 1000
+//The corresponding numbers for 1111,0110 and 1000 in hexadecimal system are F,6 and 8
+disp('The hexadecimal representation of 11110110.1(binary) is F6.8')
|