1. ## Need help.

So this is what the assignment says:

- I need to write two whole numbers using signed int
- I need to save these two numbers in a unsigned long long variable with the help of Bitshift
- Print the new number that was created

Now there are more lines but the one that confuses me is the second, I have no clue how to do whats asked there, also im not sure whats the new number that I need to print.

In a example how it needs to look in the end the new number for them is e.g. 188978561112 with the numbers 44 and 88

I really dont understand how to save two numbers in a variable... And dont get it how Bitshift should help here.

Thank you

2. Start by printing out 188978561112, 44 and 88 in hexadecimal.

3. 44 in hex 0x2C
88 in hex 0x58
188978561112 in hex 0x2C00000058

So what I got from this is that I gotta move the first number 32 bits to the left so <<32 and then add the second number and yea that works.

Code:
```int main()
{
signed int a;
signed int b;
unsigned long long  c;
scanf("%i \n %i",&a, &b);
c = (((unsigned long)a <<32)+b);
printf("First number %d \nSecond number %d\n",a,b);
printf("%llu \n",c);

}```
But Im not sure what to do if the second number is negative.

I cant get the correct number there is an one more example.

e.g. First number 20, Second number -33 result 90194313183

in hex thats 0x14, -0x21 reslut 0x14FFFFFFDF

4. Consider using | rather than + to combine the two values.

5. Did but I still dont get the correct result for 20 -33
18446744073709551583

6. Originally Posted by JohnnyC
Did but I still dont get the correct result for 20 -33
18446744073709551583
Is that the result you want or the result you're getting?

7. Thats the result I'm getting when I put 20 and -33 using | instead of +.
If I use + I get 85899345887.

While I should be getting 90194313183

8. Well, 20 is 0x14 and -33 is (at least on my machine) 0xffffffdf, and 90194313183 is 0x14ffffffdf, so that seems like a reasonable choice.

Presumably what's happening is that your -33 is getting promoted to long, and therefore the top 32 bits are getting filled with ones instead of zeroes because of the sign bit; to make that not happen you should mask off the top thirty-two bits of b.

Code:
```#include <stdio.h>
int main() {
int a = -0x12345678, b = 0x12345678;

printf("%x %x\n", a, b);

long long n = 0;
n |= (unsigned)a;
n <<= 32;
n |= (unsigned)b;

printf("%llx\n", n);

return 0;
}```

10. Long lost father?

But yea it works Thanks a lot

Code:
```int main()
{
signed int a;
signed int b;
scanf("%i \n %i",&a, &b);
unsigned long long c = 0;
c = c | (unsigned int)a;
printf("Deci%lld\n",c);
printf("Hex%llx\n\n",c);
c = c << 32;
printf("Deci%lld\n",c);
printf("Hex%llx\n\n",c);
c = c | (unsigned int)b;
printf("Deci%lld\n",c);
printf("Hex%llx\n\n",c);

printf("First number %d \nSecond number %d\n",a,b);
printf("%lld \n",c);

{
}
}```
Some of the printf I put just to see whats it doing so I can better understand it.
And the int add_special_type, that was also in the assignment so yea.
Thank you guys

Without the printf
Code:
```int main()
{
signed int a;
signed int b;
scanf("%i \n %i",&a, &b);

unsigned long long c = 0;
c = c | (unsigned int)a;
c = c << 32;
c = c | (unsigned int)b;

printf("First number %d \nSecond number %d\n",a,b);
printf("%lld \n",c);