Example usage for java.math RoundingMode CEILING

List of usage examples for java.math RoundingMode CEILING

Introduction

In this page you can find the example usage for java.math RoundingMode CEILING.

Prototype

RoundingMode CEILING

To view the source code for java.math RoundingMode CEILING.

Click Source Link

Document

Rounding mode to round towards positive infinity.

Usage

From source file:GeMSE.GS.Analysis.Stats.TwoSamplePearsonsCorrelationPanel.java

public TwoSamplePearsonsCorrelationPanel() {
    initComponents();//from w ww  .  java  2 s .co  m

    _decFor = new DecimalFormat("#.#########");
    _decFor.setRoundingMode(RoundingMode.CEILING);
    DecimalFormatSymbols decFors = _decFor.getDecimalFormatSymbols();
    decFors.setNaN("NaN");
    decFors.setInfinity("");
    _decFor.setDecimalFormatSymbols(decFors);
}

From source file:Util.java

public static BigDecimal[] quadratic(BigDecimal a, BigDecimal b, BigDecimal c, RoundingMode rounding) {
    // ax^2 + bx + c = 0
    BigDecimal part1 = b.negate();
    BigDecimal part2 = sqrt(b.multiply(b).subtract(BigDecimalFOUR.multiply(a).multiply(c)), rounding);
    BigDecimal part3 = BigDecimalTWO.multiply(a);
    BigDecimal[] toRet = new BigDecimal[2];
    toRet[0] = (part1.subtract(part2)).divide(part3, RoundingMode.CEILING);
    toRet[1] = (part1.add(part2)).divide(part3, RoundingMode.CEILING);
    return toRet;
}

From source file:GeMSE.GS.Analysis.Stats.OneSampleTTestPanel.java

public OneSampleTTestPanel() {
    initComponents();//www .  java  2  s  . c  om
    _sample = new double[0];
    _studentTest = new TTest();

    _decFor = new DecimalFormat("#.#########");
    _decFor.setRoundingMode(RoundingMode.CEILING);
    DecimalFormatSymbols decFors = _decFor.getDecimalFormatSymbols();
    decFors.setNaN("NaN");
    decFors.setInfinity("");
    _decFor.setDecimalFormatSymbols(decFors);
}

From source file:GeMSE.GS.Analysis.Stats.TwoSampleTTestPanel.java

public TwoSampleTTestPanel() {
    initComponents();/*from  w w  w . j a v  a2  s. c  om*/
    _sample1 = new double[0];
    _sample2 = new double[0];

    _decFor = new DecimalFormat("#.#########");
    _decFor.setRoundingMode(RoundingMode.CEILING);
    DecimalFormatSymbols decFors = _decFor.getDecimalFormatSymbols();
    decFors.setNaN("NaN");
    decFors.setInfinity("");
    _decFor.setDecimalFormatSymbols(decFors);

    _variance = new Variance();
    _studentTest = new TTest();
}

From source file:org.whispersystems.bithub.views.TransactionView.java

private String getAmountInDollars(BigDecimal exchangeRate, String amount) {
    return new BigDecimal(amount).abs().multiply(exchangeRate).setScale(2, RoundingMode.CEILING)
            .toPlainString();//from   w w w  . j a va  2 s . com
}

From source file:com.khartec.waltz.jobs.sample.AssetCostGenerator.java

private static BigDecimal generateAmount(long mean) {
    double z = mean / 3.4;
    double val = rnd.nextGaussian() * z + mean;

    return BigDecimal.valueOf(val).setScale(2, RoundingMode.CEILING);
}

From source file:com.github.rinde.rinsim.central.arrays.ArraysSolversTest.java

