示例#1
0
        public static int Limit(RubyContext /*!*/ context, RubyClass /*!*/ self, int n)
        {
            BigDecimal.Config config = GetConfig(context);
            int limit = config.Limit;

            config.Limit = n;
            return(limit);
        }
示例#2
0
        public static int Limit(RubyContext /*!*/ context, RubyClass /*!*/ self, int n)
        {
            if (n < 0)
            {
                throw RubyExceptions.CreateArgumentError("argument must be positive");
            }
            BigDecimal.Config config = GetConfig(context);
            int limit = config.Limit;

            config.Limit = n;
            return(limit);
        }
示例#3
0
 public static BigDecimal /*!*/ Div(RubyContext /*!*/ context, BigDecimal /*!*/ self, BigDecimal /*!*/ other)
 {
     if (BigDecimal.IsFinite(other))
     {
         BigDecimal.Config config = GetConfig(context);
         BigDecimal        remainder;
         BigDecimal        result = BigDecimal.Divide(config, self, other, 0, out remainder);
         if (BigDecimal.IsFinite(result))
         {
             return(BigDecimal.IntegerPart(config, result));
         }
     }
     return(BigDecimal.NaN);
 }
示例#4
0
 public static int Mode(RubyContext /*!*/ context, RubyClass /*!*/ self, int mode, object value)
 {
     if (value == null)
     {
         return(Mode(context, self, mode));
     }
     if (mode == ROUND_MODE)
     {
         if (value is int)
         {
             GetConfig(context).RoundingMode = (BigDecimal.RoundingModes)value;
             return((int)value);
         }
         else
         {
             throw RubyExceptions.CreateUnexpectedTypeError(context, value, "Fixnum");
         }
     }
     else
     {
         if (value is bool)
         {
             BigDecimal.Config config = GetConfig(context);
             if (Enum.IsDefined(typeof(BigDecimal.OverflowExceptionModes), mode))
             {
                 BigDecimal.OverflowExceptionModes enumMode = (BigDecimal.OverflowExceptionModes)mode;
                 if ((bool)value)
                 {
                     config.OverflowMode = config.OverflowMode | enumMode;
                 }
                 else
                 {
                     config.OverflowMode = config.OverflowMode & (BigDecimal.OverflowExceptionModes.All ^ enumMode);
                 }
             }
             return((int)config.OverflowMode);
         }
         else
         {
             throw RubyExceptions.CreateTypeError("second argument must be true or false");
         }
     }
 }
示例#5
0
 public static BigDecimal /*!*/ Multiply(RubyContext /*!*/ context, BigDecimal /*!*/ self, double other, int n)
 {
     BigDecimal.Config config = GetConfig(context);
     return(BigDecimal.Multiply(config, self, BigDecimal.Create(config, other), n));
 }
示例#6
0
 public static BigDecimal /*!*/ Multiply(RubyContext /*!*/ context, BigDecimal /*!*/ self, [NotNull] BigInteger /*!*/ other)
 {
     BigDecimal.Config config = GetConfig(context);
     return(BigDecimal.Multiply(config, self, BigDecimal.Create(config, other)));
 }
示例#7
0
 public static BigDecimal /*!*/ Subtract(RubyContext /*!*/ context, BigDecimal /*!*/ self, [NotNull] BigInteger /*!*/ other, int n)
 {
     BigDecimal.Config config = GetConfig(context);
     return(BigDecimal.Subtract(config, self, BigDecimal.Create(config, other), n));
 }
示例#8
0
 public static BigDecimal /*!*/ Subtract(RubyContext /*!*/ context, BigDecimal /*!*/ self, int other)
 {
     BigDecimal.Config config = GetConfig(context);
     return(BigDecimal.Subtract(config, self, BigDecimal.Create(config, other)));
 }
示例#9
0
 public static BigDecimal /*!*/ Add(RubyContext /*!*/ context, BigDecimal /*!*/ self, int other, int n)
 {
     BigDecimal.Config config = GetConfig(context);
     return(BigDecimal.Add(config, self, BigDecimal.Create(config, other), n));
 }