Package java.math

Examples of java.math.BigInteger.abs()


                result.set(Calendar.YEAR, Math.abs(year));
            }
            else {
                final BigInteger eonAndYear = getEonAndYear();
                result.set(Calendar.ERA, eonAndYear.signum() == -1 ? GregorianCalendar.BC : GregorianCalendar.AD);
                result.set(Calendar.YEAR, eonAndYear.abs().intValue());
            }
        }
        else {
            // use default if set
            if (defaults != null) {
View Full Code Here


                        result.set(Calendar.YEAR, Math.abs(defaultYear));
                    }
                    else {
                        final BigInteger defaultEonAndYear = defaults.getEonAndYear();
                        result.set(Calendar.ERA, defaultEonAndYear.signum() == -1 ? GregorianCalendar.BC : GregorianCalendar.AD);
                        result.set(Calendar.YEAR, defaultEonAndYear.abs().intValue());
                    }
                }
            }
        }
View Full Code Here

    public static BigInteger hashToBigInteger(ByteBuffer data)
    {
        byte[] result = hash(data);
        BigInteger hash = new BigInteger(result);
        return hash.abs();       
    }

    public static byte[] hash(ByteBuffer... data)
    {
        MessageDigest messageDigest = localMD5Digest.get();
View Full Code Here

    public static BigInteger hash(String data)
    {
        byte[] result = hash("MD5", data.getBytes());
        BigInteger hash = new BigInteger(result);
        return hash.abs();       
    }

    public static byte[] hash(String type, byte[]... data)
    {
      byte[] result = null;
View Full Code Here

            }
            if (big.signum() < 0) {
                if (restrictive) {
                    return context.nil;
                }
                big = big.abs();
            }
            big = big.subtract(BigInteger.ONE);
            return randLimitedBignum(context, random, RubyBignum.newBignum(context.runtime, big));
        }
    }
View Full Code Here

                    this.mt = new Random(ints);
                }
            } else if (seed instanceof RubyBignum) {
                BigInteger big = ((RubyBignum) seed).getBigIntegerValue();
                if (big.signum() < 0) {
                    big = big.abs();
                }
                byte[] buf = big.toByteArray();
                int buflen = buf.length;
                if (buf[0] == 0) {
                    buflen -= 1;
View Full Code Here

                                for (int i = 0; i < bigIntValues.length; i++) {
                                    BigInteger bigIntValue = bigIntValues[i];
                                    if (bigIntValue.signum() < 0) {
                                        maybeMinusNodes[i] = new ParseTreeNode(CALTreeParserTokenTypes.MINUS, "-");
                                        maybeMinusNodes[i].setFirstChild(
                                                new ParseTreeNode(CALTreeParserTokenTypes.INTEGER_LITERAL, bigIntValue.abs().toString()));
                                       
                                    } else {
                                        maybeMinusNodes[i] = new ParseTreeNode(CALTreeParserTokenTypes.INTEGER_LITERAL, bigIntValue.toString());
                                    }
                                }
View Full Code Here

        }

        BigInteger year = xgc.getEonAndYear();
        if (year != null) {
            cal.set(Calendar.ERA, year.signum() < 0 ? GregorianCalendar.BC : GregorianCalendar.AD);
            cal.set(Calendar.YEAR, year.abs().intValue());
        }

        if (xgc.getDay() != DatatypeConstants.FIELD_UNDEFINED)
            cal.set(Calendar.DAY_OF_MONTH, xgc.getDay());
View Full Code Here

        if (value == null) {
            write((byte) 0);
        } else {
            byte signum = (byte) (value.signum() < 0 ? 0 : 1);
            BigInteger bi = value.unscaledValue();
            byte mantisse[] = bi.abs().toByteArray();
            byte len = (byte) (mantisse.length + 1);

            if (len > getMaxDecimalBytes()) {
                // Should never happen now as value is normalized elsewhere
                throw new IOException("BigDecimal to big to send");
View Full Code Here

 
  // if year( and eon) are undefined, leave default Calendar values
  BigInteger year = getEonAndYear();
  if (year != null) {
    result.set(Calendar.ERA, year.signum() == -1 ? GregorianCalendar.BC : GregorianCalendar.AD);
    result.set(Calendar.YEAR, year.abs().intValue());
  }
 
  // only set month if it is set
  if (month != DatatypeConstants.FIELD_UNDEFINED) {
    // Calendar.MONTH is zero based while XMLGregorianCalendar month field is not.
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.