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 /462/CH2/EX2.6.a | |
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 '462/CH2/EX2.6.a')
-rwxr-xr-x | 462/CH2/EX2.6.a/ex_2_6_a.pdf | bin | 0 -> 39550 bytes | |||
-rwxr-xr-x | 462/CH2/EX2.6.a/ex_2_6_a.sce | 36 |
2 files changed, 36 insertions, 0 deletions
diff --git a/462/CH2/EX2.6.a/ex_2_6_a.pdf b/462/CH2/EX2.6.a/ex_2_6_a.pdf Binary files differnew file mode 100755 index 000000000..3cde5e471 --- /dev/null +++ b/462/CH2/EX2.6.a/ex_2_6_a.pdf diff --git a/462/CH2/EX2.6.a/ex_2_6_a.sce b/462/CH2/EX2.6.a/ex_2_6_a.sce new file mode 100755 index 000000000..67ae4f722 --- /dev/null +++ b/462/CH2/EX2.6.a/ex_2_6_a.sce @@ -0,0 +1,36 @@ +//example 2.6(a)//
+clc
+//clears the command window//
+clear
+//clears all the variables//
+q =0;
+b =0;
+s =0;
+//a=input(”Enter the decimal no to be converted to its binary equivalent: ”) ;
+//accepting the decimal input from user//
+a =25.5;
+d = modulo (a ,1) ;
+//separating the decimal part and the integer part//
+a = floor ( a ) ;
+//removing the decimal part//
+while (a >0)
+//taking integer part into a matrix and convert to equivalent binary//
+x = modulo (a ,2) ;
+b = b + (10^ q ) * x ;
+a = a /2;
+a = floor ( a ) ;
+q = q +1;
+end
+for i =1:10
+//For values after decimal point converting to binary//
+d = d *2;
+q = floor ( d ) ;
+s = s + q /(10^ i ) ;
+ if d >=1 then
+ d =d -1;
+ end
+end
+k=b+s;
+disp('The binary equivalent of the given decimal number is =');
+disp(k);
+//displaying the final result//
\ No newline at end of file |