Question

Does decimal math use the FPU?

I would think that the answer is yes, but I'm not sure, since a decimal is not a floating point, but a fixed precision number.

I'm looking mostly for .NET, but a general answer would be useful too.

Was it helpful?

Solution

With regards to .NET and more specifically C#, no, System.Decimal does not use the FPU because the type is emulated in software.

Also, System.Decimal is a floating point number, not a fixed precision number like commonly found in a database. The type is actually a decimal floating point that uses 10 for its base as opposed to a binary floating point (i.e. System.Single or System.Double) which uses 2 as its base. It still has the same precision problems if you attempt to store a fraction that cannot be exactly represented, for example, 1/3.

OTHER TIPS

Yes, modern languages in general support floating point math and integer math, and that's it; there's no direct support for fixed point, BCD, etc. Floating-point math is going to be done using floating-point processor instructions; modern architectures don't include a separate FPU.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top