summaryrefslogtreecommitdiff
path: root/1964/CH15/EX15.7
diff options
context:
space:
mode:
authorpriyanka2015-06-24 15:03:17 +0530
committerpriyanka2015-06-24 15:03:17 +0530
commitb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch)
treeab291cffc65280e58ac82470ba63fbcca7805165 /1964/CH15/EX15.7
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 '1964/CH15/EX15.7')
-rwxr-xr-x1964/CH15/EX15.7/ex15_7.sce25
1 files changed, 25 insertions, 0 deletions
diff --git a/1964/CH15/EX15.7/ex15_7.sce b/1964/CH15/EX15.7/ex15_7.sce
new file mode 100755
index 000000000..2639010fc
--- /dev/null
+++ b/1964/CH15/EX15.7/ex15_7.sce
@@ -0,0 +1,25 @@
+//Chapter-15, Example 15.7, Page 497
+//=============================================================================
+clc
+clear
+//CALCULATIONS
+//using 1's complement method
+x1=base2dec(['1111'],2)//converting binary to decimal
+x=bin2dec('1010')
+x2=dec2bin(bitcmp(x,4))//1's complement of a number
+disp(x2)
+x3=base2dec([x2],2)
+x4=x1+x3;
+x5=dec2base(x4,2)//converting decimal to hexadecimal
+disp(x5)
+y=15;
+z=bitand(x4,y);//eliminating carry
+z1=bitset(z,1);//setting 1st bit t0 1
+z2=dec2base(z1,2)//converting decimal to binary
+disp(z2)
+//using normal method
+a=base2dec(['1111','1010'],2);//converting binary to decimal
+b=a(1)-a(2);//subtraction
+c=dec2base(b,2)//converting decimal to binary
+disp(c)
+//=================================END OF PROGRAM=======================================================================================================