PeterO.Cbor.CBORObject.ExtendedRationalToDecimal C# (CSharp) Method

ExtendedRationalToDecimal() private static method

private static ExtendedRationalToDecimal ( PeterO.Numbers.ERational extendedNumber ) : decimal
extendedNumber PeterO.Numbers.ERational
return decimal
        private static decimal ExtendedRationalToDecimal(ERational
      extendedNumber)
        {
            // TODO: When this library uses PeterO.Numbers later than 0.2, use an
              // operator
              if (extendedNumber.IsInfinity() || extendedNumber.IsNaN()) {
            throw new OverflowException("This object's value is out of range");
              }
              try {
            EDecimal newDecimal = EDecimal.FromEInteger(extendedNumber.Numerator)
              .Divide(
              EDecimal.FromEInteger(extendedNumber.Denominator),
              EContext.CliDecimal.WithTraps(EContext.FlagOverflow));
            return (decimal)newDecimal;
              } catch (ETrapException ex) {
            throw new OverflowException("This object's value is out of range", ex);
              }
        }