Status of improved Decimal support?
-
Monday, July 23, 2012 11:00 AM
What are the current plans for improving the support for the decimal datatype (such as adding missing functions to System.Math)?
We are using decimal to store financial information and will probably use it to perform some calculations, but not beeing able to use exp,log etc without casting back and forth to double etc makes things a lot less straightforward than it should be.
I found the following feedback on this from 2004 and 2006, but surley you must be able to improve it now after 6-8 years?
* A (still open) feature requst for VS 2005 that was to be looked into after VS 2005 release: https://connect.microsoft.com/VisualStudio/feedback/details/94548/math-pow-method-should-have-an-overload-for-decimal
* A thread from back in 2006 (http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/753b6659-4a8a-4389-b805-126ae670aba9/) it was stated that Math.Sqrt was not supported since MSVCRT did only support 64bit floating points, but maybe there are some of the missing functions that can be added more efficiently today than in 2006?
Update with some further results on the topic of decimal support:
* In 2008 the IEEE 754 introduced among other things decimal128 (see http://en.wikipedia.org/wiki/IEEE_754-2008).* Support for the different decimal datatypes are beeing standardized in a techincal report for c (http://www.open-std.org/jtc1/sc22/wg14/www/projects#24732) and c++ (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2849.pdf) and these both include math functions with enought precision also there are several request for MSSQL to support the new types in the next release, and at least they "should look into it" so if you don't have the required code base yet you should be able to get someone start working on decimal128 support which in the end hopfully can provide us with richer functionality for system.decimal (and maybe even an implementation for decimal128 in .net with at least theoretical hardware support :) ).
* Decimal support can also be optained from intel http://software.intel.com/en-us/articles/intel-decimal-floating-point-math-library/
/Daniel Svensson
- Edited by Daniel_Svensson Monday, July 23, 2012 1:07 PM
- Changed Type Mike FengMicrosoft Contingent Staff, Moderator Tuesday, July 24, 2012 9:09 AM feature request
All Replies
-
Monday, July 23, 2012 11:38 AM
To extend Daniel's question, in some applications the precision of double is not enough and therefore just casting back and forth between double and decimal won't cut it either.
Sure it is possible to use Newton-Raphson with the value from the double-base equivalent as starting point or use expansion series (in combination with a Horner scheme) for both exp and log, but is it extremely inefficient for large value sets.
A "pure" decimal based version would be preferable if possible :D
-
Tuesday, July 24, 2012 9:11 AMModerator
Hi Daniel,
Welcome to the MSDN Forum.
Since this is a feature request, I changed it to discussion. Thank you for your understanding and support.
Best regards,
Mike Feng
MSDN Community Support | Feedback to us
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
-
Thursday, July 26, 2012 12:01 PM
Since this is a feature request, I changed it to discussion. Thank you for your understanding and support.
Actually it was a question to the BCL team if they have it on their agenda at all?
But your are right that it is also a request for them to add it to their todo list or bump it up a notch since having full "decimal128" support (the iso/ecma standard allows decimal to conform to decimal128, but the msdn specs limits both the precision and usefullness).
/Daniel Svensson

