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

Working with VERY LARGE numbers

Hi,

I have working on a system in which I have to manipulate *very* big numbers.
Like
32368060745625089670148189374568111100874165870871 388541651800834565616109380834613212956588769877

They may be upto 10000 digits long.

These numbers are coming through a device in ascii format, I am creating a
text file and saving these numbers in the file.
Is there a way that I can convert them into binary.
For example if the incoming number is '14005685717805198227'
it should be saved in file as 11000010 01011110 00110000 11110100 01111101
10001010 01101011 10010011 (binary data) (File size: 8 bytes)
instead of ascii '1', '4', '0', '0', '5', '6', '8', '5', '7', '1', '7',
'8', '0', '5', '1', '9', '8', '2', '2', '7' (ascii/text data) (File size: 20
bytes).

I am looking for a hint on how to implement this, of if there are libraries
availeble to acheive this.

Thanks.

-
AM

Nov 7 '07 #1
9 9963
BTW, I used Windows Calculator program to convert 14005685717805198227
(decimal) into binary.
"Aamir Mahmood" <aa**********@gmail.comwrote in message
news:ey*************@TK2MSFTNGP06.phx.gbl...
Hi,

I have working on a system in which I have to manipulate *very* big
numbers.
Like
32368060745625089670148189374568111100874165870871 388541651800834565616109380834613212956588769877

They may be upto 10000 digits long.

These numbers are coming through a device in ascii format, I am creating a
text file and saving these numbers in the file.
Is there a way that I can convert them into binary.
For example if the incoming number is '14005685717805198227'
it should be saved in file as 11000010 01011110 00110000 11110100 01111101
10001010 01101011 10010011 (binary data) (File size: 8 bytes)
instead of ascii '1', '4', '0', '0', '5', '6', '8', '5', '7', '1', '7',
'8', '0', '5', '1', '9', '8', '2', '2', '7' (ascii/text data) (File size:
20 bytes).

I am looking for a hint on how to implement this, of if there are
libraries availeble to acheive this.

Thanks.

-
AM

Nov 7 '07 #2
On Nov 6, 8:19 pm, "Aamir Mahmood" <aamirmahm...@gmail.comwrote:
Hi,

I have working on a system in which I have to manipulate *very* big numbers.
Like
32368060745625089670148189374568111100874165870871 3885416518008345656161093*80834613212956588769877

They may be upto 10000 digits long.

These numbers are coming through a device in ascii format, I am creating a
text file and saving these numbers in the file.
Is there a way that I can convert them into binary.
For example if the incoming number is '14005685717805198227'
it should be saved in file as 11000010 01011110 00110000 11110100 01111101
10001010 01101011 10010011 (binary data) (File size: 8 bytes)
instead of ascii '1', '4', '0', '0', '5', '6', '8', '5', '7', '1', '7',
'8', '0', '5', '1', '9', '8', '2', '2', '7' (ascii/text data) (File size:20
bytes).

I am looking for a hint on how to implement this, of if there are libraries
availeble to acheive this.

Thanks.

-
AM
The J# library contains a BigInteger class.

Nov 7 '07 #3
Aamir Mahmood wrote:
I have working on a system in which I have to manipulate *very* big numbers.
Like
32368060745625089670148189374568111100874165870871 388541651800834565616109380834613212956588769877

They may be upto 10000 digits long.
I am looking for a hint on how to implement this, of if there are libraries
availeble to acheive this.
There should be plenty of bigint libraries for C# available.

http://www.codeproject.com/csharp/biginteger.asp shows up
at the top in Google.

Arne
Nov 7 '07 #4
"Aamir Mahmood" <aa**********@gmail.comwrote in message
news:ey*************@TK2MSFTNGP06.phx.gbl...
Hi,

I have working on a system in which I have to manipulate *very* big
numbers.
Like
32368060745625089670148189374568111100874165870871 388541651800834565616109380834613212956588769877

They may be upto 10000 digits long.

These numbers are coming through a device in ascii format, I am creating a
text file and saving these numbers in the file.
Is there a way that I can convert them into binary.
For example if the incoming number is '14005685717805198227'
it should be saved in file as 11000010 01011110 00110000 11110100 01111101
10001010 01101011 10010011 (binary data) (File size: 8 bytes)
instead of ascii '1', '4', '0', '0', '5', '6', '8', '5', '7', '1', '7',
'8', '0', '5', '1', '9', '8', '2', '2', '7' (ascii/text data) (File size:
20 bytes).

I am looking for a hint on how to implement this, of if there are
libraries availeble to acheive this.
This is the way I did it (originally in VB6).
1) Create a byte array of size 1 with just the values 1 in it. (A)
2) Create a byte array for the result (B)
3) Grab the least significant digit of your value. (C)
4) Add a times c to b
5) Multiply a by 10
6) Repeat, grabbing the next digit along.

You'll need to do something to enlarge the byte arrays as you go. To
multiply by 10 you shift left 2 and add that to the result of shifting left
another 2, eg, to multiply A by 10

x = A << 2
y = x << 2
A = x + y

I can send you the vb6 source code if you like.

Michael
Nov 7 '07 #5
Maybe its time to consider using Microsoft F# which was just released and is
a CLR functional language for those working with science, geometry and math
applications. Not widely marketed yet but Microsoft also has a Windows
server for science and engineering where many F# applications will be used
to develop applications supporting parellel processing on the quad cores and
beyond.

"Aamir Mahmood" <aa**********@gmail.comwrote in message
news:ey*************@TK2MSFTNGP06.phx.gbl...
Hi,

