Created
August 9, 2016 01:49
-
-
Save zhenlinyang/3a105ba91b0d6c9e436b2c3013502ccc to your computer and use it in GitHub Desktop.
Data Matrix Rotating
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <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