Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define COUNTOF(x) (sizeof(x)/sizeof(*x))
- int mergeTwoInts(const int first, const int second)
- {
- return (first << 16) | second;
- }
- int *splitToTwoInts(const unsigned int merged)
- {
- int *ret = new int[2];
- ret[0] = (merged >> 16) & 0xFFFF;
- ret[1] = merged & 0xFFFF;
- return ret;
- }
- void testSplitStrings() {
- unsigned int id [] = { 65533, 65531, 0, 8, 1, 2, 1, 1 };
- int t1, t2, merged;
- for(int i = 0; i < COUNTOF(id); i+=2) {
- merged = mergeTwoInts(id[i], id[i+1]);
- cout << id[i] << " ^= " << id[i+1] << " -> " << merged<< " -> " << splitToTwoInts(merged)[0] << " !^ " << splitToTwoInts(merged)[1] << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement