From b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b Mon Sep 17 00:00:00 2001 From: priyanka Date: Wed, 24 Jun 2015 15:03:17 +0530 Subject: initial commit / add all books --- 1733/CH9/EX9.12/9_12.sce | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 1733/CH9/EX9.12/9_12.sce (limited to '1733/CH9/EX9.12/9_12.sce') 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) -- cgit