summaryrefslogtreecommitdiff
path: root/1733/CH9/EX9.12/9_12.sce
diff options
context:
space:
mode:
authorpriyanka2015-06-24 15:03:17 +0530
committerpriyanka2015-06-24 15:03:17 +0530
commitb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch)
treeab291cffc65280e58ac82470ba63fbcca7805165 /1733/CH9/EX9.12/9_12.sce
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 '1733/CH9/EX9.12/9_12.sce')
-rwxr-xr-x1733/CH9/EX9.12/9_12.sce26
1 files changed, 26 insertions, 0 deletions
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)