473,587 Members | 2,547 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Arbitrary precision decimal numbers

Hello!

I am trying to find a minimal class/lib that handles arbitrary precision
decimal numbers. I would be happy if this class supported as little as
addition, subtraction, multiplication, division and comparisons. For
some reason it's quite hard to find such a class on the net. Maybe
because it is trivial to implement such a class?

The only library I have found so far is MAPM
(http://www.tc.umn.edu/~ringx004/mapm-main.html). This library seems
quite small and competent. I would, however, prefer something even
smaller. =)

Maybe someone on this list has some information to share with me about a
minimal arbitrary precision implementaion.

:.:: mattias
Jul 23 '05 #1
5 3057
* =?ISO-8859-1?Q?Mattias_Br= E4ndstr=F6m?=:
Hello!

I am trying to find a minimal class/lib that handles arbitrary precision
decimal numbers. I would be happy if this class supported as little as
addition, subtraction, multiplication, division and comparisons. For
some reason it's quite hard to find such a class on the net. Maybe
because it is trivial to implement such a class?

The only library I have found so far is MAPM
(http://www.tc.umn.edu/~ringx004/mapm-main.html). This library seems
quite small and competent. I would, however, prefer something even
smaller. =)

Maybe someone on this list has some information to share with me about a
minimal arbitrary precision implementaion.


<url: http://www.swox.com/gmp/>

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 23 '05 #2
> I am trying to find a minimal class/lib that handles arbitrary precision
decimal numbers. I would be happy if this class supported as little as
addition, subtraction, multiplication, division and comparisons. For
some reason it's quite hard to find such a class on the net. Maybe
because it is trivial to implement such a class?

The only library I have found so far is MAPM
(http://www.tc.umn.edu/~ringx004/mapm-main.html). This library seems
quite small and competent. I would, however, prefer something even
smaller. =)

Maybe someone on this list has some information to share with me about a
minimal arbitrary precision implementaion.

:.:: mattias


Hello.

You can use some library for long number. For example:

http://sourceforge.net/projects/muntl/

Multiprecision unsigned number template library (MUNTL). The program
is intended for the organization of calculations with the big
precision for unsigned numbers. Program is very fast because do not
use any heap call (new, malloc etc.) All buffers is static allocated.
Program is not use GMP. Program is not limit of number length. For use
this library need only one small header file di.h (26Kb). Adapt for
GCC 3.2.2 and BCB60.

Sincerely yours
Basil
Jul 23 '05 #3

Multiprecision unsigned number template library (MUNTL). The program
is intended for the organization of calculations with the big
precision for unsigned numbers. Program is very fast because do not
use any heap call (new, malloc etc.) All buffers is static allocated.
Program is not use GMP. Program is not limit of number length. For use
this library need only one small header file di.h (26Kb). Adapt for
GCC 3.2.2 and BCB60.

Sincerely yours
Basil


Basil,
Question, I'm actually interested in MUNTL and or GMP.

MUNTL
http://sourceforge.net/projects/muntl/

GMP
http://www.swox.com/gmp/
You seem to recommend not to use GMP, Any particular reasons? In my case, I
have loads of CPU and memory horsepower, but I need to do it very fast.
I'll probably muck around with both, but wondering what you meant by
recommending to NOT use GMP.

Cheers
-grant
Jul 23 '05 #4
> >
Multiprecision unsigned number template library (MUNTL). The program
is intended for the organization of calculations with the big
precision for unsigned numbers. Program is very fast because do not
use any heap call (new, malloc etc.) All buffers is static allocated.
Program is not use GMP. Program is not limit of number length. For use
this library need only one small header file di.h (26Kb). Adapt for
GCC 3.2.2 and BCB60.

Sincerely yours
Basil


Basil,
Question, I'm actually interested in MUNTL and or GMP.

MUNTL
http://sourceforge.net/projects/muntl/

