473,226 Members | 1,693 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,226 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 5428
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: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

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.