Note that I am not looking for something opinion based or some third party library - I merely want confirmation that nothing is planned (or pointers to some discussion by the powers to be). I tried google and fail to find anything, so it looks like I am heading towards a "write my own implementation in C++/CLI using the Intel library").
Like many I am working with financial numbers and that means floats are terrifically problematic. At the same time, the .NET decimal is a beast - slow but also large (128 bit large) Which makes it inefficient to use when you amass hundreds of thousands of them and want them in a struct with some more information.
IEEE 754 defines 3 decimal types that likely have coming support in hardware in mainstream procesors (they already have in less commmon ones, the Power Series for example), for 32, 64 and 128 bit. There is an optimized Intel library to do decimal mathematics and it is possibly quite likely that at one point at least the easier mathematics will be in hardware.
All I could find is an ancient discussion in the Annotated C# Standard about interop between .NET decimal and the IEEE then proposed standard and that it was rejected but made in a way it can be identified whether a bitfield is either a .NET decimal or an bit inveted IEEE decimal 128.
Since then, many years have passed. Now IEEE 754 : 2008 is finished and - I wonder whether there is anything official that has been published about how that is to go on. As I said, the .NET decimal is slow and has zero chance to ever get hardware acceleration - and i is unwiedely big.
So, anyone knows anything in a blog or something? Note - it has to be official or referring to, I am not here for opinions that are from people unrelated to the .NET langauges or BCL teams. THis is about a canonical resource whether additional data types are considered in the future... possibly for a .NET 5.0 / 6.0 timeframe.
The classes from the Decimal TR are not implemented for all compilers. Some compilers, e.g., gcc, implement the C Decimal TR and provide the corresponding extensions in C++, too. In the past there was an open source implementation for the C++ Decimal TR available but I failed to locate it.
There is also the Bloomberg bde library which has bdldfp_decimal.h and bdldfp_decimalutil.h. The classes from the Decimal TR are not implemented for all compilers. Some compilers, e.g., gcc, implement the C Decimal TR and provide the corresponding extensions in C++, too.
The decimals used by gcc are not in the library! There are certainly no decimal classes in libstdc++. The logic is built into the compiler. If you use gcc you can configure it when building gcc to include decimal support (by default it isn't included).
C++ doesn't have any decimal types built-in. You'll need a 3rd-party library. – Cory Nelson Dec 31 '12 at 0:11 Upvote this answer if you find it clear and useful. Downvote this answer if you find it unclear or not useful. Say thanks for this answer. 0 others reacted with thanks. Show activity on this post.
I've programmed financial software and completely understand why simple integers are not enough.
It's exceedingly difficult to prove a negative but here goes:
http://social.msdn.microsoft.com/forums/vstudio/en-US/48c698db-d602-4f83-92bb-1c0506d58a78/ieee754 In short if the language doesn't require it .NET doesn't care.
Finding a language that requires it: Looks like Dietmar Kühl was going to attempt to add a decimal to c but failed to submit in time: C++ decimal data types
Despite that IEEE is still doing plenty of work on decimals. Try these google searches:
Decimal site:ieee.org and limit it to the last month. Decimal Draft site:ieee.org and limit it to the last year.
If it's in the hardware the software will eventually have it. Assembly will let you do anything the hardware can do but if you're stuck in a virtual machine that is ignorant of the new op codes I'm not sure you can do anything but emulate.
So for now I don't see much more than you do. Sorry.
Oh and you can tell supercat from me that (a+b)+c = a+(b+c) isn't anymore guaranteed on integers than it is on floating points. Bits can also fall off the left end of a non infinite sized integer number. 'a' might have been negative and saved you from the overflow if you had added it first.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With