The decimal
type in C#, .NET's System.Decimal
type, is just a floating point number stored as base-10 instead of base-2 encoding. float
and double
are more typical base-2 floating point numbers. That is, a double
is stored as +/- x * 2^y
while a decimal is stored as +/- x * 10 ^ y
. That's why it does better for, as one example, financial data, which is typically expressed in terms of x * 10^-2
. The IEEE standard 754 (the floating point math standard) calls this "decimal floating point" math, and defines a 32- and 64-bit version of each.
In C++, these types are implemented in the std::decimal
namespace, and are called std::decimal::decimal32
and std::decimal::decimal64
, in the <decimal>
header. If Borland C++ builder has such a type, you will find it there. GNU's C++ library includes this header but, AFAIK it's not actually part of the standard yet, so BCB may not have it. If that's the case, you'll need to use a third-party library. @dash's example of Intel's Decimal Floating Point library is probably the best known such library, though a Google search for IEEE 754 Decimal
should turn up others if, for some reason, you need them.