Long(64) to Int(32) in C/C++

Just for me because I need this as a snippet:

int leftbits = (int)(longvar>> 32);

gives you the left bits, and

long tlong= ((longvar>> 32) << 32);
int rightbits= (int)(longvar- tlong);

gives you to right bits of a 64 bit number.

Consider turning this into a macro or a function, but I’m not sure how often I’m gonna need it…  Part of me thinks this 64bit number is just for upward compatibility..

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: