Very small numbers
I am writing a Mandelbrot viewer. Everything works except when you get to a very high zoom the image starts to pixilate about at about zoom 10^(-14). I am guessing because i run out of memory in my double vars. What can i use that will allow me to use very sma开发者_JAVA技巧ll numbers?
I need to use the java.lang.Math class and i dont think that supports bigdecimal
If you really need arbitrary precision, your best option is probably BigDecimal
.
If you're concerned with efficiency, I suspect you would be better off trying to scale your values and keep them in the neighborhood of 1.0.
The following discussion seems quite informative: High-Performance Arbitrary precision numerical calculations in Java (Mandelbrot Set!).
I know nothing about how you're doing it, but if you can do your calculations in log-space you can deal with tiny numbers much better (since they become large negative numbers).
http://download.oracle.com/javase/1,5.0/docs/api/java/math/BigDecimal.html
You can use Java's BigDecimal
.
精彩评论