public override RArray DivMod(object o) { RBignum z; RBignum y = divmod(o, out z); return(RArray.AssocNew(ruby, y.Normalize, z.Normalize)); }
public override RArray Coerce(object y) { if (y is int || y is long || y is RFixnum) { return(RArray.AssocNew(ruby, to_big(ruby, y), this)); } throw new eTypeError("Can't create " + ruby.ClassOf(y).Name + " to Bignum"); }
public virtual RArray Coerce(object o) { if (ruby.ClassOf(o) == Class) { return(RArray.AssocNew(ruby, Instanciate(o), this)); } return(RArray.AssocNew(ruby, RFloat.Float(ruby, o), ToFloat())); }
public override RArray ToArray() { ArrayList a = new ArrayList(); lock (hash.SyncRoot) { foreach (DictionaryEntry ent in hash) { a.Add(RArray.AssocNew(ruby, ent.Key, ent.Value)); } } return(new RArray(ruby, a)); }
public override RArray DivMod(object o) { int y; if (o is int) { y = (int)o; } else if (o is RFixnum) { y = (int)((RFixnum)o).iVal; } else { return((RArray)CoerceBin(o)); } int mod; int d = divmod(y, out mod); return(RArray.AssocNew(ruby, new RFixnum(ruby, d), new RFixnum(ruby, mod))); }
public override RArray DivMod(object o) { double y; if (o is int) { y = (int)o; } else if (o is long) { y = (long)o; } else if (o is RFixnum) { y = ((RFixnum)o).ToLong(); } else if (o is double) { y = (double)o; } else if (o is RFloat) { y = ((RFloat)o).dVal; } else if (o is RBignum) { y = ((RBignum)o).Big2Dbl(); } else { return((RArray)CoerceBin(o)); } if (y == 0.0) { throw new DivideByZeroException("divided by 0"); } return(RArray.AssocNew(ruby, new RFloat(ruby, dVal / y), Modulo(y))); }