summaryrefslogtreecommitdiff
path: root/3860/CH1/EX1.21/Ex1_21.sce
blob: f07a47cc568d1e69faa0171aa4967f97d242016b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//Example 1.21: Overflow for unsigned numbers in Example 1.21(a) and for signed numbers in Example 1.21(b)
clc;
disp('Example 1.21(a)')
x=bitcmp(7,4) //finds complement of 5
y=1;
u=x+y //1 is added to the complement
w=5
z=w+u;
r = dec2bin(z); // binary equivalent of decimal number
disp('The binary number is = ');
disp(r) 
disp('Example 1.21(b)')
x=7
y=5;
u=x+y //1 is added to the complement
r = dec2bin(u); // binary equivalent of decimal number
disp('The binary number is = ');
disp(r)