comparehash

A bitwise XOR of two big Integers. Returns the difference in percent.
/* MYSQL QUERY */ SELECT ((64 - bit_count(hash1 ^ hash2))*100.0/64); /* MYSQL Function */ DELIMITER $$ DROP FUNCTION IF EXISTS comparehash $$ CREATE FUNCTION comparehash (hash1 bigint, hash2 bigint) RETURNS float DETERMINISTIC BEGIN RETURN ((64 - bit_count(hash1 ^ hash2))*100.0/64); END $$ DELIMITER ;

Url: http://www.medienservice-ladewig.de/MYSQL-Hamming-Distance.2099932101.html

Language: SQL | User: Jörg | Created: Oct 21, 2013 | Tags: mysql bitwise xor function