summaryrefslogtreecommitdiff
path: root/462/CH2/EX2.36.a/ex_2_36_a.sce
blob: 6a6bb7cfcc6f2e24c6c0677476007f3b2f8b0d7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//example 2.36(a)//
//subtraction of hexadecimal number//
clc
//clears the screen//
clear
//clears already existing variables//
x=hex2dec('3F')
//hexadecimal to deciimal conversion//
y=hex2dec('5C')
z=x-y
//subtraction//
t=z*-1
t1=dec2hex(t)
//answer in hexadecimal form(modulus)//
t2=bitcmp(t,8)
//complement//
t3=t2+1
//2's complement//
a=dec2bin(t3)
//answer in 2's complement form
disp('result of subtraction in 2''s compliment form is:')
disp(a)