Package java.math

Examples of java.math.BigInteger.longValue()


           
            // But we may over/underflow, let's check:
            if (neg) {
                bi = bi.negate();
                if (bi.compareTo(BD_MIN_LONG) >= 0) {
                    return bi.longValue();
                }
            } else {
                if (bi.compareTo(BD_MAX_LONG) <= 0) {
                    return bi.longValue();
                }
View Full Code Here


                if (bi.compareTo(BD_MIN_LONG) >= 0) {
                    return bi.longValue();
                }
            } else {
                if (bi.compareTo(BD_MAX_LONG) <= 0) {
                    return bi.longValue();
                }
            }

            throw new IllegalArgumentException("value \""+lexicalDesc(lexical)+"\" not a valid long: overflow.");
        }
View Full Code Here

        {
            litValue = fLiteral;
        }
        else if ((iLiteral = p.parseIntegerLiteral()) != null)
        {
            litValue = Long.valueOf(iLiteral.longValue());
        }
        else if ((bLiteral = p.parseBooleanLiteral()) != null)
        {
            litValue = bLiteral;
        }
View Full Code Here

        {
            litValue = fLiteral;
        }
        else if ((iLiteral = p.parseIntegerLiteral()) != null)
        {
            litValue = Long.valueOf(iLiteral.longValue());
        }
        else if ((bLiteral = p.parseBooleanLiteralIgnoreCase()) != null)
        {
            litValue = bLiteral;
        }
View Full Code Here

        return values.get(index);
      case SUM:
        BigInteger sum = BigInteger.valueOf(0);
        for (int i = 0; i < values.size(); ++i)
          sum = sum.add(BigInteger.valueOf(values.get(i)));
        return sum.longValue();
      case MIN:
        BigInteger minimum = BigInteger.valueOf(values.get(0));
        for (int i = 1; i < values.size(); ++i)
          if (minimum.compareTo(BigInteger.valueOf(
              values.get(i))) > 0)
View Full Code Here

        BigInteger minimum = BigInteger.valueOf(values.get(0));
        for (int i = 1; i < values.size(); ++i)
          if (minimum.compareTo(BigInteger.valueOf(
              values.get(i))) > 0)
            minimum = BigInteger.valueOf(values.get(i));
        return minimum.longValue();
      case MAX:
        BigInteger maximum = BigInteger.valueOf(values.get(0));
        for (int i = 1; i < values.size(); ++i)
          if (maximum.compareTo(BigInteger.valueOf(
              values.get(i))) < 0)
View Full Code Here

        BigInteger maximum = BigInteger.valueOf(values.get(0));
        for (int i = 1; i < values.size(); ++i)
          if (maximum.compareTo(BigInteger.valueOf(
              values.get(i))) < 0)
            maximum = BigInteger.valueOf(values.get(i));
        return maximum.longValue();
      case FIRST:
        return values.get(0);
      case LAST:
        return values.get(values.size() - 1);
      default:
View Full Code Here

        BigInteger big = value.getValue();

        if (big.compareTo(LONG_MIN) < 0 || big.compareTo(LONG_MAX) > 0) {
            throw value.getRuntime().newRangeError("bignum too big to convert into `long'");
        }
        return big.longValue();
    }

    /** rb_big2dbl
     *
     */
 
View Full Code Here

        else if (arg instanceof RubyBignum) {
            BigInteger big = ((RubyBignum)arg).getValue();
            if (big.compareTo(QUAD_MIN) < 0 || big.compareTo(QUAD_MAX) > 0) {
                throw arg.getRuntime().newRangeError("bignum too big to convert into `quad int'");
            }
            return big.longValue();
        }
        return RubyNumeric.num2long(arg);
    }

    static {
View Full Code Here

        BigInteger ulongValue = new BigInteger("1234567");
        writer.writeULong(ulongValue);
       
        InputStream iStream = oStream.create_input_stream();
        long ul = iStream.read_ulong();
        assertTrue(ul == ulongValue.longValue());
    }
   
    public void testWriteLongLong() {
        Buffer buf = new Buffer();
        OutputStream oStream = new OutputStream(buf);
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.