且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

的"任何同等;扩展"对于C#?

更新时间:2022-12-08 19:41:13


在64位平台上,扩展类型是双重的别名,其中
只有8个字节。在32位平台上,一个扩展号表示为10个字节(80位)。


块引用>

这意味着,即使你的Delphi程序可能无法在64位平台上运行良好。



如果你需要一个数字数据类型比64位更然后去小数和优化算法来提高性能。


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.

On 64-bit platforms, the Extended type is an alias for Double, which is only 8 bytes. On 32-bit platforms, an Extended 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.