diff options
Diffstat (limited to '3544/CH4/EX4.17')
-rw-r--r-- | 3544/CH4/EX4.17/Ex4_17.sce | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/3544/CH4/EX4.17/Ex4_17.sce b/3544/CH4/EX4.17/Ex4_17.sce new file mode 100644 index 000000000..d11259888 --- /dev/null +++ b/3544/CH4/EX4.17/Ex4_17.sce @@ -0,0 +1,25 @@ + +//Longitudinal redundancy check + +data = [ "11100100","11011101","00111001","00101001" ] +disp("Original data") +disp(data) +data = bin2dec(data) + +lrc = 0. + +for i=1:length(data) + lrc = bitxor(lrc,data(i)) +end + +disp("LRC: ") + +for i=1:7 + if lrc<(2^(8-i)) then + printf("0") + else + printf("%s",dec2bin(lrc)) + break + end +end + |