473,405 Members | 2,373 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

splitting u_int64_t into 2 u_int32_t in c++

Hi,

I have a c++ code in which i have combined 2 u_int32_t data into a single u_int64_t data initially.
Now, i need to split this u_int64_t data into their 2 corresponding u_int_32_t data?(I need to gather the values of the 2 u_int32_t as they were before the combination to that u_int64_t).

Can anyone provide me with a piece of code which would help to do this?

Thanking you,
Am_Rich...!
Nov 26 '07 #1
7 5453
gpraghuram
1,275 Expert 1GB
Hi,

I have a c++ code in which i have combined 2 u_int32_t data into a single u_int64_t data initially.
Now, i need to split this u_int64_t data into their 2 corresponding u_int_32_t data?(I need to gather the values of the 2 u_int32_t as they were before the combination to that u_int64_t).

Can anyone provide me with a piece of code which would help to do this?

Thanking you,
Am_Rich...!

What logic you have followed to combine 2 32 bit values to a 64 bit value?
You have to do the reverse.
The logic is usually while combining you will do a OR operation and while separating you have to use AND operation.


Raghuram
Nov 26 '07 #2
Hi Raghuram,
Thanks a lot for your response.
This is in fact the piece of code which ive been using for the combination purpose:

swap_64(u_int32_t x, u_int32_t y)
{
u_int64_t int64a = x;
u_int64_t int64b = y;
return(int64a<<32)|(int64b);

}
Nov 26 '07 #3
Sorry for the improper formatting Raghuram,
I had been accidentally hitting on the Tab Key for some formatting and this has as such resulted to the submission of the post:(

Appology for the inconvenience caused,
Am_Rich...!
Nov 26 '07 #4
gpraghuram
1,275 Expert 1GB
Sorry for the improper formatting Raghuram,
I had been accidentally hitting on the Tab Key for some formatting and this has as such resulted to the submission of the post:(

Appology for the inconvenience caused,
Am_Rich...!
The cobining part is OK but for the splitting part i am not able to get a solution....i need some time...
In the Mean time other members please take a look into this

Raghuram
Nov 27 '07 #5
gpraghuram
1,275 Expert 1GB
The cobining part is OK but for the splitting part i am not able to get a solution....i need some time...
In the Mean time other members please take a look into this

Raghuram
Hi,
I got the idea about how to do that.
Following is the code snippet
Expand|Select|Wrap|Line Numbers
  1. void separateVar(unsigned long long _ip,unsigned long &_var1,unsigned long &_var2)
  2. {
  3.     unsigned long long mask=0x00000000FFFFFFFF;
  4.     _var2=_ip&mask;
  5.     _var1=_ip>>32;
  6. }
  7.  
_ip is the combined variable
_var1 and _var2 is passed as reference.

Thanks
Raghuram
Nov 27 '07 #6
Thanks Raghuram,

Will try implement this.

Regards,
Am_Rich...!
Nov 27 '07 #7
Hi Raghuram,

Its Working!!!
Thanks a lot!!!:)

Regards,
Am_Rich...![/quote]
Nov 27 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: somaBoy MX | last post by:
I'm building a site where I need to pull very large blocks from a database. I would like to make navigation a little more user friendly by splitting text in pages which can then be navigated. I...
7
by: qwweeeit | last post by:
Hi all, I am writing a script to visualize (and print) the web references hidden in the html files as: '<a href="web reference"> underlined reference</a>' Optimizing my code, I found that an...
3
by: Rakesh | last post by:
Hi, I was 'googling' to look out for some ways of optimizing the code and came across this term - 'hot / cold splitting'. In short, the discussion is about splitting heavily accessed ( hot )...
6
by: nwheavyw8 | last post by:
I am currently trying to write a simple PHP script that will split an uploading file up into 500kb "chunks", then read and concatenate them back together when accessed for download. I can't seem...
1
by: Andy Britcliffe | last post by:
Hi I'm faced with the situation where I could have a single physical file that could contain multiplie XML documents e.g file.txt contains the following: <?xml version="1.0"...
6
by: Earl Anderson | last post by:
I have a A97/XP applet I've developed for my own use in my department. My boss "suggests" that since I built it, I share it with and instruct the other 6 members of my department on its use. I've...
20
by: Ed | last post by:
I am running Access 2002 and just ran the built in Access wizard for splitting a database into a back end (with tables) and front end (with queries, forms, modules, etc.). After running the...
5
by: The Dark Free Soul | last post by:
Moin everybody. I'm writing a little application to take confidence with socket raw and tcp protocol over ipv4. According to tcp protocol sequence number must be a 32bit log number. I do this...
2
by: shadow_ | last post by:
Hi i m new at C and trying to write a parser and a string class. Basicly program will read data from file and splits it into lines then lines to words. i used strtok function for splitting data to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.