summaryrefslogtreecommitdiff
path: root/1241/CH2/EX2.37/exa2_37.sce
blob: aa04e69b30889f9fedbe3cc2890b4d507bdec021 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//Example 2-37//
// negative decimal representation of 10011011//
clc
//clears the window//
clear
//clears all existing variables//
b=bin2dec('10011011')
x=bitcmp(b,8)
//complement of the decimal number 17(8 bit representation)//
y=1
z=x+y
//1 is added to the complement//
a=dec2bin(z)
//binary conversion of the decimal number//
z=z*(-1)
disp(' the negative value that 10011011 represents is: ')
disp(z)
//result is displayed//