summaryrefslogtreecommitdiff
path: root/275/CH8/EX8.8.30b
diff options
context:
space:
mode:
authorpriyanka2015-06-24 15:03:17 +0530
committerpriyanka2015-06-24 15:03:17 +0530
commitb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch)
treeab291cffc65280e58ac82470ba63fbcca7805165 /275/CH8/EX8.8.30b
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 '275/CH8/EX8.8.30b')
-rwxr-xr-x275/CH8/EX8.8.30b/Ch8_8_30b.sce31
1 files changed, 31 insertions, 0 deletions
diff --git a/275/CH8/EX8.8.30b/Ch8_8_30b.sce b/275/CH8/EX8.8.30b/Ch8_8_30b.sce
new file mode 100755
index 000000000..73020d16a
--- /dev/null
+++ b/275/CH8/EX8.8.30b/Ch8_8_30b.sce
@@ -0,0 +1,31 @@
+clc
+clear
+disp("Example 8.30b")
+printf("\n")
+disp("perform the following decimal subtraction using 10s complements")
+disp("a)49-24 b)321-578")
+//given numbers
+a=49
+b=-24
+//should set to 100 if input is 2 digit number,1000 if 3digit number
+c=1000
+//add c with 2nd operand
+e=c+b
+N=a+e
+if(N>100)
+ if(N<199)
+ M=N-100
+ N=M
+end
+end
+if(N>1000)
+ if(N<1999)
+ M=N-1000
+ N=M
+end
+end
+ M=N
+if(-b>a)
+ M=-(999-M+1)
+end
+printf("result=%d",M)