Skip to content

Instantly share code, notes, and snippets.

@zhenlinyang
Created August 9, 2016 01:49
Show Gist options
  • Save zhenlinyang/3a105ba91b0d6c9e436b2c3013502ccc to your computer and use it in GitHub Desktop.
Save zhenlinyang/3a105ba91b0d6c9e436b2c3013502ccc to your computer and use it in GitHub Desktop.
Data Matrix Rotating
/// <summary>
/// Data Matrix Rotating
/// </summary>
/// <param name="number">Original Data</param>
/// <returns>Four directions of the number, the original data in the final.</returns>
public static ulong[] GetRotatedNumbers(ulong number)
{
ulong[] ulongs = new ulong[4];
ulongs[3] = number;
for (int t = 0; t < 3; ++t)
{
ulong nu = 0;
for (int i = 0; i < 8; ++i)
{
for (int j = 0; j < 8; ++j)
{
int len = (i * 8 + j);
nu |= ((number & (1UL << len)) >> len) << (j * 8 + 7 - i);
}
}
ulongs[t] = nu;
number = nu;
}
return ulongs;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment