Skip to content

Instantly share code, notes, and snippets.

@zhenlinyang
Created August 9, 2016 01:44
Show Gist options
  • Save zhenlinyang/2fab34b8520b2996fedd89fc5be7c2ec to your computer and use it in GitHub Desktop.
Save zhenlinyang/2fab34b8520b2996fedd89fc5be7c2ec to your computer and use it in GitHub Desktop.
Data Matrix Matching Check
/// <summary>
/// Data Matrix Matching Check
/// </summary>
/// <param name="u1"></param>
/// <param name="u2"></param>
/// <param name="num">Maxdiff</param>
public static bool Match(ulong u1, ulong u2, byte num)
{
for (u1 ^= u2; 0 != u1 && 0 != num; num--)
{
u1 &= (u1 - 1);
}
return 0 == u1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment