Package java.math

Examples of java.math.BigDecimal.movePointRight()


      dst.put(POS_SMALL);
    }

    // normalize abs(val) to determine E
    while (abs.compareTo(EN10) < 0) { abs = abs.movePointRight(8); e += 4; }
    while (abs.compareTo(EN2) < 0) { abs = abs.movePointRight(2); e++; }

    putVaruint64(dst, e, !isNeg); // encode appropriate E value.

    // encode M by peeling off centimal digits, encoding x as 2x+1
    startM = dst.getPosition();
View Full Code Here


    // encode M by peeling off centimal digits, encoding x as 2x+1
    startM = dst.getPosition();
    // TODO: 18 is an arbitrary encoding limit. Reevaluate once we have a better handling of
    // numeric scale.
    for (int i = 0; i < 18 && abs.compareTo(BigDecimal.ZERO) != 0; i++) {
      abs = abs.movePointRight(2);
      d = abs.intValue();
      dst.put((byte) ((2 * d + 1) & 0xff));
      abs = abs.subtract(BigDecimal.valueOf(d));
    }
    a[offset + dst.getPosition() - 1] &= 0xfe; // terminal digit should be 2x
View Full Code Here

    // encode M by peeling off centimal digits, encoding x as 2x+1
    startM = dst.getPosition();
    // TODO: 18 is an arbitrary encoding limit. Reevaluate once we have a better handling of
    // numeric scale.
    for (int i = 0; i < 18 && abs.compareTo(BigDecimal.ZERO) != 0; i++) {
      abs = abs.movePointRight(2);
      d = abs.intValue();
      dst.put((byte) (2 * d + 1));
      abs = abs.subtract(BigDecimal.valueOf(d));
    }

View Full Code Here

        calendar.add(Calendar.SECOND, getSeconds() * signum);

        if (seconds != null) {
            BigDecimal fraction =
                seconds.subtract(seconds.setScale(0, BigDecimal.ROUND_DOWN));
            int millisec = fraction.movePointRight(3).intValue();
            calendar.add(Calendar.MILLISECOND, millisec * signum);
        }
    }

    /**
 
View Full Code Here

        calendar.add(Calendar.SECOND, getSeconds() * signum);

        if (seconds != null) {
            BigDecimal fraction =
                seconds.subtract(seconds.setScale(0, BigDecimal.ROUND_DOWN));
            int millisec = fraction.movePointRight(3).intValue();
            calendar.add(Calendar.MILLISECOND, millisec * signum);
        }
    }
   
    /**
 
View Full Code Here

                                                           getErrorString(DatatypeMessageProvider.ScaleExceeded,
                                                                          DatatypeMessageProvider.MSG_NONE,
                                                                          new Object[] { content}));
            }
            if ( isPrecisionDefined == true ) {
                int precision = d.movePointRight(d.scale()).toString().length() -
                                ((d.signum() < 0) ? 1 : 0); // account for minus sign

                if (precision > fPrecision)
                    throw new InvalidDatatypeValueException(
                             getErrorString(DatatypeMessageProvider.PrecisionExceeded,
View Full Code Here

        }

        value = value.setScale(0, BigDecimal.ROUND_FLOOR);
        value = ((BigDecimal) a).subtract(value);

        return value.movePointRight(scale).longValue();
    }

    public static boolean isInLongLimits(BigDecimal result) {

        if (NumberType.MIN_LONG.compareTo(result) > 0
View Full Code Here

        calendar.add(Calendar.SECOND, getSeconds() * signum);

        if (seconds != null) {
            BigDecimal fraction =
                seconds.subtract(seconds.setScale(0, BigDecimal.ROUND_DOWN));
            int millisec = fraction.movePointRight(3).intValue();
            calendar.add(Calendar.MILLISECOND, millisec * signum);
        }
    }
   
    /**
 
View Full Code Here

                                                        getErrorString(DatatypeMessageProvider.ScaleExceeded,
                                                                        DatatypeMessageProvider.MSG_NONE,
                                                                        new Object[] { content}));
        }
        if ( isPrecisionDefined == true ) {
            int precision = d.movePointRight(d.scale()).toString().length() -
                            ((d.signum() < 0) ? 1 : 0); // account for minus sign
            if (precision > fPrecision)
                throw new InvalidDatatypeValueException(
                                getErrorString(DatatypeMessageProvider.PrecisionExceeded,
                                 DatatypeMessageProvider.MSG_NONE,
View Full Code Here

    } else { /* Small positive number: 0x16, ~-E, M */
      dst.put(POS_SMALL);
    }

    // normalize abs(val) to determine E
    while (abs.compareTo(EN10) < 0) { abs = abs.movePointRight(8); e += 4; }
    while (abs.compareTo(EN2) < 0) { abs = abs.movePointRight(2); e++; }

    putVaruint64(dst, e, !isNeg); // encode appropriate E value.

    // encode M by peeling off centimal digits, encoding x as 2x+1
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.