Decimal | CF 1.0, ECMA 1.0, serializable |
System (mscorlib.dll) | struct |
This simple value type is
commonly used for financial
calculations, which can preserve a significant number of fractional
digits with no round-off error. Decimals are stored as 12-byte signed
integers scaled by a variable power of 10. This means that a decimal
data type can effectively hold 28 significant digits without losing
any information. With a scale of 0 (no decimal places), the largest
possible value is approximately
7.92x1028. This type is
available in C# through the decimal alias.
public struct Decimal : IFormattable, IComparable, IConvertible {
// Public Constructors
public Decimal(double value);
public Decimal(int value);
public Decimal(int[ ] bits);
public Decimal(int lo, int mid, int hi, bool isNegative, byte scale);
public Decimal(long value);
public Decimal(float value);
public Decimal(uint value);
public Decimal(ulong value);
// Public Static Fields
public static readonly decimal MaxValue;
// =79228162514264337593543950335
public static readonly decimal MinusOne;
// =-1
public static readonly decimal MinValue;
// =-79228162514264337593543950335
public static readonly decimal One;
// =1
public static readonly decimal Zero;
// =0
// Public Static Methods
public static decimal Add(decimal d1, decimal d2);
public static int Compare(decimal d1, decimal d2);
public static decimal Divide(decimal d1, decimal d2);
public static bool Equals(decimal d1, decimal d2);
public static decimal Floor(decimal d);
public static decimal FromOACurrency(long cy);
public static int[ ] GetBits(decimal d);
public static decimal Multiply(decimal d1, decimal d2);
public static decimal Negate(decimal d);
public static decimal Parse(string s);
public static decimal Parse(string s, IFormatProvider provider);
public static decimal Parse(string s, System.Globalization.NumberStyles style);
public static decimal Parse(string s, System.Globalization.NumberStyles style,
IFormatProvider provider);
public static decimal Remainder(decimal d1, decimal d2);
public static decimal Round(decimal d, int decimals);
public static decimal Subtract(decimal d1, decimal d2);
public static byte ToByte(decimal value);
public static double ToDouble(decimal d);
public static short ToInt16(decimal value);
public static int ToInt32(decimal d);
public static long ToInt64(decimal d);
public static long ToOACurrency(decimal value);
public static sbyte ToSByte(decimal value);
public static float ToSingle(decimal d);
public static ushort ToUInt16(decimal value);
public static uint ToUInt32(decimal d);
public static ulong ToUInt64(decimal d);
public static decimal Truncate(decimal d);
public static decimal operator %(decimal d1, decimal d2);
public static decimal operator ,*(decimal d1, decimal d2);
public static decimal operator /(decimal d1, decimal d2);
public static decimal operator--(decimal d);
public static decimal operator -(decimal d);
public static decimal operator -(decimal d1, decimal d2);
public static decimal operator +(decimal d);
public static decimal operator +(decimal d1, decimal d2);
public static decimal operator ++(decimal d);
public static bool operator !=(decimal d1, decimal d2);
public static bool operator <(decimal d1, decimal d2);
public static bool operator <=(decimal d1, decimal d2);
public static bool operator = =(decimal d1, decimal d2);
public static bool operator >(decimal d1, decimal d2);
public static bool operator >=(decimal d1, decimal d2);
public static explicit operator byte(decimal value);
public static explicit operator char(decimal value);
public static explicit operator decimal(double value);
public static explicit operator decimal(float value);
public static explicit operator double(decimal value);
public static explicit operator short(decimal value);
public static explicit operator int(decimal value);
public static explicit operator long(decimal value);
public static explicit operator sbyte(decimal value);
public static explicit operator float(decimal value);
public static explicit operator ushort(decimal value);
public static explicit operator uint(decimal value);
public static explicit operator ulong(decimal value);
public static implicit operator decimal(byte value);
public static implicit operator decimal(char value);
public static implicit operator decimal(short value);
public static implicit operator decimal(int value);
public static implicit operator decimal(long value);
public static implicit operator decimal(sbyte value);
public static implicit operator decimal(ushort value);
public static implicit operator decimal(uint value);
public static implicit operator decimal(ulong value);
// Public Instance Methods
public int CompareTo(object value);
// implements IComparable
public override bool Equals(object value);
// overrides ValueType
public override int GetHashCode( );
// overrides ValueType
public TypeCode GetTypeCode( );
// implements IConvertible
public override string ToString( );
// overrides ValueType
public string ToString(IFormatProvider provider);
// implements IConvertible
public string ToString(string format);
public string ToString(string format, IFormatProvider provider)
// implements IFormattable
}
Hierarchy
Object
ValueType
Decimal(IFormattable, IComparable,
IConvertible)
Returned By
Convert.ToDecimal( ),
IConvertible.ToDecimal( ),
System.IO.BinaryReader.ReadDecimal( ),
System.Runtime.InteropServices.CurrencyWrapper.WrappedObject,
System.Runtime.Serialization.FormatterConverter.ToDecimal(
),
System.Runtime.Serialization.IFormatterConverter.ToDecimal(
),
System.Runtime.Serialization.SerializationInfo.GetDecimal(
), System.Xml.XmlConvert.ToDecimal( )
Passed To
Multiple types
|