Forum Moderators: coopster

Message Too Old, No Replies

Binary math and CRC32

Fun binary math / getting a CRC8

         

suidas

6:06 pm on Feb 1, 2006 (gmt 0)

10+ Year Member



Does anyone know how to get a CRC8 out of PHP?

As I understand it a CRC8 has 4,294,967,296 possible answers. A CRC8 would have 256.

Related question:

I posted a message on the database board ( [webmasterworld.com...] ) about fun binary math in MySQL. The question is, if you have a site like last.fm, can you use binary sets to discover how users' band preferences inter-relate.

For example:
Jim likes 10010110
Jill likes 11010000
Bob likes 01000001

Ergo, Jim and Jill share bands one and four. Jim and Bob share no bands, and Bob and Jill share one.

Since this is a PHP question too, any ideas?

Echilon

6:53 pm on Feb 1, 2006 (gmt 0)

10+ Year Member



My guess would be you'd have to explode it into an array,
$jil = explode("",$jilstring);
foreach($jil as $num=>$val) {
if($jil[$num] == $bob[$num])
}
Although you'd nee another loop in there somewhere. It would be a load easier if you could set preset choices. Then you could just query the DB for the right results.

Moosetick

2:56 pm on Feb 2, 2006 (gmt 0)

10+ Year Member



Why not save the binary digits into 8 different columns. Then you can let MySQL do the heavy lifting?