473,320 Members | 1,865 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.

big number crunching in C

Greetings:

Does any one know how high-precision integer +-*/ are implemented in C
using char[]? I'm talking about integers that have say, 2000 digits.

I found a few "bignum.c" on the net but all of them are too long to
implement in the session of a single computing contest (3 hours), so
I'm looking for shorter ones.

Regards,

Shuo Xiang
Nov 13 '05 #1
3 3602

"Shuo Xiang" <sx****@student.math.uwaterloo.ca> wrote in message
news:db**************************@posting.google.c om...
Greetings:

Does any one know how high-precision integer +-*/ are implemented in C
Numeric precision is not specified in terms of
operators, but of the numeric types' representations.
See the macros in <limits.h> for the allowed range for each
integral type, and in <float.h> for the same info about
each floating point type. e.g. 'INT_MAX' is the highest
value allowed for type 'int', 'DBL_MAX' the highest for
type 'double', etc.

using char[]?
Arithmetic operators cannot be applied to arrays.
If you mean you want to store your values as 'one
digit per character', then the size is only limited
by available storage. But you'll have to code the
operators yourself. Not a small task. Better might
be to find an already existing library. www.google.com

I'm talking about integers that have say, 2000 digits.
You'll need to write or obtain a library for that.


I found a few "bignum.c" on the net but all of them are too long to
implement
They're already implemented. Your program can *use* them.
in the session of a single computing contest (3 hours), so
I'm looking for shorter ones.


I'm looking for automobile that can be driven from Los Angeles
to New York in six hours.

"I want a new drug"
-- Huey Lewis

-Mike
Nov 13 '05 #2
Shuo Xiang wrote:
Does any one know how high-precision integer +-*/ are implemented in C
using char[]? I'm talking about integers that have say, 2000 digits.
They aren't. Standard C doesn't have high precision integers. There
are various libraries that do, but I doubt any of them use arrays of
char.
I found a few "bignum.c" on the net but all of them are too long to
implement in the session of a single computing contest (3 hours), so
I'm looking for shorter ones.


If you mean you need to be able to hack up some bignum code in a few
hours for a contest, offhand I'd advise putting the least
significant digit in [0], store them as 0-9 instead of '0'-'9', and
think about how you do +-*/ with paper and pencil.

--
Tom Zych
This is a fake email address to thwart spammers.
Real address: echo 'g******@cbobk.pbz' | rot13
Nov 13 '05 #3

"Shuo Xiang" <sx****@student.math.uwaterloo.ca> wrote in message
news:db**************************@posting.google.c om...
Greetings:

Does any one know how high-precision integer +-*/ are implemented in C
using char[]? I'm talking about integers that have say, 2000 digits.

I found a few "bignum.c" on the net but all of them are too long to
implement in the session of a single computing contest (3 hours), so
I'm looking for shorter ones.


All except bugnum divided by bignum can be done in a 3 hour contest.

Things like computing pi or e to many digits don't need bignum divided by
bignum.

-- glen
Nov 13 '05 #4

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

Similar topics

8
by: EAS | last post by:
Hey, I'm new to python (and programming in general) so I'll prolly be around here a lot... Anyways, I've found out how to make a "guess my number game" where the player guesses a number between...
3
by: I.V. Aprameya Rao | last post by:
hi i have been wondering, how does python store its very long integers and perform aritmetic on it. i needed to implement this myself and was thinking of storing the digits of an integer in a...
0
by: TechBookReport | last post by:
There's a review of 'Data Crunching' by Greg Wilson over at TechBookReport. This is not a teach-yourself Python book but one that uses Python to solve various common data-related tasks with regular...
11
by: don | last post by:
Ok, this is a homework assignment, but can you help me out anyway...... I need a routine for figuring out if a number inputted by the user is a prime number or not...... all I'm asking for is Not...
3
by: Chris Spencer | last post by:
Is there any library for Python that implements a kind of universal number object. Something that, if you divide two integers, generates a ratio instead of a float, or if you take the square root...
4
by: tbonejo | last post by:
Hi all. Question: I have a project nearly complete written in VB.Net using charts from 3rd party vendors...expensive, yes, fast, not really. The data I am plotting is about 30 columns by...
19
by: gk245 | last post by:
Trying to write a program that will figure out if a number is perfect or not. Here is my logic: 1) Read in the number 2) Split it up (number - 1) 3) Put all the split up numbers into an...
13
by: artev | last post by:
If sort this work: var myarray= new Array(10,16,35,"0.1",8,4,22,19,1,22,35,9,26,38,40); with code function function1(a,b) {return a - b} var order02=new Array();...
6
by: Paul Bromley | last post by:
Ok - I have given up on trying to find the active IP address for a given PC. For licensing purposes I need to retrive a unique identifier from the PC that the program is installed on. The Hard disk...
22
by: utab | last post by:
Dear all, I was wondering if I could divide all elements of a vector by the max element of that vector. I checked the STL references and found transform, for_each and lately BOOST_FOREACH,...
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: 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...
0
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...
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)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
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: 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...

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.