System.Convert.ToDecimal(long)

Here are the examples of the csharp api System.Convert.ToDecimal(long) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

25 Examples 7

19 Source : JsonTextReader.cs
with MIT License
from akaskela

private void ParseNumber(ReadType readType)
        {
            ShiftBufferIfNeeded();

            char firstChar = _chars[_charPos];
            int initialPosition = _charPos;

            ReadNumberIntoBuffer();

            // set state to PostValue now so that if there is an error parsing the number then the reader can continue
            SetPostValueState(true);

            _stringReference = new StringReference(_chars, initialPosition, _charPos - initialPosition);

            object numberValue;
            JsonToken numberType;

            bool singleDigit = (char.IsDigit(firstChar) && _stringReference.Length == 1);
            bool nonBase10 = (firstChar == '0' && _stringReference.Length > 1 && _stringReference.Chars[_stringReference.StartIndex + 1] != '.' && _stringReference.Chars[_stringReference.StartIndex + 1] != 'e' && _stringReference.Chars[_stringReference.StartIndex + 1] != 'E');

            if (readType == ReadType.Readreplacedtring)
            {
                string number = _stringReference.ToString();

                // validate that the string is a valid number
                if (nonBase10)
                {
                    try
                    {
                        if (number.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
                        {
                            Convert.ToInt64(number, 16);
                        }
                        else
                        {
                            Convert.ToInt64(number, 8);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw JsonReaderException.Create(this, "Input string '{0}' is not a valid number.".FormatWith(CultureInfo.InvariantCulture, number), ex);
                    }
                }
                else
                {
                    double value;
                    if (!double.TryParse(number, NumberStyles.Float, CultureInfo.InvariantCulture, out value))
                    {
                        throw JsonReaderException.Create(this, "Input string '{0}' is not a valid number.".FormatWith(CultureInfo.InvariantCulture, _stringReference.ToString()));
                    }
                }

                numberType = JsonToken.String;
                numberValue = number;
            }
            else if (readType == ReadType.ReadAsInt32)
            {
                if (singleDigit)
                {
                    // digit char values start at 48
                    numberValue = firstChar - 48;
                }
                else if (nonBase10)
                {
                    string number = _stringReference.ToString();

                    try
                    {
                        int integer = number.StartsWith("0x", StringComparison.OrdinalIgnoreCase) ? Convert.ToInt32(number, 16) : Convert.ToInt32(number, 8);

                        numberValue = integer;
                    }
                    catch (Exception ex)
                    {
                        throw JsonReaderException.Create(this, "Input string '{0}' is not a valid integer.".FormatWith(CultureInfo.InvariantCulture, number), ex);
                    }
                }
                else
                {
                    int value;
                    ParseResult parseResult = ConvertUtils.Int32TryParse(_stringReference.Chars, _stringReference.StartIndex, _stringReference.Length, out value);
                    if (parseResult == ParseResult.Success)
                    {
                        numberValue = value;
                    }
                    else if (parseResult == ParseResult.Overflow)
                    {
                        throw JsonReaderException.Create(this, "JSON integer {0} is too large or small for an Int32.".FormatWith(CultureInfo.InvariantCulture, _stringReference.ToString()));
                    }
                    else
                    {
                        throw JsonReaderException.Create(this, "Input string '{0}' is not a valid integer.".FormatWith(CultureInfo.InvariantCulture, _stringReference.ToString()));
                    }
                }

                numberType = JsonToken.Integer;
            }
            else if (readType == ReadType.ReadAsDecimal)
            {
                if (singleDigit)
                {
                    // digit char values start at 48
                    numberValue = (decimal)firstChar - 48;
                }
                else if (nonBase10)
                {
                    string number = _stringReference.ToString();

                    try
                    {
                        // decimal.Parse doesn't support parsing hexadecimal values
                        long integer = number.StartsWith("0x", StringComparison.OrdinalIgnoreCase) ? Convert.ToInt64(number, 16) : Convert.ToInt64(number, 8);

                        numberValue = Convert.ToDecimal(integer);
                    }
                    catch (Exception ex)
                    {
                        throw JsonReaderException.Create(this, "Input string '{0}' is not a valid decimal.".FormatWith(CultureInfo.InvariantCulture, number), ex);
                    }
                }
                else
                {
                    string number = _stringReference.ToString();

                    decimal value;
                    if (decimal.TryParse(number, NumberStyles.Number | NumberStyles.AllowExponent, CultureInfo.InvariantCulture, out value))
                    {
                        numberValue = value;
                    }
                    else
                    {
                        throw JsonReaderException.Create(this, "Input string '{0}' is not a valid decimal.".FormatWith(CultureInfo.InvariantCulture, _stringReference.ToString()));
                    }
                }

                numberType = JsonToken.Float;
            }
            else if (readType == ReadType.ReadAsDouble)
            {
                if (singleDigit)
                {
                    // digit char values start at 48
                    numberValue = (double)firstChar - 48;
                }
                else if (nonBase10)
                {
                    string number = _stringReference.ToString();

                    try
                    {
                        // double.Parse doesn't support parsing hexadecimal values
                        long integer = number.StartsWith("0x", StringComparison.OrdinalIgnoreCase) ? Convert.ToInt64(number, 16) : Convert.ToInt64(number, 8);

                        numberValue = Convert.ToDouble(integer);
                    }
                    catch (Exception ex)
                    {
                        throw JsonReaderException.Create(this, "Input string '{0}' is not a valid double.".FormatWith(CultureInfo.InvariantCulture, number), ex);
                    }
                }
                else
                {
                    string number = _stringReference.ToString();

                    double value;
                    if (double.TryParse(number, NumberStyles.Float, CultureInfo.InvariantCulture, out value))
                    {
                        numberValue = value;
                    }
                    else
                    {
                        throw JsonReaderException.Create(this, "Input string '{0}' is not a valid double.".FormatWith(CultureInfo.InvariantCulture, _stringReference.ToString()));
                    }
                }

                numberType = JsonToken.Float;
            }
            else
            {
                if (singleDigit)
                {
                    // digit char values start at 48
                    numberValue = (long)firstChar - 48;
                    numberType = JsonToken.Integer;
                }
                else if (nonBase10)
                {
                    string number = _stringReference.ToString();

                    try
                    {
                        numberValue = number.StartsWith("0x", StringComparison.OrdinalIgnoreCase) ? Convert.ToInt64(number, 16) : Convert.ToInt64(number, 8);
                    }
                    catch (Exception ex)
                    {
                        throw JsonReaderException.Create(this, "Input string '{0}' is not a valid number.".FormatWith(CultureInfo.InvariantCulture, number), ex);
                    }

                    numberType = JsonToken.Integer;
                }
                else
                {
                    long value;
                    ParseResult parseResult = ConvertUtils.Int64TryParse(_stringReference.Chars, _stringReference.StartIndex, _stringReference.Length, out value);
                    if (parseResult == ParseResult.Success)
                    {
                        numberValue = value;
                        numberType = JsonToken.Integer;
                    }
                    else if (parseResult == ParseResult.Overflow)
                    {
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
                        string number = _stringReference.ToString();

                        if (number.Length > MaximumJavascriptIntegerCharacterLength)
                        {
                            throw JsonReaderException.Create(this, "JSON integer {0} is too large to parse.".FormatWith(CultureInfo.InvariantCulture, _stringReference.ToString()));
                        }

                        numberValue = BigIntegerParse(number, CultureInfo.InvariantCulture);
                        numberType = JsonToken.Integer;
#else
                        throw JsonReaderException.Create(this, "JSON integer {0} is too large or small for an Int64.".FormatWith(CultureInfo.InvariantCulture, _stringReference.ToString()));
#endif
                    }
                    else
                    {
                        string number = _stringReference.ToString();

                        if (_floatParseHandling == FloatParseHandling.Decimal)
                        {
                            decimal d;
                            if (decimal.TryParse(number, NumberStyles.Number | NumberStyles.AllowExponent, CultureInfo.InvariantCulture, out d))
                            {
                                numberValue = d;
                            }
                            else
                            {
                                throw JsonReaderException.Create(this, "Input string '{0}' is not a valid decimal.".FormatWith(CultureInfo.InvariantCulture, number));
                            }
                        }
                        else
                        {
                            double d;
                            if (double.TryParse(number, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out d))
                            {
                                numberValue = d;
                            }
                            else
                            {
                                throw JsonReaderException.Create(this, "Input string '{0}' is not a valid number.".FormatWith(CultureInfo.InvariantCulture, number));
                            }
                        }

                        numberType = JsonToken.Float;
                    }
                }
            }

            ClearRecentString();

            // index has already been updated
            SetToken(numberType, numberValue, false);
        }

19 Source : Time.cs
with Apache License 2.0
from Capnode

public static DateTime UnixTimeStampToDateTime(long unixTimeStamp)
        {
            return UnixTimeStampToDateTime(Convert.ToDecimal(unixTimeStamp));
        }

19 Source : JsonTextReader.cs
with MIT License
from CragonGame

private void ParseNumber(char firstChar)
    {
      char currentChar = firstChar;

      // parse until seperator character or end
      bool end = false;
      do
      {
        if (IsSeperator(currentChar))
        {
          end = true;
          _lastChar = currentChar;
        }
        else
        {
          _buffer.Append(currentChar);
        }

      } while (!end && ((currentChar = MoveNext()) != '\0' || !_end));

      string number = _buffer.ToString();
      object numberValue;
      JsonToken numberType;

      bool nonBase10 = (firstChar == '0' && !number.StartsWith("0.", StringComparison.OrdinalIgnoreCase));

      if (_readType == ReadType.ReadAsDecimal)
      {
        if (nonBase10)
        {
          // decimal.Parse doesn't support parsing hexadecimal values
          long integer = number.StartsWith("0x", StringComparison.OrdinalIgnoreCase)
            ? Convert.ToInt64(number, 16)
            : Convert.ToInt64(number, 8);

          numberValue = Convert.ToDecimal(integer);
        }
        else
        {
          numberValue = decimal.Parse(number, NumberStyles.Number | NumberStyles.AllowExponent, CultureInfo.InvariantCulture);
        }

        numberType = JsonToken.Float;
      }
      else
      {
        if (nonBase10)
        {
          numberValue = number.StartsWith("0x", StringComparison.OrdinalIgnoreCase)
            ? Convert.ToInt64(number, 16)
            : Convert.ToInt64(number, 8);
          numberType = JsonToken.Integer;
        }
        else if (number.IndexOf(".", StringComparison.OrdinalIgnoreCase) != -1 || number.IndexOf("e", StringComparison.OrdinalIgnoreCase) != -1)
        {
          numberValue = Convert.ToDouble(number, CultureInfo.InvariantCulture);
          numberType = JsonToken.Float;
        }
        else
        {
          try
          {
            numberValue = Convert.ToInt64(number, CultureInfo.InvariantCulture);
          }
          catch (OverflowException ex)
          {
            throw new JsonReaderException("JSON integer {0} is too large or small for an Int64.".FormatWith(CultureInfo.InvariantCulture, number), ex);
          }

          numberType = JsonToken.Integer;
        }
      }

      _buffer.Position = 0;

      SetToken(numberType, numberValue);
    }

19 Source : TimeSpan2.cs
with MIT License
from dahall

decimal IConvertible.ToDecimal(IFormatProvider provider) => Convert.ToDecimal(core.Ticks);

19 Source : Int64AdvancedConverter.cs
with MIT License
from DataObjects-NET

decimal IAdvancedConverter<long, decimal>.Convert(long value)
    {
      return System.Convert.ToDecimal(value);
    }

19 Source : TimeSpanAdvancedConverter.cs
with MIT License
from DataObjects-NET

decimal IAdvancedConverter<TimeSpan, decimal>.Convert(TimeSpan value)
    {
      return System.Convert.ToDecimal(value.Ticks);
    }

19 Source : DateTimeAdvancedConverter.cs
with MIT License
from DataObjects-NET

decimal IAdvancedConverter<DateTime, decimal>.Convert(DateTime value)
    {
      return System.Convert.ToDecimal(value.Ticks - baseDateTimeTicks);
    }

19 Source : BasicConvert.Overload.cs
with MIT License
from Dogwei

decimal IXConverter<long, decimal>.Convert(long value)
			=> Convert.ToDecimal(value);

19 Source : ActingOnNullableDecimals.cs
with BSD 3-Clause "New" or "Revised" License
from fluffynuts

[Test]
            public void GreaterThan_WhenActualIsEqualToExpected_ShouldThrow()
            {
                // Arrange
                var actual = Convert.ToDecimal(GetRandomLong(5, 10)) as decimal?;
                var expected = (long)actual;

                // Pre-replacedert

                // Act
                replacedert.That(
                    () =>
                    {
                        Expect(actual).To.Be.Greater.Than(expected);
                    },
                    Throws.Exception.InstanceOf<UnmetExpectationException>());

                // replacedert
            }

19 Source : ActingOnNullableDecimals.cs
with BSD 3-Clause "New" or "Revised" License
from fluffynuts

[Test]
            public void LessThan_WhenActualIsEqualToExpected_ShouldThrow()
            {
                // Arrange
                var actual = Convert.ToDecimal(GetRandomLong(1, 5)) as decimal?;
                var expected = actual.Value;
                // Pre-replacedert
                // Act
                replacedert.That(
                    () =>
                    {
                        Expect(actual).To.Be.Less.Than(expected);
                    },
                    Throws.Exception
                        .InstanceOf<UnmetExpectationException>()
                        .With.Message.Contains($"{actual} to be less than {expected}"));
                // replacedert
            }

19 Source : Tracer.cs
with MIT License
from iccb1013

private decimal GetSecondsElapsed(long milliseconds)
		{
			decimal result = Convert.ToDecimal(milliseconds) / 1000m;
			return Math.Round(result, 6);
		}

19 Source : JsonTextReader.cs
with Apache License 2.0
from intuit

private void ParseNumber()
    {
      ShiftBufferIfNeeded();

      char firstChar = _chars[_charPos];
      int initialPosition = _charPos;

      ReadNumberIntoBuffer();

      _stringReference = new StringReference(_chars, initialPosition, _charPos - initialPosition);

      object numberValue;
      JsonToken numberType;

      bool singleDigit = (char.IsDigit(firstChar) && _stringReference.Length == 1);
      bool nonBase10 = (firstChar == '0' && _stringReference.Length > 1
        && _stringReference.Chars[_stringReference.StartIndex + 1] != '.'
        && _stringReference.Chars[_stringReference.StartIndex + 1] != 'e'
        && _stringReference.Chars[_stringReference.StartIndex + 1] != 'E');

      if (_readType == ReadType.ReadAsInt32)
      {
        if (singleDigit)
        {
          // digit char values start at 48
          numberValue = firstChar - 48;
        }
        else if (nonBase10)
        {
          string number = _stringReference.ToString();

          // decimal.Parse doesn't support parsing hexadecimal values
          int integer = number.StartsWith("0x", StringComparison.OrdinalIgnoreCase)
                           ? Convert.ToInt32(number, 16)
                           : Convert.ToInt32(number, 8);

          numberValue = integer;
        }
        else
        {
          string number = _stringReference.ToString();

          numberValue = Convert.ToInt32(number, CultureInfo.InvariantCulture);
        }

        numberType = JsonToken.Integer;
      }
      else if (_readType == ReadType.ReadAsDecimal)
      {
        if (singleDigit)
        {
          // digit char values start at 48
          numberValue = (decimal)firstChar - 48;
        }
        else if (nonBase10)
        {
          string number = _stringReference.ToString();

          // decimal.Parse doesn't support parsing hexadecimal values
          long integer = number.StartsWith("0x", StringComparison.OrdinalIgnoreCase)
                           ? Convert.ToInt64(number, 16)
                           : Convert.ToInt64(number, 8);

          numberValue = Convert.ToDecimal(integer);
        }
        else
        {
          string number = _stringReference.ToString();

          numberValue = decimal.Parse(number, NumberStyles.Number | NumberStyles.AllowExponent, CultureInfo.InvariantCulture);
        }

        numberType = JsonToken.Float;
      }
      else
      {
        if (singleDigit)
        {
          // digit char values start at 48
          numberValue = (long)firstChar - 48;
          numberType = JsonToken.Integer;
        }
        else if (nonBase10)
        {
          string number = _stringReference.ToString();

          numberValue = number.StartsWith("0x", StringComparison.OrdinalIgnoreCase)
                          ? Convert.ToInt64(number, 16)
                          : Convert.ToInt64(number, 8);
          numberType = JsonToken.Integer;
        }
        else
        {
          string number = _stringReference.ToString();

          // it's faster to do 3 indexof with single characters than an indexofany
          if (number.IndexOf('.') != -1 || number.IndexOf('E') != -1 || number.IndexOf('e') != -1)
          {
            numberValue = Convert.ToDouble(number, CultureInfo.InvariantCulture);
            numberType = JsonToken.Float;
          }
          else
          {
            try
            {
              numberValue = Convert.ToInt64(number, CultureInfo.InvariantCulture);
            }
            catch (OverflowException ex)
            {
              throw new JsonReaderException("JSON integer {0} is too large or small for an Int64.".FormatWith(CultureInfo.InvariantCulture, number), ex);
            }

            numberType = JsonToken.Integer;
          }
        }
      }

      ClearRecentString();

      SetToken(numberType, numberValue);
    }

19 Source : LineChart.xaml.cs
with Apache License 2.0
from kauffman12

private static void Insert(DataPoint aggregate, Dictionary<string, ChartValues<DataPoint>> chartValues)
    {
      DataPoint newEntry = new DataPoint
      {
        Name = aggregate.Name,
        PlayerName = aggregate.PlayerName,
        CurrentTime = aggregate.CurrentTime,
        Total = aggregate.Total
      };

      double totalSeconds = aggregate.CurrentTime - aggregate.BeginTime + 1;
      newEntry.Vps = (long)Math.Round(aggregate.RollingTotal / totalSeconds, 2);

      if (aggregate.RollingHits > 0)
      {
        newEntry.Avg = (long)Math.Round(Convert.ToDecimal(aggregate.RollingTotal) / aggregate.RollingHits, 2);
        newEntry.CritRate = Math.Round(Convert.ToDouble(aggregate.RollingCritHits) / aggregate.RollingHits * 100, 2);
      }

      if (!chartValues.TryGetValue(aggregate.Name, out ChartValues<DataPoint> playerValues))
      {
        playerValues = new ChartValues<DataPoint>();
        chartValues[aggregate.Name] = playerValues;
      }

      DataPoint test;
      if (playerValues.Count > 0 && (test = playerValues.Last()) != null && test.CurrentTime == newEntry.CurrentTime)
      {
        playerValues[playerValues.Count - 1] = newEntry;
      }
      else
      {
        playerValues.Add(newEntry);
      }
    }

19 Source : BitmexConverter.cs
with Apache License 2.0
from Marfusios

public static decimal ConvertToBtcDecimal(string from, long value)
        {
            var valueDouble = Convert.ToDecimal(value);
            return ConvertToBtc(from, valueDouble);
        }

19 Source : CryptoDateUtils.cs
with Apache License 2.0
from Marfusios

public static decimal ToUnixSecondsDecimal(this DateTime date)
        {
            var unixTimeStampInTicks = Convert.ToDecimal((date.ToUniversalTime() - UnixBase).Ticks);
            return unixTimeStampInTicks / TimeSpan.TicksPerSecond;
        }

19 Source : Int64Extensions.cs
with GNU General Public License v3.0
from ME3Tweaks

public static decimal ToDecimal(this long value)
		{
			return Convert.ToDecimal(value);
		}

19 Source : AtomicInt64.cs
with Apache License 2.0
from NightOwl888

decimal IConvertible.ToDecimal(IFormatProvider? provider) => Convert.ToDecimal(Value);

19 Source : MultiTrackBar.cs
with MIT License
from redscientistlabs

private long tbValueToNmValueQuadScale(long tbValue)
        {
            decimal max_X = Convert.ToDecimal(tbControlValue.Maximum);
            decimal max_X_Squared = max_X * max_X;
            decimal A = Maximum / max_X_Squared;

            decimal X = Convert.ToDecimal(tbValue);
            decimal Y = A * (X * X);

            decimal Floored_Y = Math.Floor(Y);
            return Convert.ToInt64(Floored_Y);
        }

19 Source : LongConvertor.cs
with GNU General Public License v3.0
from SeeSharpOpenSource

protected override void InitializeConvertFuncs()
        {
            ConvertFuncs.Add(typeof(decimal).Name, sourceValue => System.Convert.ToDecimal((long)sourceValue));
            ConvertFuncs.Add(typeof(double).Name, sourceValue => System.Convert.ToDouble((long)sourceValue));
            ConvertFuncs.Add(typeof(float).Name, sourceValue => System.Convert.ToSingle((long)sourceValue));
//            ConvertFuncs.Add(typeof(long).Name, sourceValue => System.Convert.ToInt64((long)sourceValue));
            ConvertFuncs.Add(typeof(ulong).Name, sourceValue => System.Convert.ToUInt64((long)sourceValue));
            ConvertFuncs.Add(typeof(int).Name, sourceValue => System.Convert.ToInt32((long)sourceValue));
            ConvertFuncs.Add(typeof(uint).Name, sourceValue => System.Convert.ToUInt32((long)sourceValue));
            ConvertFuncs.Add(typeof(short).Name, sourceValue => System.Convert.ToInt16((long)sourceValue));
            ConvertFuncs.Add(typeof(ushort).Name, sourceValue => System.Convert.ToUInt16((long)sourceValue));
            ConvertFuncs.Add(typeof(char).Name, sourceValue => System.Convert.ToChar((long)sourceValue));
            ConvertFuncs.Add(typeof(byte).Name, sourceValue => System.Convert.ToByte((long)sourceValue));
            ConvertFuncs.Add(typeof(bool).Name, sourceValue => (long)sourceValue > 0);
            ConvertFuncs.Add(typeof(string).Name, sourceValue => sourceValue.ToString());
        }

19 Source : Index.cs
with GNU General Public License v3.0
from sergiisyrovatchenko

public override string ToString() {
      return $"{DatabaseName} | {SchemaName}.{ObjectName} " +
             $"| {(string.IsNullOrEmpty(IndexName) ? "Heap" : $"{IndexName}")} {(IsParreplacedioned ? "[ " + ParreplacedionNumber + " ] " : string.Empty)}" +
             $"| {(Convert.ToDecimal(PagesCount) * 8).FormatSize()}".Replace("'", string.Empty);
    }

19 Source : Int64.cs
with MIT License
from spaceflint7

System.Decimal System.IConvertible.ToDecimal(System.IFormatProvider provider)
            => System.Convert.ToDecimal(Get());

19 Source : TronUnit.cs
with MIT License
from stoway

public static decimal SunToTRX(long sun)
        {
            return Convert.ToDecimal(sun) / _sun_unit;
        }

19 Source : Int64.cs
with MIT License
from Team-RTCLI

decimal IConvertible.ToDecimal(IFormatProvider? provider)
        {
            return Convert.ToDecimal(m_value);
        }

19 Source : ObfuscatedLong.cs
with MIT License
from vovgou

decimal IConvertible.ToDecimal(IFormatProvider provider)
        {
            return Convert.ToDecimal(this.Value);
        }

19 Source : NumberUtils.cs
with Apache License 2.0
from zhangzihan

public static object Divide(object m, object n, bool forceDecimal = false)
        {
            CoerceTypes(ref m, ref n);

            if (forceDecimal)
            {
                return ToDecimal(m) / ToDecimal(n);
            }

            if (n is Int32 || n is Int16)
            {
                var l = Convert.ToInt32(m);
                var r = Convert.ToInt32(n);
                if (l % r != 0)
                {
                    return Convert.ToDecimal(l) / r;
                }
                return l / r;
            }
            else if (n is Int64)
            {
                var l = Convert.ToInt64(m);
                var r = Convert.ToInt64(n);
                if (l % r != 0)
                {
                    return Convert.ToDecimal(l) / r;
                }
                return l / r;
            }
            else if (n is UInt16 || n is UInt32)
            {
                var l = (uint)m;
                var r = (uint)n;
                if (l % r != 0)
                {
                    return Convert.ToDecimal(l) / r;
                }
                return l / r;
            }
            else if (n is UInt64)
            {
                var l = Convert.ToUInt64(m);
                var r = Convert.ToUInt64(n);
                if (l % r != 0)
                {
                    return Convert.ToDecimal(l) / r;
                }
                return l / r;
            }
            else if (n is Byte)
                return Convert.ToByte(m) / Convert.ToByte(n);
            else if (n is SByte)
                return Convert.ToSByte(m) / Convert.ToSByte(n);
            else if (n is Single)
                return Convert.ToSingle(m) / Convert.ToSingle(n);
            else if (n is Double)
                return Convert.ToDouble(m) / Convert.ToDouble(n);
            else if (n is Decimal)
                return Convert.ToDecimal(m) / Convert.ToDecimal(n);
            else
            {
                throw new ArgumentException(string.Format("'{0}' and/or '{1}' are not one of the supported numeric types.", m, n));
            }
        }