Last active
December 2, 2015 19:35
-
-
Save clausecker/3d957c8c0b7a05960dda to your computer and use it in GitHub Desktop.
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
| extern unsigned | |
| decimal2dpd(unsigned a, unsigned b, unsigned c) | |
| { | |
| unsigned result = c & 1 | (a & 7) << 7; | |
| if (a < 8) { | |
| if (b < 8) | |
| return result | b << 4 | c; | |
| else | |
| return result | (c > 7 ? 0104 : (c & 6) << 4) | (b & 1) << 4 | 0012; | |
| } else { | |
| result |= (b & 1) << 4; | |
| if (c < 8) | |
| return result | (c & 6) << 7 | (b > 7 ? 0002 : b << 4) | 0014; | |
| else | |
| return result | (b > 7 ? 0100 : (b & 6) << 7) | 0056; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment