Solved

I need to manage more than 15 digits of precision in my Visual C++ program and libraries

Posted on 2011-02-28
7
358 Views
Last Modified: 2012-05-11
Hi,

I have a program and libraries written in Visual C++ 2005 where i use variables of type double. So far i have been working with this data type with the maximum 15 digits of precision but now i have a request from my customer for supporting 16, 17 and more digits of precision. I don't know how to do this or even if that is possible.

What can i do?
Should i use the boost libraries?
Write my own type and change the data types all over the code (thousands of lines involved) ?

Thanks and regards,

Johann
0
Comment
Question by:JohannRamon
7 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 35002856
It's definitely possible - check out e.g.

NTL (http://www.shoup.net/ntl/): arbitrary length integers, vectors/matrices/polynomials over integers and over finite fields.
Apfloat (http://www.apfloat.org/apfloat/): a C++ High Performance Arbitrary Precision Arithmetic Package
MUNTL (http://sourceforge.net/projects/muntl/): Multiprecision unsigned number template library
LiDIA (http://www.cdc.informatik.tu-darmstadt.de/TI/LiDIA/): A library for computational number theory. Provides a collection of highly optimized implementations of various multiprecision data types and time-intensive algorithms.
0
 
LVL 33

Expert Comment

by:sarabande
ID: 35005249
it would be not so difficult to use own type highdouble instead of double in your code. you can do such a substitution in very short time with case sensitive and full-word replacement. then make a central typedef double highdouble; and your programs should build. you then can decide how to implement highdouble, either made by your own for example based on 64-bit integer or using an appropriate type of a foreign library as base.

Sara
0
 
LVL 2

Author Comment

by:JohannRamon
ID: 35017500
Hi,

Thanks for the prompt answers!

jkr: I have checked the libraries and so far NTL types (xdouble or RR) look like my best solution. It looks like the library i already have "boost" doesn't have an appropriate data type.

Sara: It looks like the best path for this large amount of code is the search-replace of the data type. If i include the foreign library it would still be necessary to make the "typedef double highdouble"?

Thanks again and regards,

Johann
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 33

Expert Comment

by:sarabande
ID: 35019713
you probably then would replace the typedef by

   typedef  long_double_from_library highdouble;

or in case the new (class) type would not provide an interface so that it could substitute a double, you would implement the type highdouble yourself taking the type from the library as a base.

Sara
0
 
LVL 2

Author Comment

by:JohannRamon
ID: 35060797
Hi,

Funny as it sounds, my management wants a "commercial" solution because they feel it is necessary to have a "provider" which can give us support and warranties backed up with a contract (the perceived risk of precision errors is too high for us to assume it alone).

I´m sorry for this added condition. Any suggested option?

Thanks again and regards,

Johann
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 35321646
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now