Floating point performance (decimal vs double)

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

Hi-

I am developing a WinForms app with the dotnet 2.0 framework that
manipulates GPS data. Some of the algoritms are pretty math intensive,
with Sin, Cos, Log, etc.

I originally developed the app using the type "double" for all my data
points, but as an experiment, I changed the types to "decimal" and was
surprised to see that the performance improved. Is this expected?
FYI, I am running this app on a Turion ML-34 (1.8Ghz 1MB cache), so my
fp unit should be pretty good.

Are there any good resources on tweaking floating point performance in
dotnet? I was very surprised to see decimal out perform double, so I'm
wondering if I'm missing something else. For example, what about
exetended floating point types? I imagine that this may be even faster
since it would use the SSE unit of the chip.

Any input is appreciated.

-jeff
 
Hi,

Some food for thought - decimal is actually a *fixed* point data type (as
opposed to *floating* point). And the former has been known as a faster one
since times of ID Software's Quake 1 (which used fixed point math for 3D
calculations all the way).

Given you are working with coordinates, which are unlikely to have a large
number of digits after the decimal point (I might be wrong though), you
might be better off using the decimal data type (and having a benefit of
predicted precision of all your calculations).
 
Back
Top