summaryrefslogtreecommitdiff
path: root/1241/CH2/EX2.38
diff options
context:
space:
mode:
Diffstat (limited to '1241/CH2/EX2.38')
-rwxr-xr-x1241/CH2/EX2.38/exa2_38.sce23
1 files changed, 23 insertions, 0 deletions
diff --git a/1241/CH2/EX2.38/exa2_38.sce b/1241/CH2/EX2.38/exa2_38.sce
new file mode 100755
index 000000000..b9dfdd3ef
--- /dev/null
+++ b/1241/CH2/EX2.38/exa2_38.sce
@@ -0,0 +1,23 @@
+//Example 2-38//
+//add -17 to -30//
+clc
+//clears the console//
+clear
+//clears all exisiting variables//
+x=bitcmp(17,8)
+y=bitcmp(30,8)
+//complement of the decimal numbers 17 and 30//
+z=1
+u=x+z
+v=y+z
+//1 is added to the complements//
+w=u+v
+a=dec2bin(w)
+//binary conversion of the decimal number//
+disp('binary form of number obtained by adding -17 to -30')
+disp(a)
+//result is displayed//
+disp(' the msb is discarded,so eight bit representation is the answer in binary form ')
+a=dec2bin(w-(2^8))
+disp(a)
+//final result is displayed//