VCR+ coding› -----------››The HA3 routine is used in DECODING›values as follows.››From a newspaper VCR+ code, we run›through HASH1 to get the corrected›VCR+ code (we also know the month and›year). Let›TOP=INT(corrected code/1000) and›BOT=corr.code-1000*TOP (the bottom›three digits and the TOP digits)››LET Q=INT((BOT-1)/32),›REM=BOT-1-32*Q=(BOT-1) MOD32››(Q and REM are the quotient and›remainder of the bottom.value -1›mod 32, that is we write BOT as a two›digit number in base 32).››and set DAY:=Q+1››Set TOP=d2,d1,d0 (DIGITS IN BASE TEN)›and set P as follows:›› if d2=d1=d0=0 then HASH3=0 and›OFF=0›› if d2=d1=0<>d0, P=d0, D=1›› if d2=0<>d1, P=d0*x+d1, D=2›› if d2<>0, P=d0*x^2+d1*x+d2, D=3››(note that the order of the›coefficients is in the OPPOSITE order›to the digits in TOP, this is why we›check H(0) and P(0) as not being zero›rather than checking that H and P›have the same degree: they may›NOT!... note that as d0 may be zero,›D is NOT the degree of P plus 1! ...››If P'=d0+d1*x+...+d(D-1)*x^(D-1), the›polynomial with the order of›coefficients reversed, then›D=deg(P')+1 and P=x^(D-1)*P'(1/x))››Take YEAR=(year MOD 100) MOD 16››(you MUST do that in the right›order!)››Put H=HASH3(P,DAT,YEAR) and calculate›OFF››If H(x)=h0*x^(D-1)+...+h(D-1) (where›h(D-1)<>0) then let›A=h(D-1)*10^(D-1)+...+h(0) (NOTE that›since the order is reversed and›h(D-1)<>0, from A we can determine H›and D!, though we may have deg(H)a0, H=a0, D=1› if a2=0<>a1, H=a0*x+a1, D=2› if a2<>0, H=a0*x^2+a1*x+a2, D=3››If H=0 then P=0››Otherwise use the HA3I routine above›to get P››(P=HA3I(H): if P(0)=0 then›P=HA3I(P))››Now that we have P, we can calculate›OFF (we know the DAY, MONTH and year,›and again we set›YEAR=(year MOD 100) MOD 16) and›Q=DAY-1››We have B so take››REM=(B-DAY*(MONTH+1)-OFF)MOD[32]››and set BOT=1+REM+32*Q››We have P and D and thus we have TOP›(if P=p0*x^(D-1)+..+p(D-1), then›TOP=p(D-1)*10^(D-1)+...+p(0))››We have the corrected VCR+ code of›1000*TOP+BOT and use HASH1I (in the›opposite direction as for decoding)›to get the newspaper version of the›VCR+ code!›