Package java.math

Examples of java.math.BigInteger.signum()


        BigInteger r;
        do {
            old_r = number.get();
            r = old_r;
            int i = 0;
            while (i < v.length && r.signum() != 0)
                r = r.and(v[i++]);
        }
        while (!number.compareAndSet(old_r, r));
        return null;
    }
View Full Code Here


        BigInteger r;
        do {
            old_r = number.get();
            r = old_r;
            int i = 0;
            while (i < v.length && r.signum() != 0)
                r = r.and(v[i++]);
        }
        while (!number.compareAndSet(old_r, r));
        return Node.createExternal(new External_Integer(old_r));
    }
View Full Code Here

    public Node external_or(Node startAt) throws Exception {
        startAt.isGoodArgsLength(false, 2);
        BigInteger r = number.get();
        int i = 1;
        int asize = startAt.size();
        while (i < asize && r.signum() != 0)
            r = r.or(_getArg_(startAt, i++));
        return Node.createExternal(new External_Integer(r));
    }

    /**
 
View Full Code Here

            otherValue = ((RubyBignum) other).value;
        } else {
            return coerceBin(context, "%", other);
        }
        Ruby runtime = context.getRuntime();
        if (otherValue.signum() == 0) throw runtime.newZeroDivisionError();

        BigInteger result = value.mod(otherValue.abs());
        if (otherValue.signum() == -1 && result.signum() != 0) result = otherValue.add(result);
        return bignorm(runtime, result);
    }
View Full Code Here

        }
        Ruby runtime = context.getRuntime();
        if (otherValue.signum() == 0) throw runtime.newZeroDivisionError();

        BigInteger result = value.mod(otherValue.abs());
        if (otherValue.signum() == -1 && result.signum() != 0) result = otherValue.add(result);
        return bignorm(runtime, result);
    }

    /** rb_big_modulo
     *
 
View Full Code Here

            otherValue = ((RubyBignum) other).value;
        } else {
            return coerceBin(context, "remainder", other);
        }
        Ruby runtime = context.getRuntime();
        if (otherValue.signum() == 0) throw runtime.newZeroDivisionError();
        return bignorm(runtime, value.remainder(otherValue));
    }
   
    @JRubyMethod(name = "remainder", required = 1, compat = RUBY1_9)
    public IRubyObject remainder19(ThreadContext context, IRubyObject other) {
View Full Code Here

    @JRubyMethod(name = "*", required = 1)
    public IRubyObject op_mul(ThreadContext context, IRubyObject other) {
        Ruby runtime = context.getRuntime();
        if (other instanceof RubyFixnum) {
            BigInteger result = value.multiply(fix2big(((RubyFixnum) other)));
            return result.signum() == 0 ? RubyFixnum.zero(runtime) : new RubyBignum(runtime, result);
        }
        if (other instanceof RubyBignum) {
            BigInteger result = value.multiply(((RubyBignum)other).value);
            return result.signum() == 0 ? RubyFixnum.zero(runtime) : new RubyBignum(runtime, result);
        } else return opMulOther(context, other);
View Full Code Here

            BigInteger result = value.multiply(fix2big(((RubyFixnum) other)));
            return result.signum() == 0 ? RubyFixnum.zero(runtime) : new RubyBignum(runtime, result);
        }
        if (other instanceof RubyBignum) {
            BigInteger result = value.multiply(((RubyBignum)other).value);
            return result.signum() == 0 ? RubyFixnum.zero(runtime) : new RubyBignum(runtime, result);
        } else return opMulOther(context, other);
    }

    @JRubyMethod(name = "*", required = 1, compat = RUBY1_9)
    public IRubyObject op_mul19(ThreadContext context, IRubyObject other) {
View Full Code Here

    }

    public IRubyObject op_mul(ThreadContext context, long other) {
        Ruby runtime = context.getRuntime();
        BigInteger result = value.multiply(long2big(other));
        return result.signum() == 0 ? RubyFixnum.zero(runtime) : new RubyBignum(runtime, result);
    }
   
    public IRubyObject opMulOther(ThreadContext context, IRubyObject other) {
        if (other instanceof RubyFloat) {
            return RubyFloat.newFloat(getRuntime(), big2dbl(this) * ((RubyFloat) other).getDoubleValue());
View Full Code Here

            }
        } else {
            return coerceBin(context, slash ? "/" : "div", other);
        }

        if (otherValue.signum() == 0) throw runtime.newZeroDivisionError();

        final BigInteger result;
        if (value.signum() * otherValue.signum() == -1) {
            BigInteger[] results = value.divideAndRemainder(otherValue);
            result = results[1].signum() != 0 ? results[0].subtract(BigInteger.ONE) : results[0];
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.