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/EX7.2 | |
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/EX7.2')
-rwxr-xr-x | 887/CH7/EX7.2/7_2.sce | 19 |
1 files changed, 19 insertions, 0 deletions
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')
|