问题
I'm working on a new version of my Mandelbrot screensaver and I'm running out of floating point accuracy - simple double values don't have enough significant figures for my needs.
More significant figures = greater levels of zooming into the fractal
Back when I wrote a version of this screensaver in Delphi 7, I used the extended floating point type, 80 bits in size.
In .NET, I could switch to decimal, but the performance hit for this is terrible, slowing down fractal generation by a factor of 20 or so.
Is there any equivalent of extended for .NET? Or, alternatively, are there any numeric types with higher precision than double that still use the FPU for evaluation and therefore don't have the high performance hit of decimal?
Update
My screensaver already manages to zoom into the fractal by many (many!) orders of magnitude; currently it resets to the base fractal only when the numeric type in use is unable to separate the ordinates for adjacent pixels. The extra 16 bits of precision from the double-extended improvement would give me close to 16 more doublings of size.
As to performance, my algorithm already manages to eliminate 95-99% of the math required (as compared to a naive implementation that calculates many pixels), while retaining the integrity of the fractal.
回答1:
On 64-bit platforms, the
Extended
type is an alias for Double, which is only 8 bytes. On 32-bit platforms, anExtended
number is represented as 10 bytes (80 bits).
That means even your Delphi program may not perform well in 64bit platforms.
If you need a numeric data type with more than 64bits then go for decimal
and optimize your algorithms to improve performance.
来源:https://stackoverflow.com/questions/12549000/any-equivalent-of-extended-for-c