473,795 Members | 2,830 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do you write an infinite precision number class?

Hi!!! Protoman here, I need to write an infinite precision number class
b/c I want to compute pi. Give me some sample code. Also, when I run my
program and it computes pi, will my computer freeze b/c it's infinite
precision? Thanks for the help!

Sep 11 '05 #1
37 6373
Hi

Protoman wrote:
Hi!!! Protoman here, I need to write an infinite precision number class
b/c I want to compute pi. Give me some sample code.
Give me all your money.
Also, when I run my
program and it computes pi, will my computer freeze b/c it's infinite
precision? Thanks for the help!


Seriously...
1) you certainly want arbitrary precision, not infinite precision
2) you should definitely do your homework on your own
3) if you get stuck, feel free to ask a more specific question

Good luck
Markus

Sep 11 '05 #2
Protoman wrote:
Hi!!! Protoman here,
Hi, pleased to meet you.

I need to write an infinite precision number class
b/c I want to compute pi.
Non sequitur. If you want to compute pi, all you need is to use an arbitrary
precision library. There are some available, and Google is your friend.

Give me some sample code.
Request denied: be more polite.

Also, when I run my program and it computes pi, will my computer freeze
b/c it's infinite precision?
Yes, an infinite precission calculation will freeze your computer and the
whole universe along with it.

Seriously, if you use a high/arbitrary precision library, it will allow you
to specify the precision you want. Then the program will run and either
print out a highly accurate approximation to pi or it will die on you.
Whether your computer freezes in the process depends on your operating
system and how it handles programs that have an ever growing hunger for
memory.

Thanks for the help!


You are very welcome.
Best

Kai-Uwe Bux
Sep 12 '05 #3
OK, let me rephrase this:
I'd like to write an arbitary precision number class[I'd like to be
able to specify the precision in digits or bits] because my co. won't
buy any commercial classes[the procurement dept. are cheapskates].
We're writing a program for a NASA sys. that requires us to calc pi to
1,000,000,000+ digits. Don't worry about size; it'll be running on a
Cray. We're also going to use it to replace or supplant the built in
number types. If you can give me some sample code, that'd be great.
Thanks for the help.

Sep 12 '05 #4

"Kai-Uwe Bux" <jk********@gmx .net> wrote in message
news:dg******** **@murdoch.acc. Virginia.EDU...
Protoman wrote:
Hi!!! Protoman here,
Hi, pleased to meet you.

I need to write an infinite precision number class
b/c I want to compute pi.


Non sequitur. If you want to compute pi, all you need is to use an
arbitrary
precision library. There are some available, and Google is your friend.

Give me some sample code.


Request denied: be more polite.

Also, when I run my program and it computes pi, will my computer freeze
b/c it's infinite precision?


Yes, an infinite precission calculation will freeze your computer and the
whole universe along with it.


lol
Seriously, if you use a high/arbitrary precision library, it will allow
you
to specify the precision you want. Then the program will run and either
print out a highly accurate approximation to pi or it will die on you.
Whether your computer freezes in the process depends on your operating
system and how it handles programs that have an ever growing hunger for
memory.

Thanks for the help!


You are very welcome.
Best

Kai-Uwe Bux

Sep 12 '05 #5

"Protoman" <Pr**********@g mail.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
OK, let me rephrase this:
I'd like to write an arbitary precision number class[I'd like to be
able to specify the precision in digits or bits] because my co. won't
buy any commercial classes[the procurement dept. are cheapskates].
We're writing a program for a NASA sys. that requires us to calc pi to
1,000,000,000+ digits. Don't worry about size; it'll be running on a
Cray. We're also going to use it to replace or supplant the built in
number types. If you can give me some sample code, that'd be great.
Thanks for the help.


OMG, you writing code for Nasa?
Sep 12 '05 #6
Yes really; I'm the asst. head of systems programming in the R&D Dept.
We're calculating thruster angles for a prototype ion drive engine.

Sep 12 '05 #7
Protoman wrote:
OK, let me rephrase this:
I'd like to write an arbitary precision number class[I'd like to be
able to specify the precision in digits or bits] because my co. won't
buy any commercial classes[the procurement dept. are cheapskates].
Use a free library. There are those as well. At least you can use them to do
a quick and dirty implementation of the class to be replaced later. That
way, your colleagues can move on with the rest of the program.

We're writing a program for a NASA sys. that requires us to calc pi to
1,000,000,000+ digits.
a ) Why would NASA need that? The known universe has a diameter on the order
of 10^28m. Thus, an error in an angle in the 50s digit after the decimal
point will project to a distance way less than the diameter of an electron
at the other end of the universe. No real world application has a need for
more than 50 digits of pi.

b) If NASA does not like open source, have them pay for the library.

Don't worry about size; it'll be running on a Cray.
No need for that. There is a digit extraction algorithm for pi. You can
produce 1,000,000,000 digits and more on any modern day PC.

We're also going to use it to replace or supplant the built in
number types. If you can give me some sample code, that'd be great.
Thanks for the help.


Well, if you really want to code that beast on your own, the best way to
start is probably still to read the relevant chapters in

D.E. Knuth: The art of computer programming Vol 2
(seminumerical algorithms)

Then, start with coding an arbitrary size unsigned int class. A cheap way to
go would be to do something like:

class Cardinal {
std::vector< unsigned long > digit;
public:
...
}; // class Cardinal

later you can use that and build a float class like so:

template < unsigned long Digits = 100 > {
class Real {

bool positive;
Cardinal mantissa;
signed long exponent;
public:
...
}; // Real<>

It does not make sense to discuss the "..." parts unless you settled on
certain algorithms.
Best

Kai-Uwe Bux
Sep 12 '05 #8
OK, but how do I actually *code* it? The precision alogorithm, I mean.

Sep 12 '05 #9
It's not a missile; it's a space probe. And how do I code the
prescision algorithm and conversion functs; I can figure out how to do
just about everything else but constructor, destructor, and copy
constructor. Thanks.

Sep 12 '05 #10

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

Similar topics

5
2404
by: Bruce | last post by:
I have a nice public domain large number class that uses STL vectors and seems to be relatively bug free but is not the fastest thing on the planet and I have a need for speed. Anyone know of any available that are really optimized for speed. All I need for functionality is multiply, divide and modulous operations.
0
9673
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10216
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10165
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9044
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7543
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6783
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5565
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2921
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.