Merging and splitting two ints in c++

In c++ an int consists of 4 bytes and can hold a max value of 2147483647 (2^31-1). Should you ever feel the obscure need to merge two ints, because you know that both of your values will never be blow 0 or above 32767 (2^15-1) use the following methods.

1) Merging

2) Splitting

3) applying in a test method

Conclusion:

c++ empoweres me to do probably unnecessary and weird stuff.

Facebook comments:

comments

1 Comment

  1. i think there’s an error in your code, and when you split it should be a right shift

Leave a Reply