Computer Science, asked by thatherasantosh9458, 1 year ago

Can i store two integer values into a single integer

Answers

Answered by Avanish010
0

Hi there,

Here's the program to add integers.

void take2IntegersAsOne(int x)

{

// int1 is stored in the bottom half of x, so take just that part.

int int1 = x & 0xFFFF;

// int2 is stored in the top half of x, so slide that part of the number

// into the bottom half, and take just that part.

int int2 = (x >> 16) & 0xFFFF

// use int1 and int2 here. They must both be less than 0xFFFF or 65535 in decimal

}

void pass2()

{

int int1 = 345;

int int2 = 2342;

take2Integers( int1 | (int2 << 16) );

}

Similar questions