i am trying to implement the 8-bit fletcher algorithm. I wrote a piece of code that does that but i am not sure if i understood the algorithm correctly. this is my piece of code:
public class TestFletcher {
public static void main(String[] argv) {
String bin = "10010010101111101110101101110011";
char[] cA = bin.toCharArray();
int ckA = 0, ckB = 0;
for (int i = 0; i < cA.length; i++){
ckA += Integer.valueOf(cA[i])/49;
ckB += ckA;
}
System.out.println(ckA);
System.out.println(ckB);
}
the results that i am getting are : ckA = 20, ckB = 308. i assume this is not the correct implementation since 308 can not be represented by an 8bit binary which is the length of ckA and ckB.
can any one shed some light on this problem? any help would be appreciated. thank you.