An Algorithm for Error Detection

9.8 An Algorithm for Error Detection
9.8.1 When implementing error detection, it is convenient to imagine a checksum for each individual character
position. This partial checksum forms a check on all preceding characters, as well as the present character. Then
using Horner’s Rule, one can calculate a running checksum (that is, calculate each partial checksum in order). This
leads to the following algorithm.
9.8.2 Add the checksum (or the previous character position to itself (for the first character position, the value of the
previous checksum is zero). If the result is 59 or greater, subtract 59. This leaves a value in the range 0–58.
9.8.3 Add the result of step 1 to itself. If the result is 59 or greater, subtract 59.
9.8.4 Add the result of step 2 to itself. If the result is 59 or greater, subtract 59. The result of this step is eight times
the previous position checksum, modulo 59.
9.8.5 Add the result of step 3 to the numerical value of the character in the present position. If the result is 59 or
greater, subtract 59. The result of this step is the checksum for the present character position.
9.8.6 Repeat steps 1 through 4 for each character position. If the checksum for the final character position is
nonzero, an error has occurred.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值