I converted the C code below, but I'm not sure if it's totally accurate. Can anyone see if I erred somewhere?
C code
My conversion
C code
Code:
char * OutBits; int OutCount; char * InBits ; /* Process input stream to yield output bits and two additional biased streams */ void amls_round( int start, int end) { if (start >= end ) return ; int doubles = start; int IndexLow = start; int IndexHigh = end; do{ if (InBits[IndexLow] == InBits[IndexHigh]) { InBits[doubles++] = InBits[IndexLow]; InBits[IndexHigh] = '0'; }else{ OutBits[OutCount++] = InBits[IndexLow]; InBits[IndexHigh] = '1'; } IndexHigh--; IndexLow++; }while (IndexHigh>IndexLow); /* Process the two derived streams */ /* Remove both recursive calls to implement Von Neuman algorithm.*/ /* Remove second recursive call to implement unadvanced MLS */ amls_round(start,--doubles); amls_round(++IndexHigh,end); return ; }
My conversion
Code:
GLOBAL OutBits() AS BYTE GLOBAL OutCount AS LONG GLOBAL InBits() AS BYTE '/* Process input stream to yield output bits and two additional biased streams */ FUNCTION amls_round(start AS LONG, finish AS LONG) AS LONG IF start >= finish THEN EXIT FUNCTION LOCAL doubles, IndexLow, IndexHigh AS LONG doubles = start IndexLow = start IndexHigh = finish DO IF InBits(IndexLow) = InBits(IndexHigh) THEN InBits(doubles) = InBits(IndexLow) INCR doubles InBits(IndexHigh) = 48 ELSE OutBits(OutCount) = InBits(IndexLow) INCR OutCount InBits(IndexHigh) = 49 END IF DECR IndexHigh INCR IndexLow LOOP WHILE IndexHigh > IndexLow '/* Process the two derived streams */ '/* Remove both recursive calls to implement Von Neuman algorithm.*/ '/* Remove second recursive call to implement unadvanced MLS */ DECR doubles amls_round(start, doubles) INCR IndexHigh amls_round(IndexHigh, finish) END FUNCTION
Comment