GMP
http://www.swox.com/gmp/
You seem to recommend not to use GMP, Any particular reasons? In my case, I
have loads of CPU and memory horsepower, but I need to do it very fast.
I'll probably muck around with both, but wondering what you meant by
recommending to NOT use GMP.

Cheers
-grant


Hello
Program is very fast because do not use any heap call (new, malloc

etc.) >>All buffers is static allocated.
GMP keeps all of the buffer in a heap.

For many platforms heap system call is carried out slowly
in comparison with access to static objects
or to objects in a stack. Therefore if your program constantly
works with the big numbers and uses GMP, a lot of time
will be spent for allocation and removal of memory in a heap.

If your program works with the big numbers once at start
and once at end, the difference will be imperceptible.:-)

Sincerely yours
Basil
Jul 23 '05 #5

"Mattias Brändström" <"thebrasse at brasse dot org"> wrote in message news:42******** *************@n ews.luth.se...
Hello!

I am trying to find a minimal class/lib that handles arbitrary precision
decimal numbers.

[snip]

Look at C++ BigInt class
https://sourceforge.net/projects/cpp-bigint/
http://groups-beta.google.com/group/...6e8d3ae812abbb

--
Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn

Jul 23 '05 #6

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

Similar topics

0
1408
by: Thinkit | last post by:
Are there any good libraries of arbitrary precision binary floats? I'd like to specify the mantissa length and exponent range. Hexadecimal output would be best (decimal is disgusting with binary floats).
0
1700
by: Thinkit | last post by:
Are there any packages for arbitrary precision binary floats? Something along the lines of Gnu Multi Precision. I saw quite a few rationals classes, but not this. Just looking to be able to use any mantissa or exponent I want. Of course it would be software based arithmetic.
5
11113
by: | last post by:
Ok, I know this sounds bizarre and I regret to say it has me baffled. New decimal fields in tables will accept entry of decimal numbers but immediately change same into integers. Can someone please tell me what incredibly silly thing I'm doing to cause this??? Thanks
1
1328
by: Jack | last post by:
Hello, Can I have advice on the best method to discern the precision of numbers in a text box? My objective is to be able to validate numeric entries in a text box and provide an error message when the precision is not according to business rules. For example, a business rule for one text box may be that the user must enter whole numbers...
12
2844
by: Chadwick Boggs | last post by:
I need to perform modulo operations on extremely large numbers. The % operator is giving me number out of range errors and the mod(x, y) function simply seems to return the wrong results. Also, my numerator is in the format of a quoted string, which the mod function can't take. Desparately searching for solutions, Chadwick. ...
13
42868
by: Girish Sahani | last post by:
Hi, I want to truncate every number to 2 digits after the decimal point. I tried the following but it doesnt work. >>> a = 2 >>> b = 3 >>> round(a*1.0 / b,2) 0.67000000000000004
1
3441
by: Twanne | last post by:
Hi, I've got some code in VBA where I calculate some numbers. Now some of them are large decimal numbers like -6,3216324E03. So in scientific notations. Now I need to add them to a table with an insert query. The query: db.Execute ("INSERT INTO tmpZscore (datum, leeftijd, lengte, ZscoreL, gewicht, ZscoreW, BMI, ZscoreB, IBW) VALUES('" &...
8
2073
by: Martin the Third | last post by:
Hi, I need some help! I'm writing an infinite-precision floating point library called ipfloat (I know infinite is a misnomer - but arbitrary was taken). A quick overview: I'm storing numbers as a char* mantissa, an int exponent and a sign. For example, the number "123.45" would have a mantissa of 12345, an exponent of 2, and a sign of +....
2
3806
by: bsmath | last post by:
I am trying to achieve arbitrary precision for the C++ program below. It works only to about two digits (integer 50) on the C++ compiler I used a few days ago. I am trying to implement the MAPM arbitrary precision library for 300000000 (three hundred million) digits. Any other method or precision greater than 200000 (two hundred thousand)...
0
7920
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8215
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8220
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5718
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5394
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3844
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1454
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.