   How to make a real number accurate up to n decimal places?
  I was asked to write a function that do some calculation and return a real number as the result.Is there any library function in C/C++ that make a real number accurate up to n decimal places?   
  I don't know whether there is already a library for this, but if you don't find one, I suppose you'll have to implement your own type for real numbers, able to hold an arbitrary number of digits for precision, (and maybe able to dynamically adjust to higher precision if needed)You'll have to overload arithmetic operators to re-define operations for the new data type and you'll probably have to write all mathematical functions you may need (such as sin/cos, sqrt etc.) using iterative methods in your new format. The existing ones won't be of much use if i.e. you want cos(pi/4) with 100 digits precision. (which is irrational -btw-)I suppose you can forget about the speed performance of the arithmetic data types inherent to the programming languages.   ;  there are lots of them, you just need to know the search keywords:MAPM, A Portable Arbitrary Precision Math Library in C., havent searched for one that is pure c++ ... but it should'nt be to hard to find one with:[google]T2k   