I have working on a system in which I have to manipulate *very* big
numbers.
Like
32368060745625089670148189374568111100874165870871 388541651800834565616109380834613212956588769877

They may be upto 10000 digits long.

These numbers are coming through a device in ascii format, I am creating a
text file and saving these numbers in the file.
Is there a way that I can convert them into binary.
For example if the incoming number is '14005685717805198227'
it should be saved in file as 11000010 01011110 00110000 11110100 01111101
10001010 01101011 10010011 (binary data) (File size: 8 bytes)
instead of ascii '1', '4', '0', '0', '5', '6', '8', '5', '7', '1', '7',
'8', '0', '5', '1', '9', '8', '2', '2', '7' (ascii/text data) (File size:
20 bytes).

I am looking for a hint on how to implement this, of if there are
libraries availeble to acheive this.

Thanks.

-
AM

Nov 7 '07 #6
I wrote a C# wrapper for the GMP bignum library. You can find it at
http://www.frontiernet.net/~fredm/gmp/gmp.htm
"Aamir Mahmood" <aa**********@gmail.comwrote in message
news:ey*************@TK2MSFTNGP06.phx.gbl...
Hi,

I have working on a system in which I have to manipulate *very* big
numbers.
Like
32368060745625089670148189374568111100874165870871 388541651800834565616109380834613212956588769877

They may be upto 10000 digits long.

These numbers are coming through a device in ascii format, I am creating a
text file and saving these numbers in the file.
Is there a way that I can convert them into binary.
For example if the incoming number is '14005685717805198227'
it should be saved in file as 11000010 01011110 00110000 11110100 01111101
10001010 01101011 10010011 (binary data) (File size: 8 bytes)
instead of ascii '1', '4', '0', '0', '5', '6', '8', '5', '7', '1', '7',
'8', '0', '5', '1', '9', '8', '2', '2', '7' (ascii/text data) (File size:
20 bytes).

I am looking for a hint on how to implement this, of if there are
libraries availeble to acheive this.

Thanks.

-
AM

Nov 7 '07 #7
If all you need to so is store them, you can split the string into
substrings, convert each of these to an unsigned integer, and store it. Each
substring represents a power (exponent) of the number stored in it,
according to its place in the original string. To perform math with it would
require a good bit more work, however.

--
HTH,

Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP

"Aamir Mahmood" <aa**********@gmail.comwrote in message
news:ey*************@TK2MSFTNGP06.phx.gbl...
Hi,

I have working on a system in which I have to manipulate *very* big
numbers.
Like
32368060745625089670148189374568111100874165870871 388541651800834565616109380834613212956588769877

They may be upto 10000 digits long.

These numbers are coming through a device in ascii format, I am creating a
text file and saving these numbers in the file.
Is there a way that I can convert them into binary.
For example if the incoming number is '14005685717805198227'
it should be saved in file as 11000010 01011110 00110000 11110100 01111101
10001010 01101011 10010011 (binary data) (File size: 8 bytes)
instead of ascii '1', '4', '0', '0', '5', '6', '8', '5', '7', '1', '7',
'8', '0', '5', '1', '9', '8', '2', '2', '7' (ascii/text data) (File size:
20 bytes).

I am looking for a hint on how to implement this, of if there are
libraries availeble to acheive this.

Thanks.

-
AM

Nov 7 '07 #8
I've got to ask. Just what kind of application requires such amazingly
large numbers. 1000 decimal digits is awesome! Are you counting the
electrons in the universe, or something?

SteveT

Nov 8 '07 #9
"Steve Thackery" <th***@nowhere.netwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
I've got to ask. Just what kind of application requires such amazingly
large numbers. 1000 decimal digits is awesome! Are you counting the
electrons in the universe, or something?
Bill Gate's personal accounting software? ;-)

Michael
Nov 8 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Alex Vinokur | last post by:
Dann Corbit has implemented function int ilog2 (unsigned long) at http://groups.google.com/groups?selm=lkPa4.2165%24I41.1498%40client Is exist a similar C++-function for very large numbers,...
5
by: Todd Steury | last post by:
Greetings Python'ers: I'm just an amature who occasionally uses Python for complex mathematical models. The current model I'm working with occasionally generates really large numbers that are...
24
by: Salad | last post by:
Every now and then I see ads that state something like "Experience with Large Databases ...multi-gig...blah-de-blah" And I have to laugh. What's the difference between a large or small database? ...
3
by: adam.sherratt | last post by:
Ayup! I am currently working on a Capacity Planning project for my office, and i'm interested to hear your thoughts on the best way to approach something. here's the scenario; The...
1
by: Joshco | last post by:
Does anybody know how to force visual to use a number this is around 1000 digits long and 64 bit floating point. I am a beginner in programing.
132
by: Frederick Gotham | last post by:
If we look at a programming language such as C++: When an updated Standard comes out, everyone adopts it and abandons the previous one. It seems though that things aren't so clear-cut in the C...
58
by: mailursubbu | last post by:
Hi How to write a program to get the factorial of 4096. I am working on a Linux m/c. Best Regards, Subra
1
by: AlmasKhan01 | last post by:
Hi I have been for sometime now been working on a MineSweeper program and I'm 90% complete on it it involves a window interface and is quite simple but the issue is not. The program is long(to me)...
0
by: zephyrus360 | last post by:
This is about a technique to find the mod of a very large integer with a normal small integer. I recently encountered this problem when I needed to compute the modulus of a very large number with...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.