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

Arbitrary Precision for C++ Program

7
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) digits will be helpful, but the one below is
best, unless a better method can be found. I did not know what to do with the
last few lines (if(int(X/Y)==X/N)cout<<"yes";
else cout<<"no";
cout<<"\tS: "<<S<<"\tR: "<<R<<"\ta: "<<a<<endl;) as far as
arbitrary precision goes.


Expand|Select|Wrap|Line Numbers
  1. #include<iostream>
  2. #include<cmath>
  3. #include<"m_apm.h">
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.      m_apm_cpp_precision(300000000);
  9.     double a_mapm=m_apm_2.0,m_apm_R=1;
  10.     for(int S=900;S<913;S+=2)
  11.     {
  12.         double N_mapm=m_apmpow(2,R)*S+1;
  13.         double X_mapm=m_apmpow(a,S)-1;
  14.         double Y_mapm=m_mapmpow(2,R)*S+1;
  15.         if(int(X/Y)==X/N)cout<<"yes";
  16.         else cout<<"no";
  17.       cout<<"\tS: "<<S<<"\tR: "<<R<<"\ta: "<<a<<endl;      
  18.       }
  19. char q;
  20. cout<<"press enter to delete screen...";
  21. cin.get(q);
  22. return 0;
  23. }
Mar 31 '10 #1
2 3793
whodgson
542 512MB
Hmm you say you are trying to set precision to 300 000 000.
Ok I have no idea how to do that although the people evaluating pi have gone a lot further on the Cray. However you cannot write the double pow (double, double) as above with that prefix in C++ to evaluate 2 raised to power R as far as I am aware irrespective of what is in the header file of the same name.Will follow with interest.
Apr 1 '10 #2
weaknessforcats
9,208 Expert Mod 8TB
A double has only 15 digits. A float has 6.

You cannot use floating pointer for accuracy. Floating point is designed specifically for scientific wiork where extreme accuracy is not required.

In your case you will need to write a large number library if you can't find one already written that you can buy.
Apr 2 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
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...
0
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...
2
by: Jack | last post by:
Quick question, does anyone know what the limitations are, besides memory for GMP, and also, if I write software that uses this library, is it true that it may run differently on different hardware...
2
by: cpptutor2000 | last post by:
Could some C++ guru please help me? I am using a BigInteger class which is really a wrapper around a C source file(mpi.c) that does arbitrary precision arithmetic operations. When I compile the C...
5
by: Mattias Brändström | last post by:
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,...
3
by: Jack | last post by:
Quick question, does anyone know what the limitations are, besides memory for GMP, and also, if I write software that uses this library, is it true that it may run differently on different hardware...
12
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,...
15
by: Alasdair | last post by:
I need to apply the ceiling function to arbitrary sized (long) integers. However, division automatically returns the type of its operands, so that, for example: math.ceil(7/4) returns 1. I can use...
8
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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
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...
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,...

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.