2

I am trying to make a Mandelbrot fractal zoom in java, but when the zoom increases, the double does not have enought precision and the image gets pixelated and I can not zoom more. I want to increase the precision or use another data type that allows me to that. Thank you.

  • 3
    Does this answer your question? [Java Mandelbrot visualization questions on zooming and coloring](https://stackoverflow.com/questions/53381336/java-mandelbrot-visualization-questions-on-zooming-and-coloring) – akuzminykh Jun 14 '20 at 01:02

1 Answers1

2

You can use the BigDecimal class.

For example -

    BigDecimal a = new BigDecimal("0.000000000000000000000000000005");
    BigDecimal b = new BigDecimal("0.06");
    BigDecimal c = b.subtract(a);
    System.out.println(c);

EDIT: You can control the number of digits to the right of the decimal point using the setScale() method

    BigDecimal p=a.setScale(29, BigDecimal.ROUND_HALF_UP);
Alim Ul Gias
  • 6,351
  • 2
  • 28
  • 39