## ariyan

How to store a 64 bit value into 2 unsigned long variable (of 32 bit)?

Let,

``````:
unsigned long a; // variable 'a' will be incremented regularly and 'll be stored in b
void fun(void)
{
unsigned long double b; // It may be a global variable
b += a; // if b is a 64 bit variable ,
// regular addition of 'a' into 'b' will increase the value greater than 32 bit
};``````

Now instead of using variable b of using 64 bit, I have to use two unsigned long variable(let c, d of 32 bit each) and store the value into 'c' and 'd', which is not a problem in case of storing that value into 'b'.
If you provide the answer using 4 unsigned integer (16 bit each) variable, it is also somhow acceptable.
Note: a' is a global variable. and 'c' and 'd' 'll also be global.
Thanks to all.

## Grunt 19

I think you can use `shifting` and `bitwise` operators.

commented: yup you're right (andor) +2

## Infarction 503

I'd agree with Grunt. But to make my post somewhat meaningful, I though I'd also point out that you made b of type `unsigned long double` . I'm thinking that you don't want a floating point value if you're doing integer operations (especially if you're using bitwise operators).

## Grunt 19

and I think `unsigned long double` is anyway wrong.

## Infarction 503

Yeah, IIRC floating point values are always signed. I think some compilers accept `long double` as a type though. The OP probably meant to use `unsigned long long` , I'm guessing.

## ariyan

I'd agree with Grunt. But to make my post somewhat meaningful, I though I'd also point out that you made b of type `unsigned long double` . I'm thinking that you don't want a floating point value if you're doing integer operations (especially if you're using bitwise operators).

yeah you are right. I can do that job by using double, but I am unable to use that in my environment. I have to usec either 'long' o 'int'.