mscorlib(4.0.0.0) API with additions
Decimal.cs
7 using System.Security;
8 
9 namespace System
10 {
12  [Serializable]
13  [ComVisible(true)]
14  [NonVersionable]
15  [__DynamicallyInvokable]
17  {
18  private const int SignMask = int.MinValue;
19 
20  private const byte DECIMAL_NEG = 128;
21 
22  private const byte DECIMAL_ADD = 0;
23 
24  private const int ScaleMask = 16711680;
25 
26  private const int ScaleShift = 16;
27 
28  private const int MaxInt32Scale = 9;
29 
30  private static uint[] Powers10 = new uint[10]
31  {
32  1u,
33  10u,
34  100u,
35  1000u,
36  10000u,
37  100000u,
38  1000000u,
39  10000000u,
40  100000000u,
41  1000000000u
42  };
43 
45  [__DynamicallyInvokable]
46  public const decimal Zero = 0m;
47 
49  [__DynamicallyInvokable]
50  public const decimal One = 1m;
51 
53  [__DynamicallyInvokable]
54  public const decimal MinusOne = -1m;
55 
57  [__DynamicallyInvokable]
58  public const decimal MaxValue = decimal.MaxValue;
59 
61  [__DynamicallyInvokable]
62  public const decimal MinValue = decimal.MinValue;
63 
64  private const decimal NearNegativeZero = -0.000000000000000000000000001m;
65 
66  private const decimal NearPositiveZero = 0.000000000000000000000000001m;
67 
68  private int flags;
69 
70  private int hi;
71 
72  private int lo;
73 
74  private int mid;
75 
78  [__DynamicallyInvokable]
79  public Decimal(int value)
80  {
81  int num = value;
82  if (num >= 0)
83  {
84  flags = 0;
85  }
86  else
87  {
88  flags = int.MinValue;
89  num = -num;
90  }
91  lo = num;
92  mid = 0;
93  hi = 0;
94  }
95 
98  [CLSCompliant(false)]
99  [__DynamicallyInvokable]
100  public Decimal(uint value)
101  {
102  flags = 0;
103  lo = (int)value;
104  mid = 0;
105  hi = 0;
106  }
107 
110  [__DynamicallyInvokable]
111  public Decimal(long value)
112  {
113  long num = value;
114  if (num >= 0)
115  {
116  flags = 0;
117  }
118  else
119  {
120  flags = int.MinValue;
121  num = -num;
122  }
123  lo = (int)num;
124  mid = (int)(num >> 32);
125  hi = 0;
126  }
127 
130  [CLSCompliant(false)]
131  [__DynamicallyInvokable]
132  public Decimal(ulong value)
133  {
134  flags = 0;
135  lo = (int)value;
136  mid = (int)(value >> 32);
137  hi = 0;
138  }
139 
145  [MethodImpl(MethodImplOptions.InternalCall)]
146  [SecuritySafeCritical]
147  [__DynamicallyInvokable]
148  public extern Decimal(float value);
149 
155  [MethodImpl(MethodImplOptions.InternalCall)]
156  [SecuritySafeCritical]
157  [__DynamicallyInvokable]
158  public extern Decimal(double value);
159 
160  internal Decimal(Currency value)
161  {
162  decimal num = Currency.ToDecimal(value);
163  lo = num.lo;
164  mid = num.mid;
165  hi = num.hi;
166  flags = num.flags;
167  }
168 
172  [__DynamicallyInvokable]
173  public static long ToOACurrency(decimal value)
174  {
175  return new Currency(value).ToOACurrency();
176  }
177 
181  [__DynamicallyInvokable]
182  public static decimal FromOACurrency(long cy)
183  {
184  return Currency.ToDecimal(Currency.FromOACurrency(cy));
185  }
186 
192  [__DynamicallyInvokable]
193  public Decimal(int[] bits)
194  {
195  lo = 0;
196  mid = 0;
197  hi = 0;
198  flags = 0;
199  SetBits(bits);
200  }
201 
202  private void SetBits(int[] bits)
203  {
204  if (bits == null)
205  {
206  throw new ArgumentNullException("bits");
207  }
208  if (bits.Length == 4)
209  {
210  int num = bits[3];
211  if ((num & 0x7F00FFFF) == 0 && (num & 0xFF0000) <= 1835008)
212  {
213  lo = bits[0];
214  mid = bits[1];
215  hi = bits[2];
216  flags = num;
217  return;
218  }
219  }
220  throw new ArgumentException(Environment.GetResourceString("Arg_DecBitCtor"));
221  }
222 
232  [__DynamicallyInvokable]
233  public Decimal(int lo, int mid, int hi, bool isNegative, byte scale)
234  {
235  if (scale > 28)
236  {
237  throw new ArgumentOutOfRangeException("scale", Environment.GetResourceString("ArgumentOutOfRange_DecimalScale"));
238  }
239  this.lo = lo;
240  this.mid = mid;
241  this.hi = hi;
242  flags = scale << 16;
243  if (isNegative)
244  {
245  flags |= int.MinValue;
246  }
247  }
248 
249  [OnSerializing]
250  private void OnSerializing(StreamingContext ctx)
251  {
252  try
253  {
254  SetBits(GetBits(this));
255  }
256  catch (ArgumentException innerException)
257  {
258  throw new SerializationException(Environment.GetResourceString("Overflow_Decimal"), innerException);
259  }
260  }
261 
266  {
267  try
268  {
269  SetBits(GetBits(this));
270  }
271  catch (ArgumentException innerException)
272  {
273  throw new SerializationException(Environment.GetResourceString("Overflow_Decimal"), innerException);
274  }
275  }
276 
277  private Decimal(int lo, int mid, int hi, int flags)
278  {
279  if ((flags & 0x7F00FFFF) == 0 && (flags & 0xFF0000) <= 1835008)
280  {
281  this.lo = lo;
282  this.mid = mid;
283  this.hi = hi;
284  this.flags = flags;
285  return;
286  }
287  throw new ArgumentException(Environment.GetResourceString("Arg_DecBitCtor"));
288  }
289 
290  internal static decimal Abs(decimal d)
291  {
292  return new decimal(d.lo, d.mid, d.hi, d.flags & int.MaxValue);
293  }
294 
300  [SecuritySafeCritical]
301  [__DynamicallyInvokable]
302  public static decimal Add(decimal d1, decimal d2)
303  {
304  FCallAddSub(ref d1, ref d2, 0);
305  return d1;
306  }
307 
308  [MethodImpl(MethodImplOptions.InternalCall)]
309  [SecurityCritical]
310  private static extern void FCallAddSub(ref decimal d1, ref decimal d2, byte bSign);
311 
312  [MethodImpl(MethodImplOptions.InternalCall)]
313  [SecurityCritical]
314  private static extern void FCallAddSubOverflowed(ref decimal d1, ref decimal d2, byte bSign, ref bool overflowed);
315 
319  [__DynamicallyInvokable]
320  public static decimal Ceiling(decimal d)
321  {
322  return -Floor(-d);
323  }
324 
332  [SecuritySafeCritical]
333  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
334  [__DynamicallyInvokable]
335  public static int Compare(decimal d1, decimal d2)
336  {
337  return FCallCompare(ref d1, ref d2);
338  }
339 
340  [MethodImpl(MethodImplOptions.InternalCall)]
341  [SecurityCritical]
342  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
343  private static extern int FCallCompare(ref decimal d1, ref decimal d2);
344 
351  [SecuritySafeCritical]
352  public int CompareTo(object value)
353  {
354  if (value == null)
355  {
356  return 1;
357  }
358  if (!(value is decimal))
359  {
360  throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDecimal"));
361  }
362  decimal d = (decimal)value;
363  return FCallCompare(ref this, ref d);
364  }
365 
369  [SecuritySafeCritical]
370  [__DynamicallyInvokable]
371  public int CompareTo(decimal value)
372  {
373  return FCallCompare(ref this, ref value);
374  }
375 
383  [SecuritySafeCritical]
384  [__DynamicallyInvokable]
385  public static decimal Divide(decimal d1, decimal d2)
386  {
387  FCallDivide(ref d1, ref d2);
388  return d1;
389  }
390 
391  [MethodImpl(MethodImplOptions.InternalCall)]
392  [SecurityCritical]
393  private static extern void FCallDivide(ref decimal d1, ref decimal d2);
394 
395  [MethodImpl(MethodImplOptions.InternalCall)]
396  [SecurityCritical]
397  private static extern void FCallDivideOverflowed(ref decimal d1, ref decimal d2, ref bool overflowed);
398 
403  [SecuritySafeCritical]
404  [__DynamicallyInvokable]
405  public override bool Equals(object value)
406  {
407  if (value is decimal)
408  {
409  decimal d = (decimal)value;
410  return FCallCompare(ref this, ref d) == 0;
411  }
412  return false;
413  }
414 
419  [SecuritySafeCritical]
420  [__DynamicallyInvokable]
421  public bool Equals(decimal value)
422  {
423  return FCallCompare(ref this, ref value) == 0;
424  }
425 
428  [MethodImpl(MethodImplOptions.InternalCall)]
429  [SecuritySafeCritical]
430  [__DynamicallyInvokable]
431  public override extern int GetHashCode();
432 
438  [SecuritySafeCritical]
439  [__DynamicallyInvokable]
440  public static bool Equals(decimal d1, decimal d2)
441  {
442  return FCallCompare(ref d1, ref d2) == 0;
443  }
444 
448  [SecuritySafeCritical]
449  [__DynamicallyInvokable]
450  public static decimal Floor(decimal d)
451  {
452  FCallFloor(ref d);
453  return d;
454  }
455 
456  [MethodImpl(MethodImplOptions.InternalCall)]
457  [SecurityCritical]
458  private static extern void FCallFloor(ref decimal d);
459 
462  [SecuritySafeCritical]
463  [__DynamicallyInvokable]
464  public override string ToString()
465  {
466  return Number.FormatDecimal(this, null, NumberFormatInfo.CurrentInfo);
467  }
468 
474  [SecuritySafeCritical]
475  [__DynamicallyInvokable]
476  public string ToString(string format)
477  {
478  return Number.FormatDecimal(this, format, NumberFormatInfo.CurrentInfo);
479  }
480 
484  [SecuritySafeCritical]
485  [__DynamicallyInvokable]
486  public string ToString(IFormatProvider provider)
487  {
488  return Number.FormatDecimal(this, null, NumberFormatInfo.GetInstance(provider));
489  }
490 
497  [SecuritySafeCritical]
498  [__DynamicallyInvokable]
499  public string ToString(string format, IFormatProvider provider)
500  {
501  return Number.FormatDecimal(this, format, NumberFormatInfo.GetInstance(provider));
502  }
503 
513  [__DynamicallyInvokable]
514  public static decimal Parse(string s)
515  {
516  return Number.ParseDecimal(s, NumberStyles.Number, NumberFormatInfo.CurrentInfo);
517  }
518 
532  [__DynamicallyInvokable]
533  public static decimal Parse(string s, NumberStyles style)
534  {
535  NumberFormatInfo.ValidateParseStyleFloatingPoint(style);
536  return Number.ParseDecimal(s, style, NumberFormatInfo.CurrentInfo);
537  }
538 
549  [__DynamicallyInvokable]
550  public static decimal Parse(string s, IFormatProvider provider)
551  {
552  return Number.ParseDecimal(s, NumberStyles.Number, NumberFormatInfo.GetInstance(provider));
553  }
554 
569  [__DynamicallyInvokable]
570  public static decimal Parse(string s, NumberStyles style, IFormatProvider provider)
571  {
572  NumberFormatInfo.ValidateParseStyleFloatingPoint(style);
573  return Number.ParseDecimal(s, style, NumberFormatInfo.GetInstance(provider));
574  }
575 
581  [__DynamicallyInvokable]
582  public static bool TryParse(string s, out decimal result)
583  {
584  return Number.TryParseDecimal(s, NumberStyles.Number, NumberFormatInfo.CurrentInfo, out result);
585  }
586 
597  [__DynamicallyInvokable]
598  public static bool TryParse(string s, NumberStyles style, IFormatProvider provider, out decimal result)
599  {
600  NumberFormatInfo.ValidateParseStyleFloatingPoint(style);
601  return Number.TryParseDecimal(s, style, NumberFormatInfo.GetInstance(provider), out result);
602  }
603 
607  [__DynamicallyInvokable]
608  public static int[] GetBits(decimal d)
609  {
610  return new int[4]
611  {
612  d.lo,
613  d.mid,
614  d.hi,
615  d.flags
616  };
617  }
618 
619  internal static void GetBytes(decimal d, byte[] buffer)
620  {
621  buffer[0] = (byte)d.lo;
622  buffer[1] = (byte)(d.lo >> 8);
623  buffer[2] = (byte)(d.lo >> 16);
624  buffer[3] = (byte)(d.lo >> 24);
625  buffer[4] = (byte)d.mid;
626  buffer[5] = (byte)(d.mid >> 8);
627  buffer[6] = (byte)(d.mid >> 16);
628  buffer[7] = (byte)(d.mid >> 24);
629  buffer[8] = (byte)d.hi;
630  buffer[9] = (byte)(d.hi >> 8);
631  buffer[10] = (byte)(d.hi >> 16);
632  buffer[11] = (byte)(d.hi >> 24);
633  buffer[12] = (byte)d.flags;
634  buffer[13] = (byte)(d.flags >> 8);
635  buffer[14] = (byte)(d.flags >> 16);
636  buffer[15] = (byte)(d.flags >> 24);
637  }
638 
639  internal static decimal ToDecimal(byte[] buffer)
640  {
641  int num = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
642  int num2 = buffer[4] | (buffer[5] << 8) | (buffer[6] << 16) | (buffer[7] << 24);
643  int num3 = buffer[8] | (buffer[9] << 8) | (buffer[10] << 16) | (buffer[11] << 24);
644  int num4 = buffer[12] | (buffer[13] << 8) | (buffer[14] << 16) | (buffer[15] << 24);
645  return new decimal(num, num2, num3, num4);
646  }
647 
648  private static void InternalAddUInt32RawUnchecked(ref decimal value, uint i)
649  {
650  uint num = (uint)value.lo;
651  uint num2 = (uint)(value.lo = (int)(num + i));
652  if (num2 < num || num2 < i)
653  {
654  num = (uint)value.mid;
655  num2 = (uint)(value.mid = (int)(num + 1));
656  if (num2 < num || num2 < 1)
657  {
658  value.hi++;
659  }
660  }
661  }
662 
663  private static uint InternalDivRemUInt32(ref decimal value, uint divisor)
664  {
665  uint num = 0u;
666  if (value.hi != 0)
667  {
668  ulong num2 = (uint)value.hi;
669  value.hi = (int)(num2 / divisor);
670  num = (uint)(num2 % divisor);
671  }
672  if (value.mid != 0 || num != 0)
673  {
674  ulong num2 = ((ulong)num << 32) | (uint)value.mid;
675  value.mid = (int)(num2 / divisor);
676  num = (uint)(num2 % divisor);
677  }
678  if (value.lo != 0 || num != 0)
679  {
680  ulong num2 = ((ulong)num << 32) | (uint)value.lo;
681  value.lo = (int)(num2 / divisor);
682  num = (uint)(num2 % divisor);
683  }
684  return num;
685  }
686 
687  private static void InternalRoundFromZero(ref decimal d, int decimalCount)
688  {
689  int num = (d.flags & 0xFF0000) >> 16;
690  int num2 = num - decimalCount;
691  if (num2 > 0)
692  {
693  uint num4;
694  uint num5;
695  do
696  {
697  int num3 = (num2 > 9) ? 9 : num2;
698  num4 = Powers10[num3];
699  num5 = InternalDivRemUInt32(ref d, num4);
700  num2 -= num3;
701  }
702  while (num2 > 0);
703  if (num5 >= num4 >> 1)
704  {
705  InternalAddUInt32RawUnchecked(ref d, 1u);
706  }
707  d.flags = (((decimalCount << 16) & 0xFF0000) | (d.flags & int.MinValue));
708  }
709  }
710 
711  [SecuritySafeCritical]
712  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
713  internal static decimal Max(decimal d1, decimal d2)
714  {
715  if (FCallCompare(ref d1, ref d2) < 0)
716  {
717  return d2;
718  }
719  return d1;
720  }
721 
722  [SecuritySafeCritical]
723  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
724  internal static decimal Min(decimal d1, decimal d2)
725  {
726  if (FCallCompare(ref d1, ref d2) >= 0)
727  {
728  return d2;
729  }
730  return d1;
731  }
732 
740  [__DynamicallyInvokable]
741  public static decimal Remainder(decimal d1, decimal d2)
742  {
743  d2.flags = ((d2.flags & int.MaxValue) | (d1.flags & int.MinValue));
744  if (Abs(d1) < Abs(d2))
745  {
746  return d1;
747  }
748  d1 -= d2;
749  if (d1 == Zero)
750  {
751  d1.flags = ((d1.flags & int.MaxValue) | (d2.flags & int.MinValue));
752  }
753  decimal d3 = Truncate(d1 / d2);
754  decimal d4 = d3 * d2;
755  decimal num = d1 - d4;
756  if ((d1.flags & int.MinValue) != (num.flags & int.MinValue))
757  {
758  if (-0.000000000000000000000000001m <= num && num <= 0.000000000000000000000000001m)
759  {
760  num.flags = ((num.flags & int.MaxValue) | (d1.flags & int.MinValue));
761  }
762  else
763  {
764  num += d2;
765  }
766  }
767  return num;
768  }
769 
775  [SecuritySafeCritical]
776  [__DynamicallyInvokable]
777  public static decimal Multiply(decimal d1, decimal d2)
778  {
779  FCallMultiply(ref d1, ref d2);
780  return d1;
781  }
782 
783  [MethodImpl(MethodImplOptions.InternalCall)]
784  [SecurityCritical]
785  private static extern void FCallMultiply(ref decimal d1, ref decimal d2);
786 
787  [MethodImpl(MethodImplOptions.InternalCall)]
788  [SecurityCritical]
789  private static extern void FCallMultiplyOverflowed(ref decimal d1, ref decimal d2, ref bool overflowed);
790 
794  [__DynamicallyInvokable]
795  public static decimal Negate(decimal d)
796  {
797  return new decimal(d.lo, d.mid, d.hi, d.flags ^ int.MinValue);
798  }
799 
804  public static decimal Round(decimal d)
805  {
806  return Round(d, 0);
807  }
808 
815  [SecuritySafeCritical]
816  [__DynamicallyInvokable]
817  public static decimal Round(decimal d, int decimals)
818  {
819  FCallRound(ref d, decimals);
820  return d;
821  }
822 
830  public static decimal Round(decimal d, MidpointRounding mode)
831  {
832  return Round(d, 0, mode);
833  }
834 
845  [SecuritySafeCritical]
846  public static decimal Round(decimal d, int decimals, MidpointRounding mode)
847  {
848  if (decimals < 0 || decimals > 28)
849  {
850  throw new ArgumentOutOfRangeException("decimals", Environment.GetResourceString("ArgumentOutOfRange_DecimalRound"));
851  }
852  switch (mode)
853  {
854  default:
855  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidEnumValue", mode, "MidpointRounding"), "mode");
856  case MidpointRounding.ToEven:
857  FCallRound(ref d, decimals);
858  break;
859  case MidpointRounding.AwayFromZero:
860  InternalRoundFromZero(ref d, decimals);
861  break;
862  }
863  return d;
864  }
865 
866  [MethodImpl(MethodImplOptions.InternalCall)]
867  [SecurityCritical]
868  private static extern void FCallRound(ref decimal d, int decimals);
869 
875  [SecuritySafeCritical]
876  [__DynamicallyInvokable]
877  public static decimal Subtract(decimal d1, decimal d2)
878  {
879  FCallAddSub(ref d1, ref d2, 128);
880  return d1;
881  }
882 
888  [__DynamicallyInvokable]
889  public static byte ToByte(decimal value)
890  {
891  uint num;
892  try
893  {
894  num = ToUInt32(value);
895  }
896  catch (OverflowException innerException)
897  {
898  throw new OverflowException(Environment.GetResourceString("Overflow_Byte"), innerException);
899  }
900  if (num < 0 || num > 255)
901  {
902  throw new OverflowException(Environment.GetResourceString("Overflow_Byte"));
903  }
904  return (byte)num;
905  }
906 
912  [CLSCompliant(false)]
913  [__DynamicallyInvokable]
914  public static sbyte ToSByte(decimal value)
915  {
916  int num;
917  try
918  {
919  num = ToInt32(value);
920  }
921  catch (OverflowException innerException)
922  {
923  throw new OverflowException(Environment.GetResourceString("Overflow_SByte"), innerException);
924  }
925  if (num < -128 || num > 127)
926  {
927  throw new OverflowException(Environment.GetResourceString("Overflow_SByte"));
928  }
929  return (sbyte)num;
930  }
931 
937  [__DynamicallyInvokable]
938  public static short ToInt16(decimal value)
939  {
940  int num;
941  try
942  {
943  num = ToInt32(value);
944  }
945  catch (OverflowException innerException)
946  {
947  throw new OverflowException(Environment.GetResourceString("Overflow_Int16"), innerException);
948  }
949  if (num < -32768 || num > 32767)
950  {
951  throw new OverflowException(Environment.GetResourceString("Overflow_Int16"));
952  }
953  return (short)num;
954  }
955 
956  [SecuritySafeCritical]
957  internal static Currency ToCurrency(decimal d)
958  {
959  Currency result = default(Currency);
960  FCallToCurrency(ref result, d);
961  return result;
962  }
963 
964  [MethodImpl(MethodImplOptions.InternalCall)]
965  [SecurityCritical]
966  private static extern void FCallToCurrency(ref Currency result, decimal d);
967 
971  [MethodImpl(MethodImplOptions.InternalCall)]
972  [SecuritySafeCritical]
973  [__DynamicallyInvokable]
974  public static extern double ToDouble(decimal d);
975 
976  [MethodImpl(MethodImplOptions.InternalCall)]
977  [SecurityCritical]
978  internal static extern int FCallToInt32(decimal d);
979 
985  [SecuritySafeCritical]
986  [__DynamicallyInvokable]
987  public static int ToInt32(decimal d)
988  {
989  if ((d.flags & 0xFF0000) != 0)
990  {
991  FCallTruncate(ref d);
992  }
993  if (d.hi == 0 && d.mid == 0)
994  {
995  int num = d.lo;
996  if (d.flags >= 0)
997  {
998  if (num >= 0)
999  {
1000  return num;
1001  }
1002  }
1003  else
1004  {
1005  num = -num;
1006  if (num <= 0)
1007  {
1008  return num;
1009  }
1010  }
1011  }
1012  throw new OverflowException(Environment.GetResourceString("Overflow_Int32"));
1013  }
1014 
1020  [SecuritySafeCritical]
1021  [__DynamicallyInvokable]
1022  public static long ToInt64(decimal d)
1023  {
1024  if ((d.flags & 0xFF0000) != 0)
1025  {
1026  FCallTruncate(ref d);
1027  }
1028  if (d.hi == 0)
1029  {
1030  long num = (d.lo & uint.MaxValue) | ((long)d.mid << 32);
1031  if (d.flags >= 0)
1032  {
1033  if (num >= 0)
1034  {
1035  return num;
1036  }
1037  }
1038  else
1039  {
1040  num = -num;
1041  if (num <= 0)
1042  {
1043  return num;
1044  }
1045  }
1046  }
1047  throw new OverflowException(Environment.GetResourceString("Overflow_Int64"));
1048  }
1049 
1055  [CLSCompliant(false)]
1056  [__DynamicallyInvokable]
1057  public static ushort ToUInt16(decimal value)
1058  {
1059  uint num;
1060  try
1061  {
1062  num = ToUInt32(value);
1063  }
1064  catch (OverflowException innerException)
1065  {
1066  throw new OverflowException(Environment.GetResourceString("Overflow_UInt16"), innerException);
1067  }
1068  if (num < 0 || num > 65535)
1069  {
1070  throw new OverflowException(Environment.GetResourceString("Overflow_UInt16"));
1071  }
1072  return (ushort)num;
1073  }
1074 
1080  [SecuritySafeCritical]
1081  [CLSCompliant(false)]
1082  [__DynamicallyInvokable]
1083  public static uint ToUInt32(decimal d)
1084  {
1085  if ((d.flags & 0xFF0000) != 0)
1086  {
1087  FCallTruncate(ref d);
1088  }
1089  if (d.hi == 0 && d.mid == 0)
1090  {
1091  uint num = (uint)d.lo;
1092  if (d.flags >= 0 || num == 0)
1093  {
1094  return num;
1095  }
1096  }
1097  throw new OverflowException(Environment.GetResourceString("Overflow_UInt32"));
1098  }
1099 
1105  [SecuritySafeCritical]
1106  [CLSCompliant(false)]
1107  [__DynamicallyInvokable]
1108  public static ulong ToUInt64(decimal d)
1109  {
1110  if ((d.flags & 0xFF0000) != 0)
1111  {
1112  FCallTruncate(ref d);
1113  }
1114  if (d.hi == 0)
1115  {
1116  ulong num = (uint)d.lo | ((ulong)(uint)d.mid << 32);
1117  if (d.flags >= 0 || num == 0L)
1118  {
1119  return num;
1120  }
1121  }
1122  throw new OverflowException(Environment.GetResourceString("Overflow_UInt64"));
1123  }
1124 
1128  [MethodImpl(MethodImplOptions.InternalCall)]
1129  [SecuritySafeCritical]
1130  [__DynamicallyInvokable]
1131  public static extern float ToSingle(decimal d);
1132 
1136  [SecuritySafeCritical]
1137  [__DynamicallyInvokable]
1138  public static decimal Truncate(decimal d)
1139  {
1140  FCallTruncate(ref d);
1141  return d;
1142  }
1143 
1144  [MethodImpl(MethodImplOptions.InternalCall)]
1145  [SecurityCritical]
1146  private static extern void FCallTruncate(ref decimal d);
1147 
1151  [__DynamicallyInvokable]
1152  public static implicit operator decimal(byte value)
1153  {
1154  return new decimal(value);
1155  }
1156 
1160  [CLSCompliant(false)]
1161  [__DynamicallyInvokable]
1162  public static implicit operator decimal(sbyte value)
1163  {
1164  return new decimal(value);
1165  }
1166 
1170  [__DynamicallyInvokable]
1171  public static implicit operator decimal(short value)
1172  {
1173  return new decimal(value);
1174  }
1175 
1179  [CLSCompliant(false)]
1180  [__DynamicallyInvokable]
1181  public static implicit operator decimal(ushort value)
1182  {
1183  return new decimal(value);
1184  }
1185 
1189  [__DynamicallyInvokable]
1190  public static implicit operator decimal(char value)
1191  {
1192  return new decimal(value);
1193  }
1194 
1198  [__DynamicallyInvokable]
1199  public static implicit operator decimal(int value)
1200  {
1201  return new decimal(value);
1202  }
1203 
1207  [CLSCompliant(false)]
1208  [__DynamicallyInvokable]
1209  public static implicit operator decimal(uint value)
1210  {
1211  return new decimal(value);
1212  }
1213 
1217  [__DynamicallyInvokable]
1218  public static implicit operator decimal(long value)
1219  {
1220  return new decimal(value);
1221  }
1222 
1226  [CLSCompliant(false)]
1227  [__DynamicallyInvokable]
1228  public static implicit operator decimal(ulong value)
1229  {
1230  return new decimal(value);
1231  }
1232 
1239  [__DynamicallyInvokable]
1240  public static explicit operator decimal(float value)
1241  {
1242  return new decimal(value);
1243  }
1244 
1251  [__DynamicallyInvokable]
1252  public static explicit operator decimal(double value)
1253  {
1254  return new decimal(value);
1255  }
1256 
1262  [__DynamicallyInvokable]
1263  public static explicit operator byte(decimal value)
1264  {
1265  return ToByte(value);
1266  }
1267 
1273  [CLSCompliant(false)]
1274  [__DynamicallyInvokable]
1275  public static explicit operator sbyte(decimal value)
1276  {
1277  return ToSByte(value);
1278  }
1279 
1285  [__DynamicallyInvokable]
1286  public static explicit operator char(decimal value)
1287  {
1288  try
1289  {
1290  return (char)ToUInt16(value);
1291  }
1292  catch (OverflowException innerException)
1293  {
1294  throw new OverflowException(Environment.GetResourceString("Overflow_Char"), innerException);
1295  }
1296  }
1297 
1303  [__DynamicallyInvokable]
1304  public static explicit operator short(decimal value)
1305  {
1306  return ToInt16(value);
1307  }
1308 
1314  [CLSCompliant(false)]
1315  [__DynamicallyInvokable]
1316  public static explicit operator ushort(decimal value)
1317  {
1318  return ToUInt16(value);
1319  }
1320 
1326  [__DynamicallyInvokable]
1327  public static explicit operator int(decimal value)
1328  {
1329  return ToInt32(value);
1330  }
1331 
1337  [CLSCompliant(false)]
1338  [__DynamicallyInvokable]
1339  public static explicit operator uint(decimal value)
1340  {
1341  return ToUInt32(value);
1342  }
1343 
1349  [__DynamicallyInvokable]
1350  public static explicit operator long(decimal value)
1351  {
1352  return ToInt64(value);
1353  }
1354 
1360  [CLSCompliant(false)]
1361  [__DynamicallyInvokable]
1362  public static explicit operator ulong(decimal value)
1363  {
1364  return ToUInt64(value);
1365  }
1366 
1370  [__DynamicallyInvokable]
1371  public static explicit operator float(decimal value)
1372  {
1373  return ToSingle(value);
1374  }
1375 
1379  [__DynamicallyInvokable]
1380  public static explicit operator double(decimal value)
1381  {
1382  return ToDouble(value);
1383  }
1384 
1388  [__DynamicallyInvokable]
1389  public static decimal operator +(decimal d)
1390  {
1391  return d;
1392  }
1393 
1397  [__DynamicallyInvokable]
1398  public static decimal operator -(decimal d)
1399  {
1400  return Negate(d);
1401  }
1402 
1407  [__DynamicallyInvokable]
1408  public static decimal operator ++(decimal d)
1409  {
1410  return Add(d, One);
1411  }
1412 
1417  [__DynamicallyInvokable]
1418  public static decimal operator --(decimal d)
1419  {
1420  return Subtract(d, One);
1421  }
1422 
1428  [SecuritySafeCritical]
1429  [__DynamicallyInvokable]
1430  public static decimal operator +(decimal d1, decimal d2)
1431  {
1432  FCallAddSub(ref d1, ref d2, 0);
1433  return d1;
1434  }
1435 
1441  [SecuritySafeCritical]
1442  [__DynamicallyInvokable]
1443  public static decimal operator -(decimal d1, decimal d2)
1444  {
1445  FCallAddSub(ref d1, ref d2, 128);
1446  return d1;
1447  }
1448 
1454  [SecuritySafeCritical]
1455  [__DynamicallyInvokable]
1456  public static decimal operator *(decimal d1, decimal d2)
1457  {
1458  FCallMultiply(ref d1, ref d2);
1459  return d1;
1460  }
1461 
1469  [SecuritySafeCritical]
1470  [__DynamicallyInvokable]
1471  public static decimal operator /(decimal d1, decimal d2)
1472  {
1473  FCallDivide(ref d1, ref d2);
1474  return d1;
1475  }
1476 
1484  [__DynamicallyInvokable]
1485  public static decimal operator %(decimal d1, decimal d2)
1486  {
1487  return Remainder(d1, d2);
1488  }
1489 
1495  [SecuritySafeCritical]
1496  [__DynamicallyInvokable]
1497  public static bool operator ==(decimal d1, decimal d2)
1498  {
1499  return FCallCompare(ref d1, ref d2) == 0;
1500  }
1501 
1507  [SecuritySafeCritical]
1508  [__DynamicallyInvokable]
1509  public static bool operator !=(decimal d1, decimal d2)
1510  {
1511  return FCallCompare(ref d1, ref d2) != 0;
1512  }
1513 
1519  [SecuritySafeCritical]
1520  [__DynamicallyInvokable]
1521  public static bool operator <(decimal d1, decimal d2)
1522  {
1523  return FCallCompare(ref d1, ref d2) < 0;
1524  }
1525 
1531  [SecuritySafeCritical]
1532  [__DynamicallyInvokable]
1533  public static bool operator <=(decimal d1, decimal d2)
1534  {
1535  return FCallCompare(ref d1, ref d2) <= 0;
1536  }
1537 
1543  [SecuritySafeCritical]
1544  [__DynamicallyInvokable]
1545  public static bool operator >(decimal d1, decimal d2)
1546  {
1547  return FCallCompare(ref d1, ref d2) > 0;
1548  }
1549 
1555  [SecuritySafeCritical]
1556  [__DynamicallyInvokable]
1557  public static bool operator >=(decimal d1, decimal d2)
1558  {
1559  return FCallCompare(ref d1, ref d2) >= 0;
1560  }
1561 
1565  {
1566  return TypeCode.Decimal;
1567  }
1568 
1573  [__DynamicallyInvokable]
1575  {
1576  return Convert.ToBoolean(this);
1577  }
1578 
1583  [__DynamicallyInvokable]
1585  {
1586  throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "Decimal", "Char"));
1587  }
1588 
1593  [__DynamicallyInvokable]
1595  {
1596  return Convert.ToSByte(this);
1597  }
1598 
1603  [__DynamicallyInvokable]
1605  {
1606  return Convert.ToByte(this);
1607  }
1608 
1613  [__DynamicallyInvokable]
1615  {
1616  return Convert.ToInt16(this);
1617  }
1618 
1623  [__DynamicallyInvokable]
1625  {
1626  return Convert.ToUInt16(this);
1627  }
1628 
1633  [__DynamicallyInvokable]
1635  {
1636  return Convert.ToInt32(this);
1637  }
1638 
1643  [__DynamicallyInvokable]
1645  {
1646  return Convert.ToUInt32(this);
1647  }
1648 
1653  [__DynamicallyInvokable]
1655  {
1656  return Convert.ToInt64(this);
1657  }
1658 
1663  [__DynamicallyInvokable]
1665  {
1666  return Convert.ToUInt64(this);
1667  }
1668 
1672  [__DynamicallyInvokable]
1674  {
1675  return Convert.ToSingle(this);
1676  }
1677 
1681  [__DynamicallyInvokable]
1683  {
1684  return Convert.ToDouble(this);
1685  }
1686 
1690  [__DynamicallyInvokable]
1692  {
1693  return this;
1694  }
1695 
1700  [__DynamicallyInvokable]
1702  {
1703  throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "Decimal", "DateTime"));
1704  }
1705 
1713  [__DynamicallyInvokable]
1714  object IConvertible.ToType(Type type, IFormatProvider provider)
1715  {
1716  return Convert.DefaultToType(this, type, provider);
1717  }
1718  }
1719 }
float ToSingle(IFormatProvider provider)
Converts the value of this instance to an equivalent single-precision floating-point number using the...
Converts a base data type to another base data type.
Definition: Convert.cs:10
static decimal Floor(decimal d)
Rounds a specified T:System.Decimal number to the closest integer toward negative infinity.
Definition: Decimal.cs:450
override int GetHashCode()
Returns the hash code for this instance.
static long ToInt64(object value)
Converts the value of the specified object to a 64-bit signed integer.
Definition: Convert.cs:2506
Decimal(long value)
Initializes a new instance of T:System.Decimal to the value of the specified 64-bit signed integer.
Definition: Decimal.cs:111
static double ToDouble(object value)
Converts the value of the specified object to a double-precision floating-point number.
Definition: Convert.cs:3189
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
static ushort ToUInt16(decimal value)
Converts the value of the specified T:System.Decimal to the equivalent 16-bit unsigned integer.
Definition: Decimal.cs:1057
static long ToOACurrency(decimal value)
Converts the specified T:System.Decimal value to the equivalent OLE Automation Currency value,...
Definition: Decimal.cs:173
static decimal Multiply(decimal d1, decimal d2)
Multiplies two specified T:System.Decimal values.
Definition: Decimal.cs:777
static decimal Round(decimal d, int decimals)
Rounds a T:System.Decimal value to a specified number of decimal places.
Definition: Decimal.cs:817
const decimal One
Represents the number one (1).
Definition: Decimal.cs:50
static bool Equals(decimal d1, decimal d2)
Returns a value indicating whether two specified instances of T:System.Decimal represent the same val...
Definition: Decimal.cs:440
static sbyte ToSByte(decimal value)
Converts the value of the specified T:System.Decimal to the equivalent 8-bit signed integer.
Definition: Decimal.cs:914
static int Compare(decimal d1, decimal d2)
Compares two specified T:System.Decimal values.
Definition: Decimal.cs:335
static decimal Add(decimal d1, decimal d2)
Adds two specified T:System.Decimal values.
Definition: Decimal.cs:302
double ToDouble(IFormatProvider provider)
Converts the value of this instance to an equivalent double-precision floating-point number using the...
Decimal(uint value)
Initializes a new instance of T:System.Decimal to the value of the specified 32-bit unsigned integer.
Definition: Decimal.cs:100
bool ToBoolean(IFormatProvider provider)
Converts the value of this instance to an equivalent Boolean value using the specified culture-specif...
TypeCode
Specifies the type of an object.
Definition: TypeCode.cs:9
static float ToSingle(object value)
Converts the value of the specified object to a single-precision floating-point number.
Definition: Convert.cs:2982
string ToString(string format, IFormatProvider provider)
Converts the numeric value of this instance to its equivalent string representation using the specifi...
Definition: Decimal.cs:499
Indicates that a class is to be notified when deserialization of the entire object graph has been com...
static decimal Parse(string s, NumberStyles style, IFormatProvider provider)
Converts the string representation of a number to its T:System.Decimal equivalent using the specified...
Definition: Decimal.cs:570
Definition: __Canon.cs:3
The exception that is thrown when the value of an argument is outside the allowable range of values a...
The exception that is thrown for invalid casting or explicit conversion.
Represents a decimal number.
Definition: Decimal.cs:16
char ToChar(IFormatProvider provider)
Converts the value of this instance to an equivalent Unicode character using the specified culture-sp...
static decimal operator -(decimal d)
Negates the value of the specified T:System.Decimal operand.
Definition: Decimal.cs:1398
override bool Equals(object value)
Returns a value indicating whether this instance and a specified T:System.Object represent the same t...
Definition: Decimal.cs:405
static decimal operator *(decimal d1, decimal d2)
Multiplies two specified T:System.Decimal values.
Definition: Decimal.cs:1456
Provides a mechanism for retrieving an object to control formatting.
static bool operator >=(decimal d1, decimal d2)
Returns a value indicating whether a specified T:System.Decimal is greater than or equal to another s...
Definition: Decimal.cs:1557
static decimal Round(decimal d)
Rounds a decimal value to the nearest integer.
Definition: Decimal.cs:804
Represents an instant in time, typically expressed as a date and time of day. To browse the ....
Definition: DateTime.cs:13
int CompareTo(decimal value)
Compares this instance to a specified T:System.Decimal object and returns a comparison of their relat...
Definition: Decimal.cs:371
string ToString(string format)
Converts the numeric value of this instance to its equivalent string representation,...
Definition: Decimal.cs:476
Decimal(int value)
Initializes a new instance of T:System.Decimal to the value of the specified 32-bit signed integer.
Definition: Decimal.cs:79
DateTime ToDateTime(IFormatProvider provider)
Converts the value of this instance to an equivalent T:System.DateTime using the specified culture-sp...
Describes the source and destination of a given serialized stream, and provides an additional caller-...
static NumberFormatInfo CurrentInfo
Gets a read-only T:System.Globalization.NumberFormatInfo that formats values based on the current cul...
const decimal MinusOne
Represents the number negative one (-1).
Definition: Decimal.cs:54
sbyte ToSByte(IFormatProvider provider)
Converts the value of this instance to an equivalent 8-bit signed integer using the specified culture...
Defines a generalized type-specific comparison method that a value type or class implements to order ...
Definition: IComparable.cs:8
The exception that is thrown when an arithmetic, casting, or conversion operation in a checked contex...
NumberStyles
Determines the styles permitted in numeric string arguments that are passed to the Parse and TryParse...
Definition: NumberStyles.cs:10
Cer
Specifies a method's behavior when called within a constrained execution region.
Definition: Cer.cs:5
static decimal operator --(decimal d)
Decrements the T:System.Decimal operand by one.
Definition: Decimal.cs:1418
static long ToInt64(decimal d)
Converts the value of the specified T:System.Decimal to the equivalent 64-bit signed integer.
Definition: Decimal.cs:1022
string ToString(IFormatProvider provider)
Converts the numeric value of this instance to its equivalent string representation using the specifi...
Definition: Decimal.cs:486
Provides information about, and means to manipulate, the current environment and platform....
Definition: Environment.cs:21
static bool ToBoolean(object value)
Converts the value of a specified object to an equivalent Boolean value.
Definition: Convert.cs:457
decimal ToDecimal(IFormatProvider provider)
Converts the value of this instance to an equivalent T:System.Decimal number using the specified cult...
static uint ToUInt32(decimal d)
Converts the value of the specified T:System.Decimal to the equivalent 32-bit unsigned integer.
Definition: Decimal.cs:1083
static decimal Subtract(decimal d1, decimal d2)
Subtracts one specified T:System.Decimal value from another.
Definition: Decimal.cs:877
static decimal operator++(decimal d)
Increments the T:System.Decimal operand by 1.
Definition: Decimal.cs:1408
int ToInt32(IFormatProvider provider)
Converts the value of this instance to an equivalent 32-bit signed integer using the specified cultur...
static bool operator==(decimal d1, decimal d2)
Returns a value that indicates whether two T:System.Decimal values are equal.
Definition: Decimal.cs:1497
static decimal operator+(decimal d)
Returns the value of the T:System.Decimal operand (the sign of the operand is unchanged).
Definition: Decimal.cs:1389
static decimal Parse(string s, NumberStyles style)
Converts the string representation of a number in a specified style to its T:System....
Definition: Decimal.cs:533
const decimal MinValue
Represents the smallest possible value of T:System.Decimal. This field is constant and read-only.
Definition: Decimal.cs:62
void OnDeserialization(object sender)
Runs when the entire object graph has been deserialized.
static ulong ToUInt64(decimal d)
Converts the value of the specified T:System.Decimal to the equivalent 64-bit unsigned integer.
Definition: Decimal.cs:1108
static NumberFormatInfo GetInstance(IFormatProvider formatProvider)
Gets the T:System.Globalization.NumberFormatInfo associated with the specified T:System....
static int ToInt32(decimal d)
Converts the value of the specified T:System.Decimal to the equivalent 32-bit signed integer.
Definition: Decimal.cs:987
static bool operator >(decimal d1, decimal d2)
Returns a value indicating whether a specified T:System.Decimal is greater than another specified T:S...
Definition: Decimal.cs:1545
Decimal(ulong value)
Initializes a new instance of T:System.Decimal to the value of the specified 64-bit unsigned integer.
Definition: Decimal.cs:132
static decimal Round(decimal d, MidpointRounding mode)
Rounds a decimal value to the nearest integer. A parameter specifies how to round the value if it is ...
Definition: Decimal.cs:830
int CompareTo(object value)
Compares this instance to a specified object and returns a comparison of their relative values.
Definition: Decimal.cs:352
MidpointRounding
Specifies how mathematical rounding methods should process a number that is midway between two number...
static ushort ToUInt16(object value)
Converts the value of the specified object to a 16-bit unsigned integer.
Definition: Convert.cs:1707
object ToType(Type conversionType, IFormatProvider provider)
Converts the value of this instance to an T:System.Object of the specified T:System....
static sbyte ToSByte(object value)
Converts the value of the specified object to an 8-bit signed integer.
Definition: Convert.cs:909
Represents type declarations: class types, interface types, array types, value types,...
Definition: Type.cs:18
The exception thrown when an error occurs during serialization or deserialization.
static decimal Divide(decimal d1, decimal d2)
Divides two specified T:System.Decimal values.
Definition: Decimal.cs:385
ushort ToUInt16(IFormatProvider provider)
Converts the value of this instance to an equivalent 16-bit unsigned integer using the specified cult...
const decimal Zero
Represents the number zero (0).
Definition: Decimal.cs:46
MethodImplOptions
Defines the details of how a method is implemented.
static bool operator !=(decimal d1, decimal d2)
Returns a value that indicates whether two T:System.Decimal objects have different values.
Definition: Decimal.cs:1509
static uint ToUInt32(object value)
Converts the value of the specified object to a 32-bit unsigned integer.
Definition: Convert.cs:2235
short ToInt16(IFormatProvider provider)
Converts the value of this instance to an equivalent 16-bit signed integer using the specified cultur...
static decimal Parse(string s)
Converts the string representation of a number to its T:System.Decimal equivalent.
Definition: Decimal.cs:514
static float ToSingle(decimal d)
Converts the value of the specified T:System.Decimal to the equivalent single-precision floating-poin...
long ToInt64(IFormatProvider provider)
Converts the value of this instance to an equivalent 64-bit signed integer using the specified cultur...
The exception that is thrown when one of the arguments provided to a method is not valid.
static bool TryParse(string s, out decimal result)
Converts the string representation of a number to its T:System.Decimal equivalent....
Definition: Decimal.cs:582
static int [] GetBits(decimal d)
Converts the value of a specified instance of T:System.Decimal to its equivalent binary representatio...
Definition: Decimal.cs:608
static decimal operator -(decimal d1, decimal d2)
Subtracts two specified T:System.Decimal values.
Definition: Decimal.cs:1443
static decimal operator %(decimal d1, decimal d2)
Returns the remainder resulting from dividing two specified T:System.Decimal values.
Definition: Decimal.cs:1485
static decimal Truncate(decimal d)
Returns the integral digits of the specified T:System.Decimal; any fractional digits are discarded.
Definition: Decimal.cs:1138
static byte ToByte(object value)
Converts the value of the specified object to an 8-bit unsigned integer.
Definition: Convert.cs:1186
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition: IEquatable.cs:6
static decimal Negate(decimal d)
Returns the result of multiplying the specified T:System.Decimal value by negative one.
Definition: Decimal.cs:795
static double ToDouble(decimal d)
Converts the value of the specified T:System.Decimal to the equivalent double-precision floating-poin...
static short ToInt16(object value)
Converts the value of the specified object to a 16-bit signed integer.
Definition: Convert.cs:1452
Specifies that the class can be serialized.
static bool TryParse(string s, NumberStyles style, IFormatProvider provider, out decimal result)
Converts the string representation of a number to its T:System.Decimal equivalent using the specified...
Definition: Decimal.cs:598
static decimal FromOACurrency(long cy)
Converts the specified 64-bit signed integer, which contains an OLE Automation Currency value,...
Definition: Decimal.cs:182
override string ToString()
Converts the numeric value of this instance to its equivalent string representation.
Definition: Decimal.cs:464
Consistency
Specifies a reliability contract.
Definition: Consistency.cs:5
ulong ToUInt64(IFormatProvider provider)
Converts the value of this instance to an equivalent 64-bit unsigned integer using the specified cult...
static ulong ToUInt64(object value)
Converts the value of the specified object to a 64-bit unsigned integer.
Definition: Convert.cs:2727
static int ToInt32(object value)
Converts the value of the specified object to a 32-bit signed integer.
Definition: Convert.cs:1974
TypeCode GetTypeCode()
Returns the T:System.TypeCode for value type T:System.Decimal.
Definition: Decimal.cs:1564
Indicates that all styles except F:System.Globalization.NumberStyles.AllowExponent and F:System....
byte ToByte(IFormatProvider provider)
Converts the value of this instance to an equivalent 8-bit unsigned integer using the specified cultu...
static short ToInt16(decimal value)
Converts the value of the specified T:System.Decimal to the equivalent 16-bit signed integer.
Definition: Decimal.cs:938
Decimal(int lo, int mid, int hi, bool isNegative, byte scale)
Initializes a new instance of T:System.Decimal from parameters specifying the instance's constituent ...
Definition: Decimal.cs:233
static decimal Remainder(decimal d1, decimal d2)
Computes the remainder after dividing two T:System.Decimal values.
Definition: Decimal.cs:741
Defines methods that convert the value of the implementing reference or value type to a common langua...
Definition: IConvertible.cs:9
static byte ToByte(decimal value)
Converts the value of the specified T:System.Decimal to the equivalent 8-bit unsigned integer.
Definition: Decimal.cs:889
Provides functionality to format the value of an object into a string representation.
Definition: IFormattable.cs:8
static bool operator<=(decimal d1, decimal d2)
Returns a value indicating whether a specified T:System.Decimal is less than or equal to another spec...
Definition: Decimal.cs:1533
static decimal operator/(decimal d1, decimal d2)
Divides two specified T:System.Decimal values.
Definition: Decimal.cs:1471
uint ToUInt32(IFormatProvider provider)
Converts the value of this instance to an equivalent 32-bit unsigned integer using the specified cult...
static decimal Round(decimal d, int decimals, MidpointRounding mode)
Rounds a decimal value to a specified precision. A parameter specifies how to round the value if it i...
Definition: Decimal.cs:846
static decimal Parse(string s, IFormatProvider provider)
Converts the string representation of a number to its T:System.Decimal equivalent using the specified...
Definition: Decimal.cs:550
const decimal MaxValue
Represents the largest possible value of T:System.Decimal. This field is constant and read-only.
Definition: Decimal.cs:58
static decimal Ceiling(decimal d)
Returns the smallest integral value that is greater than or equal to the specified decimal number.
Definition: Decimal.cs:320
Decimal(int[] bits)
Initializes a new instance of T:System.Decimal to a decimal value represented in binary and contained...
Definition: Decimal.cs:193
Provides culture-specific information for formatting and parsing numeric values.
bool Equals(decimal value)
Returns a value indicating whether this instance and a specified T:System.Decimal object represent th...
Definition: Decimal.cs:421
static bool operator<(decimal d1, decimal d2)
Returns a value indicating whether a specified T:System.Decimal is less than another specified T:Syst...
Definition: Decimal.cs:1521