0

Is there any floating point type that stores more digits after the decimal point than double in c++ (or any alternative, which makes double stored more digits)?

I've read that long double is maybe more accurate.

In my program we can zoom into the Mandelbrot set, but after some zoom the picture gets pixelated. I think it is because the length between two complex numbers associated with two neighboring pixels is less than the difference between two consecutive value of double. In the program I used long double.

If it's important, then the processor of my computer is Intel® Core™ i3 CPU M 380 @ 2.53GHz × 4, the computer is 64 bit, the operating system is Ubuntu and the compiler is gcc.

the pixelated Mandelbrot set

phuclv
  • 37,963
  • 15
  • 156
  • 475
csekri
  • 20
  • 1
  • 7
  • 1
    Have a read of this guy's blog posts on Fractals: https://randomascii.wordpress.com/category/fractals/ – Richard Critten Feb 22 '17 at 00:39
  • `long double` is more accurate if it's longer than `double`, which it isn't on many platforms. Check with `sizeof`. The Intel FPU computes in 80 bits. – user207421 Feb 22 '17 at 00:51
  • The Mandelbrot set is non-computable. Which means that at some zoom your computer will give up, regardless of iterations or precision. But you can go to 80-bit doubles or even write your own routines in software., – Malcolm McLean Feb 22 '17 at 00:58
  • @MalcolmMcLean Really, it isn't computable ? Why is that ? Do you have a link to provide about this, please ? – Telokis Feb 22 '17 at 00:59
  • 3
    The reason it is not computable is that it takes an infinite number of iterations to determine whether a point arbitrarily near the boundary is in or out of the set, and you can't close in on it logarithmically either. – Malcolm McLean Feb 22 '17 at 13:46
  • Fixed point arithmetic can help, because the integral part can be assumed to be never larger than 4 (the square of +/- 2, at which the function value will escape). – Weather Vane Feb 22 '17 at 16:02

1 Answers1

1

You should take a look at third party libraries like boost.multiprecision or even GMP.

You can also do it "by hand" but that would be a lot of work. You would have to keep numbers as their string representation and manually make the arithmetic operations yourself.

Telokis
  • 3,399
  • 14
  • 36
  • Thanks for the answers! I will check them. String representation seems to be interesting. I know how addition and subtraction work, but multiplication and division are unknown for me. And if I knew them, I could make other functions with Taylor series e.g. sin, cos, x^y ... (I know I don't need these functions in my program). Logarithm is a question for me because its series converges within 1 radius. – csekri Feb 22 '17 at 01:14
  • If you feel like doing it by hand, go ahead, you'll learn a lot ! – Telokis Feb 22 '17 at 01:15