summaryrefslogtreecommitdiff
path: root/1733/CH9/EX9.14
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.14
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.14')
-rwxr-xr-x1733/CH9/EX9.14/9_14.sce27
1 files changed, 27 insertions, 0 deletions
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)