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

Large floating point numbers

I'm interested in writing some chem/biochem related tools for myself, but it
appears the Decimal format isn't going to quite cut it for some of the
numbers I'm going to be working with. It's max of ~10^28 is a bit shy of the
at least 10^34 precision I know I'll need at the very least.

Actually, I don't need all the precision. I simply need to be able to have
numbers that go that high. If the actual precision is only to 15 or 20 or so
digits, that would be plenty.

Anyway, are there any libraries for .NET that support large decimal numbers?
I know the gmp library does, but it's C and it looks like it's a nightmare
to build under Linux so I imagine it's only harder to build under Windows.

Thanks.

Pete
Jun 2 '06 #1
2 3154
I'm not aware of any custom libraries to handle larger numbers, but
then again - I've never really needed to find one ^_^

Here are your two built in data types that would be the most likely,
but neither can do 10^34.

decimal
Appx Range: ±1.0 × 10e-28 to ±7.9 × 10e28
Precision: 28-29 significant digits
.Net Framework Type: System.Decimal

double
Appx Range: ±5.0 × 10-324 to ±1.7 × 10308
Precision: 15-16 digits
.Net Framework Type: System.Double

Pete Davis wrote:
I'm interested in writing some chem/biochem related tools for myself, butit
appears the Decimal format isn't going to quite cut it for some of the
numbers I'm going to be working with. It's max of ~10^28 is a bit shy of the
at least 10^34 precision I know I'll need at the very least.

Actually, I don't need all the precision. I simply need to be able to have
numbers that go that high. If the actual precision is only to 15 or 20 orso
digits, that would be plenty.

Anyway, are there any libraries for .NET that support large decimal numbers?
I know the gmp library does, but it's C and it looks like it's a nightmare
to build under Linux so I imagine it's only harder to build under Windows.

Thanks.

Pete


Jun 2 '06 #2
You can get a pre-compiled GMP library (DLL) that works under windows (and
can be got at via DllImport directives) at
http://www.cs.nyu.edu/exact/core/gmp/ , so you do not have to build GMP for
windows.

I have used it with good results in one of my applications. I creating a
tiny VS 2005 managed C++ library project that just wraps GMP calls in C#
classes, and have used the resulting DLL in a few C# projects without a
problem.

If you are interested, I can zip up the VS 2005 C++ project source and email
it to you. I only wrote interfaces for the GMP (integer) functions I
needed, but you can easily follow the pattern to access the GMP floating
point functions. You will need the documentation for GMP at
http://www.swox.com/gmp/#DOC to write the interface functions.

"Pete Davis" <pdavis68@[nospam]hotmail.com> wrote in message
news:YM******************************@giganews.com ...
I'm interested in writing some chem/biochem related tools for myself, but
it appears the Decimal format isn't going to quite cut it for some of the
numbers I'm going to be working with. It's max of ~10^28 is a bit shy of
the at least 10^34 precision I know I'll need at the very least.

Actually, I don't need all the precision. I simply need to be able to have
numbers that go that high. If the actual precision is only to 15 or 20 or
so digits, that would be plenty.

Anyway, are there any libraries for .NET that support large decimal
numbers? I know the gmp library does, but it's C and it looks like it's a
nightmare to build under Linux so I imagine it's only harder to build
under Windows.

Thanks.

Pete

Jun 2 '06 #3

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

Similar topics

4
by: Roger Leigh | last post by:
Hello, I'm writing a fixed-precision floating point class, based on the ideas in the example fixed_pt class in the "Practical C++ Programming" book by Steve Oualline (O' Reilly). This uses a...
18
by: Zero | last post by:
Hi, I am calculating an integer to the pwer of a large integer, e.g. 2^5000. It turns out that the result I always get is zero. I am sure that the result is too large to store in such type...
687
by: cody | last post by:
no this is no trollposting and please don't get it wrong but iam very curious why people still use C instead of other languages especially C++. i heard people say C++ is slower than C but i can't...
10
by: Shawn | last post by:
Hello all, I apologize as I am sure this has probably been dealth with before... but I am doing an exercise from "Practical C Programming" and I have been unable to get it to work perfectly due to...
7
by: Vinoth | last post by:
I'm working in an ARM (ARM9) system which does not have Floating point co-processor or Floating point libraries. But it does support long long int (64 bits). Can you provide some link that would...
15
by: michael.mcgarry | last post by:
Hi, I have a question about floating point precision in C. What is the minimum distinguishable difference between 2 floating point numbers? Does this differ for various computers? Is this...
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.
32
by: ma740988 | last post by:
template <class T> inline bool isEqual( const T& a, const T& b, const T epsilon = std::numeric_limits<T>::epsilon() ) { const T diff = a - b; return ( diff <= epsilon ) && ( diff >= -epsilon );...
11
by: Peter | last post by:
I have written this small app to explain an issue I'm having with a larger program. In the following code I'm taking 10 ints from the keyboard. In the call to average() these 10 ints are then...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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,...
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...

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.