473,320 Members | 2,004 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,320 software developers and data experts.

merge two long numbers into one long number

i am implementing blowfish algorithm..
i have a long number or a 64 bit no. say X
i have to divide this 64 bit block into two 32 bit blocks say xl and xr.

after doing some calculations i have to convert these two 32 bit blocks into 64 bit block again..
so how do i do this


pls help..
Mar 21 '10 #1
3 2705
Convert two long numbers into String, then merge these two strings and then again convert this string into long number like this:

long l1=1234
long l2=5678

String s1=Long.toString(l1);
String s2=Long.toString(l2);

String s=s1+s2;

long l=Long.valueOf(s).LongValue();
Mar 21 '10 #2
hii
thanks for the reply
but the problem i am facing now is that it is giving me number format exception for string s
i guess the string becomes too large to be stored in a long no.
what i want is
a long no. X ( 64 bit )
divide to two 32 bits xl and xr
and then merge xl and xr as 64 bit X again
Mar 22 '10 #3
jkmyoung
2,057 Expert 2GB
oh no!
With the string method, each number won't fill the 32 bit space they have been assigned.
ulong ul1 = 1234;
ulong ul2 = 5678;

ulong result = (ul1 << 32) | ul2;
Use a bit shift operator instead.
Mar 22 '10 #4

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

Similar topics

3
by: Kevin King | last post by:
I have a question about an assignment I have. I need to count the number of comparisons in my merge sort. I know that the function is roughly nlog(n), but I am definately coming up with too many...
12
by: jose luis fernandez diaz | last post by:
Hi, My OS is: cronos:jdiaz:tmp>uname -a HP-UX cronos B.11.11 U 9000/800 820960681 unlimited-user license I compile in 64-bits mode the program below:
7
by: William Payne | last post by:
Hello, I have a variable of type unsigned long. It has a number of bits set (with set I mean they equal one). I need to determine those bits and their position and create new numbers from them. For...
0
by: beerman | last post by:
I have developed an app (in Access 2002) that dynamically creates a table, and the fields in that table, for propagation based on the max number of occurences in a reference table. Basically, it...
6
by: Danny Lesandrini | last post by:
I'm using an Access database to drive a web site and the colors of various table backgrounds are stored in Access. I want users of the Access database to be able to select colors for the site, but...
7
by: Defected | last post by:
Thanks all for help, I have tried this code but it's don't work. -------------------------------------------------------------------- Structure typedef struct{ int atomic_number; char...
1
by: barny | last post by:
Hi all, I have been trying to merge two access tables together all morning with no succsess. In table one I have Account Number|Return1|Return2|Return3| M1234567 | P9832 | Q1234 | P4322 |...
2
by: mqueene7 | last post by:
below is my code for my merge sort but I can't get it to sort properly. I am trying generate random numbers based on input from the user and then sort those random numbers. Can you tell me what I...
17
by: Tarique | last post by:
This program was compiled on MS Visual C++ 08 /*Fibonacci Numbers*/ #include<stdio.h> #include<limits.h> void fibonacci(int n) { unsigned long long fib0 = 0; /*First Fibonacci Number*/
8
by: Mark Main | last post by:
I just bought Visual Studio 2008, I'm new to C# and trying to learn it. I'm stuck and would appreciate some help. I need to make the fastest code I can to work with a large key (it's 200 bytes...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.