Package java.math

Examples of java.math.BigDecimal.movePointRight()


    } 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


      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

        }

        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

        }
        long n = nanos;
        BigDecimal bd = BigDecimal.valueOf(n);
        bd = bd.movePointLeft(9);
        bd = MathUtils.setScale(bd, targetScale);
        bd = bd.movePointRight(9);
        long n2 = bd.longValue();
        if (n2 == n) {
            return this;
        }
        return fromDateValueAndNanos(dateValue, n2);
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

    } 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

      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

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.