private RubyValue to_i(int radix) { String value = toString(); value = StringMe.replaceAll(value, "[^+\\-a-zA-Z0-9]", ""); int end = value.indexOf('+', 1); int end1 = value.indexOf('-', 1); if (end < 0) { if (end1 < 0) { end = value.length(); } else { end = end1; } } else { if (end1 >= 0) { end = Math.min(end, end1); } } value = value.substring(0, end); int nPoint = value.indexOf('.'); if (nPoint >= 0) value = value.substring(0, nPoint); if (radix >= 2 && radix <= 36) { HugeInt bigint; try { bigint = new HugeInt(value, radix); } catch (NumberFormatException e) { return ObjectFactory.FIXNUM0; } return RubyBignum.bignorm(bigint); } throw new RubyException(RubyRuntime.ArgumentErrorClass, "illegal radix " + radix); }
public RubyInteger toRubyInteger() { return RubyBignum.bignorm(this.toLong()); }