summaryrefslogtreecommitdiff
path: root/462/CH6/EX6.5.b.i
diff options
context:
space:
mode:
authorpriyanka2015-06-24 15:03:17 +0530
committerpriyanka2015-06-24 15:03:17 +0530
commitb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch)
treeab291cffc65280e58ac82470ba63fbcca7805165 /462/CH6/EX6.5.b.i
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 '462/CH6/EX6.5.b.i')
-rwxr-xr-x462/CH6/EX6.5.b.i/ex_6_5_b_i.pdfbin0 -> 87961 bytes
-rwxr-xr-x462/CH6/EX6.5.b.i/ex_6_5_b_i.sce59
2 files changed, 59 insertions, 0 deletions
diff --git a/462/CH6/EX6.5.b.i/ex_6_5_b_i.pdf b/462/CH6/EX6.5.b.i/ex_6_5_b_i.pdf
new file mode 100755
index 000000000..e66e1692f
--- /dev/null
+++ b/462/CH6/EX6.5.b.i/ex_6_5_b_i.pdf
Binary files differ
diff --git a/462/CH6/EX6.5.b.i/ex_6_5_b_i.sce b/462/CH6/EX6.5.b.i/ex_6_5_b_i.sce
new file mode 100755
index 000000000..36d63df25
--- /dev/null
+++ b/462/CH6/EX6.5.b.i/ex_6_5_b_i.sce
@@ -0,0 +1,59 @@
+// exmple 6.5(b)(i)
+clc ;
+clear ;
+// a=input (”enter the first 8 bit number :”) ;
+// b=input (”enter the second 8 bit number : ” ) ;
+ a =00011000 ;
+//taking given inputs//
+ b =00111010 ;
+ for i =1:8
+ a1 ( i ) = modulo (a ,10) ;
+ a = a /10;
+ a = round ( a ) ;
+ b1 ( i ) = modulo (b ,10) ;
+ b = b /10;
+ b = round ( b ) ;
+ end
+ car (1) =0;
+ for i =1:8
+//adding both the inputs (binary addition)//
+c1 ( i ) = car ( i ) + a1 ( i ) + b1 ( i ) ;
+if c1 ( i ) == 2 then
+car ( i +1) = 1;
+
+ c1 ( i ) =0;
+elseif c1 ( i ) ==3 then
+ car ( i +1) = 1;
+ c1 ( i ) =1;
+else
+ car ( i +1) =0;
+end
+end
+c1 (9) = car (9) ;
+re =0;
+format ( 'v' ,18) ;
+for i =1:9
+ re = re +( c1 ( i ) *(10^( i -1) ) )
+end
+printf ( ' The sum of given two binary numbers is %d\n ', re ) ;
+q =1;
+b =0;
+f =0;
+a = re ;
+while (a >0)
+//converting the result to a hexadecimal no//
+ r = modulo (a ,10) ;
+ b (1 , q ) = r ;
+ a = a /10;
+ a = floor ( a ) ;
+ q = q +1;
+end
+for m =1: q -1
+ c =m -1;
+ f = f + b (1 , m ) *(2^ c ) ;
+end
+hex = dec2hex ( f ) ;
+printf ('The sum in hexadecimal notation is %s \n' ,hex ) ;
+disp('the sum in decimal form is:')
+disp(f)
+//displaying result// \ No newline at end of file