hamming code

can someone provide me the code for hammingcode.?thanks
[62 byte] By [lrngjavaa] at [2007-11-26 20:03:35]
# 1
http://www.rentacoder.com/
CeciNEstPasUnProgrammeura at 2007-7-9 23:03:24 > top of Java-index,Java Essentials,New To Java...
# 2
> http://www.rentacoder.com/all i have is dukes nothing else. i am broke. plz help.
lrngjavaa at 2007-7-9 23:03:25 > top of Java-index,Java Essentials,New To Java...
# 3

@OP

http://tams-www.informatik.uni-hamburg.de/applets/hades/webdemos/10-gates/50-hamming/hamming.html

http://www.frontiernet.net/~prof_tcarr/Hamming/

http://math.arizona.edu/~ura/043/Patterson.Genevieve/Final/FinalReportSummer2004/node14.html

http://www.cs.utsa.edu/~wagner/laws/hamming.html

http://galeb.etf.bg.ac.yu/~prvul/Comm/Code.java

here are few links which specifies Hamming Code Simulation / Implementation Using JAVA...

Hop this might be of some help...:)

REGARDS,

RaHuL

RahulSharnaa at 2007-7-9 23:03:25 > top of Java-index,Java Essentials,New To Java...
# 4

try to first learn how hammingcode works. Rahul provided some useful Url. Try to learn some from my code and see if you can write your own hammingcode. if you need help or if you get stuck please post back.

public class printBits2{

public static void main( String args[] ){

printBits2 pb = new printBits2( args[ 0 ] );

}

public printBits2( String message ){

//System.out.print( message + "\n\n" );

char chA[] = new char[ message.length() ];

chA = message.toCharArray();

System.out.print( chA[ 0 ] + " -> is your input char\n" );

printCharBits( chA[ 0 ] );

System.out.print( " -> is what computer sees\n\n" );

toHamming( chA[ 0 ] );

}

private void toHamming( char c ){

char displayMask = 1 << 0;

char n[]; n = new char[ 4 ]; n[ 0 ] = 91; n[ 1 ] = 109; n[ 2 ] = 7; n[ 3 ] = 7;

int j = 0;

boolean b = true;

char HC = 0 << 15;

for( int i = 16; i > 5; i-- ){

if( 16 % ( 17 - i ) == 0 ){

//insert the appropriate parity bits

n[ j ] = (char) ( c & n[ j ] );

for( int k = 0; k < 7; k++ ){

if( (int) ( n[ j ] & displayMask ) == 1 ){ b = !b; }

n[ j ] >>=1;

}

if( ! b ){

int helpMask = 1 << (int) ( Math.pow( 2, j ) - 1 );

HC = (char) ( helpMask | (int) HC );

}

j++;

b = true;

}

else{

if( ( c & displayMask ) == displayMask ){

int helpMask = 1 << ( 16 - i );

HC = (char) ( helpMask | (int) HC );

}

c >>=1;

}

}

printCharBits( HC ); System.out.print( " -> hamming code computer sees\n\n" );

}

private void printCharBits( char c ){

char displayMask = 1 << 15;

for ( int bit = 1; bit < 17; bit++ ){

if( ( c & displayMask ) == 0 ){

System.out.print( "0" );

if( bit % 8 == 0 ){ System.out.print( " " ); }

}

else{

System.out.print( "1" );

if( bit % 8 == 0 ){ System.out.print( " " ); }

}

c <<= 1;

}

}

}

fastmikea at 2007-7-9 23:03:25 > top of Java-index,Java Essentials,New To Java...
# 5
Thanks rahul and fast mike.
lrngjavaa at 2007-7-9 23:03:25 > top of Java-index,Java Essentials,New To Java...