@Test
public void travelTimeMatrix() {
    final Point p0 = new Point(0, 0);
    final Point p1 = new Point(10, 0);
    final Point p2 = new Point(10, 10);
    final Point p3 = new Point(0, 10);

    // input in kilometers, output in minutes (rounded up), speed 40 km/h
    final Measure<Double, Velocity> speed1 = Measure.valueOf(40d, KILOMETERS_PER_HOUR);
    final int[][] matrix1 = ArraysSolvers.toTravelTimeMatrix(asList(p0, p1, p2, p3), KILOMETER, speed1, MINUTE,
            RoundingMode.CEILING);
    assertArrayEquals(new int[] { 0, 15, 22, 15 }, matrix1[0]);
    assertArrayEquals(new int[] { 15, 0, 15, 22 }, matrix1[1]);
    assertArrayEquals(new int[] { 22, 15, 0, 15 }, matrix1[2]);
    assertArrayEquals(new int[] { 15, 22, 15, 0 }, matrix1[3]);

    final Point p4 = new Point(11, 3);
    // input in meters, output in milliseconds (round down), speed .0699
    // m/ms/* w  w  w .  j  av  a2  s.  c o  m*/
    final Measure<Double, Velocity> speed2 = Measure.valueOf(.0699,
            new ProductUnit<Velocity>(METER.divide(MILLI(SECOND))));
    final int[][] matrix2 = ArraysSolvers.toTravelTimeMatrix(asList(p0, p1, p2, p3, p4), METER, speed2,
            MILLI(SECOND), RoundingMode.FLOOR);
    assertArrayEquals(new int[] { 0, 143, 202, 143, 163 }, matrix2[0]);
    assertArrayEquals(new int[] { 143, 0, 143, 202, 45 }, matrix2[1]);
    assertArrayEquals(new int[] { 202, 143, 0, 143, 101 }, matrix2[2]);
    assertArrayEquals(new int[] { 143, 202, 143, 0, 186 }, matrix2[3]);
    assertArrayEquals(new int[] { 163, 45, 101, 186, 0 }, matrix2[4]);
}

From source file:yadrone.DroneGUI.java

/**
 * Constructor// w  w  w  .j a  va2 s .  c o m
 *
 * @param drone Drone object
 * @param pil Image panel with processed image stream
 * @param cont DroneControl object for receiving navigation data
 * @param regulator Object for reading and setting PID parameters
 * @param cd Object for reading and setting thresholding parameters
 */
public DroneGUI(IARDrone drone, DroneControl cont, ProcessedImagePanel pil, TimerTask regulator,
        CircleDetection cd, int[] resolution) {
    this.drone = drone;
    this.cont = cont;
    this.pil = pil;
    this.regulator = (Regulator) regulator;
    this.cd = cd;
    v1 = new VideoListener(drone, resolution);
    navData = new NavDataListener(drone);
    try {
        for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (Exception e) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception ex) {
        }

    }
    df.setRoundingMode(RoundingMode.CEILING);
    initComponents();
    updateTextFields();
    this.setVisible(true);
}

From source file:pt.ist.fenix.ui.spring.AnnouncementsAdminController.java

@RequestMapping(method = RequestMethod.GET)
public AnnouncementsAdminView all(Model model, @PathVariable ExecutionCourse executionCourse,
        @RequestParam(required = false, defaultValue = "1") int page) {
    Professorship professorship = executionCourse.getProfessorship(AccessControl.getPerson());
    AccessControl.check(person -> professorship != null && professorship.getPermissions().getAnnouncements());
    List<Post> announcements = getAnnouncements(executionCourse.getSite());
    model.addAttribute("executionCourse", executionCourse);
    int pages = IntMath.divide(announcements.size(), PER_PAGE, RoundingMode.CEILING);
    if (page < 1) {
        page = 1;//from w  ww . ja v  a 2 s  .  c om
    }
    if (pages > 0 && page > pages) {
        page = pages;
    }
    model.addAttribute("currentPage", page);
    model.addAttribute("pages", pages);
    model.addAttribute("announcements",
            announcements.stream().skip((page - 1) * PER_PAGE).limit(PER_PAGE).collect(Collectors.toList()));
    model.addAttribute("professorship", professorship);
    return new AnnouncementsAdminView();
}

From source file:com.github.rinde.rinsim.examples.demo.factory.AgvModel.java

void init() {
    if (simulator.isPresent() && rm.isPresent()) {
        int max = 0;
        for (final List<Point> ps : points) {
            max = Math.max(max, ps.size());
        }// w w  w  . j a v  a2  s . c  o  m
        final int num = max;
        for (int i = 0; i < num; i++) {
            final long duration = DoubleMath.roundToLong(
                    FactoryExample.SERVICE_DURATION / 2d + rng.nextDouble() * FactoryExample.SERVICE_DURATION,
                    RoundingMode.CEILING);

            final Point rnd = rndBorder();
            Point dest;
            if (i >= points.get(0).size()) {
                dest = rndBorder();
            } else {
                dest = points.get(0).get(i);
                occupiedPositions.add(dest);
            }

            final BoxHandle bh = new BoxHandle(i);
            final Box b = new Box(rnd, dest, duration, bh);
            bh.box = b;

            boxes.add(bh);
            simulator.get().register(verifyNotNull(boxes.get(boxes.size() - 1).box));
        }
    }
}