List of usage examples for java.math BigDecimal ROUND_HALF_DOWN
int ROUND_HALF_DOWN
To view the source code for java.math BigDecimal ROUND_HALF_DOWN.
Click Source Link
From source file:org.onebusaway.api.actions.siri.impl.SiriSupportV2.java
public static boolean fillAnnotatedLineStructure(AnnotatedLineStructure annotatedLineStructure, RouteResult routeResult, Map<Filters, String> filters, DetailLevel detailLevel, long currentTime) { Directions directions = new Directions(); // Set Line Value LineRefStructure line = new LineRefStructure(); line.setValue(routeResult.getId());// ww w .j av a 2 s . com NaturalLanguageStringStructure lineName = new NaturalLanguageStringStructure(); lineName.setValue(routeResult.getShortName()); // DETAIL - minimum: Return only the name and identifier of stops //ideally, this would return only stops with scheduled service annotatedLineStructure.setLineRef(line); annotatedLineStructure.getLineName().add(lineName); annotatedLineStructure.setDirections(directions); annotatedLineStructure.setMonitored(true); // Loop through Direction Ids for (RouteDirection direction : routeResult.getDirections()) { // Check for existing stops in direction if (direction == null | direction.getStops().size() == 0) continue; String directionId = direction.getDirectionId(); // Journey patterns - holds stop points for direction JourneyPattern pattern = new JourneyPattern(); JourneyPatterns patterns = new JourneyPatterns(); // Directions DirectionRefStructure dirRefStructure = new DirectionRefStructure(); dirRefStructure.setValue(directionId); RouteDirectionStructure routeDirectionStructure = new RouteDirectionStructure(); NaturalLanguageStringStructure directionName = new NaturalLanguageStringStructure(); directionName.setValue(direction.getDestination()); routeDirectionStructure.getDirectionName().add(directionName); directions.getDirection().add(routeDirectionStructure); // Destination Destinations destinations = new Destinations(); AnnotatedDestinationStructure annotatedDest = new AnnotatedDestinationStructure(); DestinationRefStructure destRef = new DestinationRefStructure(); destRef.setValue(direction.getDestination()); annotatedDest.setDestinationRef(destRef); destinations.getDestination().add(annotatedDest); // Stops StopsInPattern stopsInPattern = new StopsInPattern(); List<StopOnRoute> scheduledStops = new ArrayList<StopOnRoute>(); List<StopOnRoute> allStops = new ArrayList<StopOnRoute>(); // Loop through StopOnRoute for particular Direction Id // Categorize by Scheduled and Unscheduled Stops for (StopOnRoute stop : direction.getStops()) { if (stop.getHasUpcomingScheduledStop() != null && stop.getHasUpcomingScheduledStop()) scheduledStops.add(stop); allStops.add(stop); } // DETAIL -- normal: Return name, identifier and coordinates of the stop.?? // my interpretation is that normal returns the list of stops with coordinates and their polylines //ideally, this would return only stops with scheduled service if (detailLevel.equals(DetailLevel.NORMAL)) { for (int i = 0; i < scheduledStops.size(); i++) { StopOnRoute stop = direction.getStops().get(i); BigDecimal stopLat = new BigDecimal(stop.getLatitude()); BigDecimal stopLon = new BigDecimal(stop.getLongitude()); LocationStructure location = new LocationStructure(); location.setLongitude(stopLon.setScale(6, BigDecimal.ROUND_HALF_DOWN)); location.setLatitude(stopLat.setScale(6, BigDecimal.ROUND_HALF_DOWN)); StopPointInPatternStructure pointInPattern = new StopPointInPatternStructure(); pointInPattern.setLocation(location); pointInPattern.setOrder(BigInteger.valueOf(i)); NaturalLanguageStringStructure stopName = new NaturalLanguageStringStructure(); stopName.setValue(stop.getName()); pointInPattern.getStopName().add(stopName); StopPointRefStructure spr = new StopPointRefStructure(); spr.setValue(stop.getId()); stopsInPattern.getStopPointInPattern().add(pointInPattern); } } // DETAIL -- stops: Return name, identifier and coordinates of the stop.?? // my interpretation is that normal returns the list of stops with coordinates and their polylines //ideally, this would return both stops with scheduled and unscheduled service if (detailLevel.equals(DetailLevel.STOPS) || detailLevel.equals(DetailLevel.FULL)) { for (int i = 0; i < allStops.size(); i++) { StopOnRoute stop = direction.getStops().get(i); Boolean hasUpcomingScheduledService = stop.getHasUpcomingScheduledStop(); BigDecimal stopLat = new BigDecimal(stop.getLatitude()); BigDecimal stopLon = new BigDecimal(stop.getLongitude()); LocationStructure location = new LocationStructure(); location.setLongitude(stopLon.setScale(6, BigDecimal.ROUND_HALF_DOWN)); location.setLatitude(stopLat.setScale(6, BigDecimal.ROUND_HALF_DOWN)); StopPointRefStructure spr = new StopPointRefStructure(); spr.setValue(stop.getId()); StopPointInPatternStructure pointInPattern = new StopPointInPatternStructure(); pointInPattern.setLocation(location); pointInPattern.setOrder(BigInteger.valueOf(i)); NaturalLanguageStringStructure stopName = new NaturalLanguageStringStructure(); stopName.setValue(stop.getName()); pointInPattern.getStopName().add(stopName); pointInPattern.setStopPointRef(spr); stopsInPattern.getStopPointInPattern().add(pointInPattern); // HasUpcomingService Extension SiriUpcomingServiceExtension upcomingService = new SiriUpcomingServiceExtension(); upcomingService.setUpcomingScheduledService(hasUpcomingScheduledService); ExtensionsStructure upcomingServiceExtensions = new ExtensionsStructure(); upcomingServiceExtensions.setAny(upcomingService); pointInPattern.setExtensions(upcomingServiceExtensions); } } String includePolylineFilter = filters.get(Filters.INCLUDE_POLYLINES); if (includePolylineFilter != null && passFilter("true", includePolylineFilter)) { // Polyline Extension SiriPolyLinesExtension polylines = new SiriPolyLinesExtension(); for (String polyline : direction.getPolylines()) { polylines.getPolylines().add(polyline); } ExtensionsStructure PolylineExtension = new ExtensionsStructure(); PolylineExtension.setAny(polylines); routeDirectionStructure.setExtensions(PolylineExtension); } routeDirectionStructure.setJourneyPatterns(patterns); pattern.setStopsInPattern(stopsInPattern); patterns.getJourneyPattern().add(pattern); routeDirectionStructure.setDirectionRef(dirRefStructure); } return true; }
From source file:org.onebusaway.api.actions.siri.RealtimeServiceTest.java
@Test public void testStopPointsByRoute() throws Exception { when(transitDataService.getRouteForId("1_100194")).thenReturn(routeBean); when(transitDataService.getStopsForRoute("1_100194")).thenReturn(stopsForRouteBean); when(transitDataService.stopHasUpcomingScheduledService(anyString(), anyLong(), anyString(), anyString(), anyString())).thenReturn(true); LineDirectionStructure lds = new LineDirectionStructure(); DirectionRefStructure drs = new DirectionRefStructure(); LineRefStructure lrs = new LineRefStructure(); lds.setDirectionRef(drs);/*from w w w .java2 s .com*/ lds.setLineRef(lrs); drs.setValue("0"); lrs.setValue("1_100194"); LocationStructure ls = new LocationStructure(); BigDecimal lat = new BigDecimal(47.610813); BigDecimal lon = new BigDecimal(-122.338662); ls.setLatitude(lat.setScale(6, BigDecimal.ROUND_HALF_DOWN)); ls.setLongitude(lon.setScale(6, BigDecimal.ROUND_HALF_DOWN)); NaturalLanguageStringStructure stopName = new NaturalLanguageStringStructure(); stopName.setValue("3rd Ave & Pine St"); List<NaturalLanguageStringStructure> stopNames = new ArrayList<NaturalLanguageStringStructure>(); stopNames.add(stopName); StopPointRefStructure stopPointRef = new StopPointRefStructure(); stopPointRef.setValue("1_430"); Boolean monitored = true; AnnotatedStopPointStructure mockStopPoint = new AnnotatedStopPointStructure(); mockStopPoint.setLines(new AnnotatedStopPointStructure.Lines()); mockStopPoint.getLines().getLineRefOrLineDirection().add(lds); mockStopPoint.setLocation(ls); mockStopPoint.getStopName().add(stopName); mockStopPoint.setStopPointRef(stopPointRef); mockStopPoint.setMonitored(monitored); // REALTIME ARGUMENTS // Agency Ids List<String> agencyIds = new ArrayList<String>(); String agencyId = "1"; agencyIds.add(agencyId); // Route Ids List<AgencyAndId> routeIds = new ArrayList<AgencyAndId>(); AgencyAndId routeId = AgencyAndIdLibrary.convertFromString("1_100194"); routeIds.add(routeId); // Detail Level DetailLevel detailLevel = DetailLevel.NORMAL; // Time long time = System.currentTimeMillis(); // Filters Map<Filters, String> filters = new HashMap<Filters, String>(); Map<Boolean, List<AnnotatedStopPointStructure>> actualResult = realtimeService .getAnnotatedStopPointStructures(agencyIds, routeIds, detailLevel, time, filters); AnnotatedStopPointStructure actualStopPoint = actualResult.get(true).get(0); assertTrue(isEqual(mockStopPoint, actualStopPoint)); }
From source file:org.onebusaway.api.actions.siri.RealtimeServiceTest.java
@Test public void testStopPointsByBounds() throws Exception { // MOCKS// ww w .j a v a2 s . co m // Coordinate Bounds CoordinateBounds bounds = new CoordinateBounds(Double.parseDouble("47.612813"), Double.parseDouble("-122.339662"), Double.parseDouble("47.608813"), Double.parseDouble("-122.337662")); // Stops For Bounds StopsBean stopsBean = new StopsBean(); stopsBean.setStops(stops); when(transitDataService.getRouteForId("1_100194")).thenReturn(routeBean); when(transitDataService.getStops(any(SearchQueryBean.class))).thenReturn(stopsBean); when(transitDataService.getStopsForRoute("1_100194")).thenReturn(stopsForRouteBean); when(transitDataService.stopHasUpcomingScheduledService(anyString(), anyLong(), anyString(), anyString(), anyString())).thenReturn(true); // EXPECTED LineDirectionStructure lds = new LineDirectionStructure(); DirectionRefStructure drs = new DirectionRefStructure(); LineRefStructure lrs = new LineRefStructure(); lds.setDirectionRef(drs); lds.setLineRef(lrs); drs.setValue("0"); lrs.setValue("1_100194"); LocationStructure ls = new LocationStructure(); BigDecimal lat = new BigDecimal(47.610813); BigDecimal lon = new BigDecimal(-122.338662); ls.setLatitude(lat.setScale(6, BigDecimal.ROUND_HALF_DOWN)); ls.setLongitude(lon.setScale(6, BigDecimal.ROUND_HALF_DOWN)); NaturalLanguageStringStructure stopName = new NaturalLanguageStringStructure(); stopName.setValue("3rd Ave & Pine St"); List<NaturalLanguageStringStructure> stopNames = new ArrayList<NaturalLanguageStringStructure>(); stopNames.add(stopName); StopPointRefStructure stopPointRef = new StopPointRefStructure(); stopPointRef.setValue("1_430"); Boolean monitored = true; AnnotatedStopPointStructure mockStopPoint = new AnnotatedStopPointStructure(); mockStopPoint.setLines(new AnnotatedStopPointStructure.Lines()); mockStopPoint.getLines().getLineRefOrLineDirection().add(lds); mockStopPoint.setLocation(ls); mockStopPoint.getStopName().add(stopName); mockStopPoint.setStopPointRef(stopPointRef); mockStopPoint.setMonitored(monitored); // REALTIME ARGUMENTS // Agency Ids List<String> agencyIds = new ArrayList<String>(); String agencyId = "1"; agencyIds.add(agencyId); // Route Ids List<AgencyAndId> routeIds = new ArrayList<AgencyAndId>(); AgencyAndId routeId = AgencyAndIdLibrary.convertFromString("1_100194"); routeIds.add(routeId); // Detail Level DetailLevel detailLevel = DetailLevel.NORMAL; // Time long time = System.currentTimeMillis(); // Filters Map<Filters, String> filters = new HashMap<Filters, String>(); Map<Boolean, List<AnnotatedStopPointStructure>> actualResult = realtimeService .getAnnotatedStopPointStructures(bounds, agencyIds, routeIds, detailLevel, time, filters); AnnotatedStopPointStructure actualStopPoint = actualResult.get(true).get(0); assertTrue(isEqual(mockStopPoint, actualStopPoint)); }
From source file:org.onebusaway.nyc.webapp.actions.api.siri.impl.SiriSupportV2.java
public static boolean fillAnnotatedLineStructure(AnnotatedLineStructure annotatedLineStructure, RouteResult routeResult, Map<Filters, String> filters, DetailLevel detailLevel, long currentTime) { Directions directions = new Directions(); // Set Line Value LineRefStructure line = new LineRefStructure(); line.setValue(routeResult.getId());/*from w w w .j a va 2s . c om*/ NaturalLanguageStringStructure lineName = new NaturalLanguageStringStructure(); lineName.setValue(routeResult.getShortName()); // DETAIL - minimum: Return only the name and identifier of stops //ideally, this would return only stops with scheduled service annotatedLineStructure.setLineRef(line); annotatedLineStructure.getLineName().add(lineName); annotatedLineStructure.setDirections(directions); annotatedLineStructure.setMonitored(true); // Loop through Direction Ids for (RouteDirection direction : routeResult.getDirections()) { // Check for existing stops in direction if (direction == null | direction.getStops().size() == 0) continue; String directionId = direction.getDirectionId(); // Journey patterns - holds stop points for direction JourneyPattern pattern = new JourneyPattern(); JourneyPatterns patterns = new JourneyPatterns(); // Directions DirectionRefStructure dirRefStructure = new DirectionRefStructure(); dirRefStructure.setValue(directionId); RouteDirectionStructure routeDirectionStructure = new RouteDirectionStructure(); NaturalLanguageStringStructure directionName = new NaturalLanguageStringStructure(); directionName.setValue(direction.getDestination()); routeDirectionStructure.getDirectionName().add(directionName); directions.getDirection().add(routeDirectionStructure); // Destination Destinations destinations = new Destinations(); AnnotatedDestinationStructure annotatedDest = new AnnotatedDestinationStructure(); DestinationRefStructure destRef = new DestinationRefStructure(); destRef.setValue(direction.getDestination()); annotatedDest.setDestinationRef(destRef); destinations.getDestination().add(annotatedDest); // Stops StopsInPattern stopsInPattern = new StopsInPattern(); List<StopOnRoute> scheduledStops = new ArrayList<StopOnRoute>(); List<StopOnRoute> allStops = new ArrayList<StopOnRoute>(); // Loop through StopOnRoute for particular Direction Id // Categorize by Scheduled and Unscheduled Stops for (StopOnRoute stop : direction.getStops()) { if (stop.getHasUpcomingScheduledStop() != null && stop.getHasUpcomingScheduledStop()) scheduledStops.add(stop); allStops.add(stop); } // DETAIL -- normal: Return name, identifier and coordinates of the stop.?? // my interpretation is that normal returns the list of stops with coordinates and their polylines //ideally, this would return only stops with scheduled service if (detailLevel.equals(DetailLevel.NORMAL)) { for (int i = 0; i < scheduledStops.size(); i++) { StopOnRoute stop = direction.getStops().get(i); BigDecimal stopLat = new BigDecimal(stop.getLatitude()); BigDecimal stopLon = new BigDecimal(stop.getLongitude()); LocationStructure location = new LocationStructure(); location.setLongitude(stopLon.setScale(6, BigDecimal.ROUND_HALF_DOWN)); location.setLatitude(stopLat.setScale(6, BigDecimal.ROUND_HALF_DOWN)); StopPointInPatternStructure pointInPattern = new StopPointInPatternStructure(); pointInPattern.setLocation(location); pointInPattern.setOrder(BigInteger.valueOf(i)); NaturalLanguageStringStructure stopName = new NaturalLanguageStringStructure(); stopName.setValue(stop.getName()); pointInPattern.getStopName().add(stopName); StopPointRefStructure spr = new StopPointRefStructure(); spr.setValue(stop.getId()); stopsInPattern.getStopPointInPattern().add(pointInPattern); } } // DETAIL -- stops: Return name, identifier and coordinates of the stop.?? // my interpretation is that normal returns the list of stops with coordinates and their polylines //ideally, this would return both stops with scheduled and unscheduled service if (detailLevel.equals(DetailLevel.STOPS) || detailLevel.equals(DetailLevel.FULL)) { for (int i = 0; i < allStops.size(); i++) { StopOnRoute stop = direction.getStops().get(i); Boolean hasUpcomingScheduledService = stop.getHasUpcomingScheduledStop(); BigDecimal stopLat = new BigDecimal(stop.getLatitude()); BigDecimal stopLon = new BigDecimal(stop.getLongitude()); LocationStructure location = new LocationStructure(); location.setLongitude(stopLon.setScale(6, BigDecimal.ROUND_HALF_DOWN)); location.setLatitude(stopLat.setScale(6, BigDecimal.ROUND_HALF_DOWN)); StopPointRefStructure spr = new StopPointRefStructure(); spr.setValue(stop.getId()); StopPointInPatternStructure pointInPattern = new StopPointInPatternStructure(); pointInPattern.setLocation(location); pointInPattern.setOrder(BigInteger.valueOf(i)); NaturalLanguageStringStructure stopName = new NaturalLanguageStringStructure(); stopName.setValue(stop.getName()); pointInPattern.getStopName().add(stopName); pointInPattern.setStopPointRef(spr); stopsInPattern.getStopPointInPattern().add(pointInPattern); // HasUpcomingService Extension SiriUpcomingServiceExtension upcomingService = new SiriUpcomingServiceExtension(); upcomingService.setUpcomingScheduledService(hasUpcomingScheduledService); ExtensionsStructure upcomingServiceExtensions = new ExtensionsStructure(); upcomingServiceExtensions.setAny(upcomingService); pointInPattern.setExtensions(upcomingServiceExtensions); } } String includePolylineFilter = filters.get(Filters.INCLUDE_POLYLINES); if (includePolylineFilter != null && passFilter("true", includePolylineFilter)) { // Polyline Extension SiriPolyLinesExtension polylines = new SiriPolyLinesExtension(); for (String polyline : direction.getPolylines()) { polylines.getPolylines().add(polyline); } ExtensionsStructure PolylineExtension = new ExtensionsStructure(); PolylineExtension.setAny(polylines); routeDirectionStructure.setExtensions(PolylineExtension); } routeDirectionStructure.setJourneyPatterns(patterns); pattern.setStopsInPattern(stopsInPattern); patterns.getJourneyPattern().add(pattern); routeDirectionStructure.setDirectionRef(dirRefStructure); } return true; }
From source file:org.pentaho.di.core.ConstTest.java
@Test public void testRound_BigDecimal() { assertEquals(new BigDecimal("1.0"), Const.round(new BigDecimal("1.0"), 0, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("1.0"), Const.round(new BigDecimal("1.0"), 0, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("1.0"), Const.round(new BigDecimal("1.0"), 0, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("1.0"), Const.round(new BigDecimal("1.0"), 0, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("1.0"), Const.round(new BigDecimal("1.0"), 0, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("1.0"), Const.round(new BigDecimal("1.0"), 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("1.0"), Const.round(new BigDecimal("1.0"), 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("1.0"), Const.round(new BigDecimal("1.0"), 0, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("1.2"), 0, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("1.0"), Const.round(new BigDecimal("1.2"), 0, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("1.2"), 0, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("1.0"), Const.round(new BigDecimal("1.2"), 0, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("1.0"), Const.round(new BigDecimal("1.2"), 0, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("1.0"), Const.round(new BigDecimal("1.2"), 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("1.0"), Const.round(new BigDecimal("1.2"), 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("1.0"), Const.round(new BigDecimal("1.2"), 0, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("1.5"), 0, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("1.0"), Const.round(new BigDecimal("1.5"), 0, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("1.5"), 0, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("1.0"), Const.round(new BigDecimal("1.5"), 0, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("1.5"), 0, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("1.0"), Const.round(new BigDecimal("1.5"), 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("1.5"), 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("1.5"), 0, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("1.7"), 0, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("1.0"), Const.round(new BigDecimal("1.7"), 0, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("1.7"), 0, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("1.0"), Const.round(new BigDecimal("1.7"), 0, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("1.7"), 0, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("1.7"), 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("1.7"), 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("1.7"), 0, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("2.0"), 0, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("2.0"), 0, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("2.0"), 0, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("2.0"), 0, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("2.0"), 0, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("2.0"), 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("2.0"), 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("2.0"), 0, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("3.0"), Const.round(new BigDecimal("2.2"), 0, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("2.2"), 0, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("3.0"), Const.round(new BigDecimal("2.2"), 0, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("2.2"), 0, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("2.2"), 0, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("2.2"), 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("2.2"), 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("2.2"), 0, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("3.0"), Const.round(new BigDecimal("2.5"), 0, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("2.5"), 0, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("3.0"), Const.round(new BigDecimal("2.5"), 0, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("2.5"), 0, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("3.0"), Const.round(new BigDecimal("2.5"), 0, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("2.5"), 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("2.5"), 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("3.0"), Const.round(new BigDecimal("2.5"), 0, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("3.0"), Const.round(new BigDecimal("2.7"), 0, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("2.7"), 0, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("3.0"), Const.round(new BigDecimal("2.7"), 0, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("2.0"), Const.round(new BigDecimal("2.7"), 0, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("3.0"), Const.round(new BigDecimal("2.7"), 0, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("3.0"), Const.round(new BigDecimal("2.7"), 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("3.0"), Const.round(new BigDecimal("2.7"), 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("3.0"), Const.round(new BigDecimal("2.7"), 0, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("-1.0"), Const.round(new BigDecimal("-1.0"), 0, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("-1.0"), Const.round(new BigDecimal("-1.0"), 0, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("-1.0"), Const.round(new BigDecimal("-1.0"), 0, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("-1.0"), Const.round(new BigDecimal("-1.0"), 0, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("-1.0"), Const.round(new BigDecimal("-1.0"), 0, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("-1.0"), Const.round(new BigDecimal("-1.0"), 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("-1.0"), Const.round(new BigDecimal("-1.0"), 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("-1.0"), Const.round(new BigDecimal("-1.0"), 0, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-1.2"), 0, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("-1.0"), Const.round(new BigDecimal("-1.2"), 0, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("-1.0"), Const.round(new BigDecimal("-1.2"), 0, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-1.2"), 0, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("-1.0"), Const.round(new BigDecimal("-1.2"), 0, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("-1.0"), Const.round(new BigDecimal("-1.2"), 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("-1.0"), Const.round(new BigDecimal("-1.2"), 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("-1.0"), Const.round(new BigDecimal("-1.2"), 0, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-1.5"), 0, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("-1.0"), Const.round(new BigDecimal("-1.5"), 0, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("-1.0"), Const.round(new BigDecimal("-1.5"), 0, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-1.5"), 0, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-1.5"), 0, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("-1.0"), Const.round(new BigDecimal("-1.5"), 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-1.5"), 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("-1.0"), Const.round(new BigDecimal("-1.5"), 0, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-1.7"), 0, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("-1.0"), Const.round(new BigDecimal("-1.7"), 0, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("-1.0"), Const.round(new BigDecimal("-1.7"), 0, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-1.7"), 0, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-1.7"), 0, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-1.7"), 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-1.7"), 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-1.7"), 0, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-2.0"), 0, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-2.0"), 0, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-2.0"), 0, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-2.0"), 0, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-2.0"), 0, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-2.0"), 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-2.0"), 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-2.0"), 0, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("-3.0"), Const.round(new BigDecimal("-2.2"), 0, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-2.2"), 0, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-2.2"), 0, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("-3.0"), Const.round(new BigDecimal("-2.2"), 0, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-2.2"), 0, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-2.2"), 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-2.2"), 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-2.2"), 0, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("-3.0"), Const.round(new BigDecimal("-2.5"), 0, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-2.5"), 0, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-2.5"), 0, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("-3.0"), Const.round(new BigDecimal("-2.5"), 0, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("-3.0"), Const.round(new BigDecimal("-2.5"), 0, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-2.5"), 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-2.5"), 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-2.5"), 0, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("-3.0"), Const.round(new BigDecimal("-2.7"), 0, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-2.7"), 0, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("-2.0"), Const.round(new BigDecimal("-2.7"), 0, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("-3.0"), Const.round(new BigDecimal("-2.7"), 0, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("-3.0"), Const.round(new BigDecimal("-2.7"), 0, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("-3.0"), Const.round(new BigDecimal("-2.7"), 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("-3.0"), Const.round(new BigDecimal("-2.7"), 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("-3.0"), Const.round(new BigDecimal("-2.7"), 0, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("0.010"), Const.round(new BigDecimal("0.010"), 2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("0.010"), Const.round(new BigDecimal("0.010"), 2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("0.010"), Const.round(new BigDecimal("0.010"), 2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("0.010"), Const.round(new BigDecimal("0.010"), 2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("0.010"), Const.round(new BigDecimal("0.010"), 2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("0.010"), Const.round(new BigDecimal("0.010"), 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("0.010"), Const.round(new BigDecimal("0.010"), 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("0.010"), Const.round(new BigDecimal("0.010"), 2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.012"), 2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("0.010"), Const.round(new BigDecimal("0.012"), 2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.012"), 2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("0.010"), Const.round(new BigDecimal("0.012"), 2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("0.010"), Const.round(new BigDecimal("0.012"), 2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("0.010"), Const.round(new BigDecimal("0.012"), 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("0.010"), Const.round(new BigDecimal("0.012"), 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("0.010"), Const.round(new BigDecimal("0.012"), 2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.015"), 2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("0.010"), Const.round(new BigDecimal("0.015"), 2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.015"), 2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("0.010"), Const.round(new BigDecimal("0.015"), 2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.015"), 2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("0.010"), Const.round(new BigDecimal("0.015"), 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.015"), 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.015"), 2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.017"), 2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("0.010"), Const.round(new BigDecimal("0.017"), 2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.017"), 2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("0.010"), Const.round(new BigDecimal("0.017"), 2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.017"), 2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.017"), 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.017"), 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.017"), 2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.020"), 2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.020"), 2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.020"), 2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.020"), 2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.020"), 2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.020"), 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.020"), 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.020"), 2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("0.030"), Const.round(new BigDecimal("0.022"), 2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.022"), 2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("0.030"), Const.round(new BigDecimal("0.022"), 2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.022"), 2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.022"), 2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.022"), 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.022"), 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.022"), 2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("0.030"), Const.round(new BigDecimal("0.025"), 2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.025"), 2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("0.030"), Const.round(new BigDecimal("0.025"), 2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.025"), 2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("0.030"), Const.round(new BigDecimal("0.025"), 2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.025"), 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.025"), 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("0.030"), Const.round(new BigDecimal("0.025"), 2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("0.030"), Const.round(new BigDecimal("0.027"), 2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.027"), 2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("0.030"), Const.round(new BigDecimal("0.027"), 2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("0.020"), Const.round(new BigDecimal("0.027"), 2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("0.030"), Const.round(new BigDecimal("0.027"), 2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("0.030"), Const.round(new BigDecimal("0.027"), 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("0.030"), Const.round(new BigDecimal("0.027"), 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("0.030"), Const.round(new BigDecimal("0.027"), 2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("-0.010"), Const.round(new BigDecimal("-0.010"), 2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("-0.010"), Const.round(new BigDecimal("-0.010"), 2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("-0.010"), Const.round(new BigDecimal("-0.010"), 2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("-0.010"), Const.round(new BigDecimal("-0.010"), 2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("-0.010"), Const.round(new BigDecimal("-0.010"), 2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("-0.010"), Const.round(new BigDecimal("-0.010"), 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("-0.010"), Const.round(new BigDecimal("-0.010"), 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("-0.010"), Const.round(new BigDecimal("-0.010"), 2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.012"), 2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("-0.010"), Const.round(new BigDecimal("-0.012"), 2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("-0.010"), Const.round(new BigDecimal("-0.012"), 2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.012"), 2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("-0.010"), Const.round(new BigDecimal("-0.012"), 2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("-0.010"), Const.round(new BigDecimal("-0.012"), 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("-0.010"), Const.round(new BigDecimal("-0.012"), 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("-0.010"), Const.round(new BigDecimal("-0.012"), 2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.015"), 2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("-0.010"), Const.round(new BigDecimal("-0.015"), 2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("-0.010"), Const.round(new BigDecimal("-0.015"), 2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.015"), 2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.015"), 2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("-0.010"), Const.round(new BigDecimal("-0.015"), 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.015"), 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("-0.010"), Const.round(new BigDecimal("-0.015"), 2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.017"), 2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("-0.010"), Const.round(new BigDecimal("-0.017"), 2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("-0.010"), Const.round(new BigDecimal("-0.017"), 2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.017"), 2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.017"), 2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.017"), 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.017"), 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.017"), 2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.020"), 2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.020"), 2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.020"), 2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.020"), 2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.020"), 2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.020"), 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.020"), 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.020"), 2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("-0.030"), Const.round(new BigDecimal("-0.022"), 2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.022"), 2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.022"), 2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("-0.030"), Const.round(new BigDecimal("-0.022"), 2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.022"), 2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.022"), 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.022"), 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.022"), 2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("-0.030"), Const.round(new BigDecimal("-0.025"), 2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.025"), 2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.025"), 2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("-0.030"), Const.round(new BigDecimal("-0.025"), 2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("-0.030"), Const.round(new BigDecimal("-0.025"), 2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.025"), 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.025"), 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.025"), 2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("-0.030"), Const.round(new BigDecimal("-0.027"), 2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.027"), 2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("-0.020"), Const.round(new BigDecimal("-0.027"), 2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("-0.030"), Const.round(new BigDecimal("-0.027"), 2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("-0.030"), Const.round(new BigDecimal("-0.027"), 2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("-0.030"), Const.round(new BigDecimal("-0.027"), 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("-0.030"), Const.round(new BigDecimal("-0.027"), 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("-0.030"), Const.round(new BigDecimal("-0.027"), 2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("100.0"), Const.round(new BigDecimal("100.0"), -2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("100.0"), Const.round(new BigDecimal("100.0"), -2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("100.0"), Const.round(new BigDecimal("100.0"), -2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("100.0"), Const.round(new BigDecimal("100.0"), -2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("100.0"), Const.round(new BigDecimal("100.0"), -2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("100.0"), Const.round(new BigDecimal("100.0"), -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("100.0"), Const.round(new BigDecimal("100.0"), -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("100.0"), Const.round(new BigDecimal("100.0"), -2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("120.0"), -2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("100.0"), Const.round(new BigDecimal("120.0"), -2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("120.0"), -2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("100.0"), Const.round(new BigDecimal("120.0"), -2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("100.0"), Const.round(new BigDecimal("120.0"), -2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("100.0"), Const.round(new BigDecimal("120.0"), -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("100.0"), Const.round(new BigDecimal("120.0"), -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("100.0"), Const.round(new BigDecimal("120.0"), -2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("150.0"), -2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("100.0"), Const.round(new BigDecimal("150.0"), -2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("150.0"), -2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("100.0"), Const.round(new BigDecimal("150.0"), -2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("150.0"), -2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("100.0"), Const.round(new BigDecimal("150.0"), -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("150.0"), -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("150.0"), -2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("170.0"), -2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("100.0"), Const.round(new BigDecimal("170.0"), -2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("170.0"), -2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("100.0"), Const.round(new BigDecimal("170.0"), -2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("170.0"), -2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("170.0"), -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("170.0"), -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("170.0"), -2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("200.0"), -2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("200.0"), -2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("200.0"), -2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("200.0"), -2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("200.0"), -2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("200.0"), -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("200.0"), -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("200.0"), -2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("300.0"), Const.round(new BigDecimal("220.0"), -2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("220.0"), -2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("300.0"), Const.round(new BigDecimal("220.0"), -2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("220.0"), -2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("220.0"), -2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("220.0"), -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("220.0"), -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("220.0"), -2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("300.0"), Const.round(new BigDecimal("250.0"), -2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("250.0"), -2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("300.0"), Const.round(new BigDecimal("250.0"), -2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("250.0"), -2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("300.0"), Const.round(new BigDecimal("250.0"), -2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("250.0"), -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("250.0"), -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("300.0"), Const.round(new BigDecimal("250.0"), -2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("300.0"), Const.round(new BigDecimal("270.0"), -2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("270.0"), -2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("300.0"), Const.round(new BigDecimal("270.0"), -2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("200.0"), Const.round(new BigDecimal("270.0"), -2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("300.0"), Const.round(new BigDecimal("270.0"), -2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("300.0"), Const.round(new BigDecimal("270.0"), -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("300.0"), Const.round(new BigDecimal("270.0"), -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("300.0"), Const.round(new BigDecimal("270.0"), -2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("-100.0"), Const.round(new BigDecimal("-100.0"), -2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("-100.0"), Const.round(new BigDecimal("-100.0"), -2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("-100.0"), Const.round(new BigDecimal("-100.0"), -2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("-100.0"), Const.round(new BigDecimal("-100.0"), -2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("-100.0"), Const.round(new BigDecimal("-100.0"), -2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("-100.0"), Const.round(new BigDecimal("-100.0"), -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("-100.0"), Const.round(new BigDecimal("-100.0"), -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("-100.0"), Const.round(new BigDecimal("-100.0"), -2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-120.0"), -2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("-100.0"), Const.round(new BigDecimal("-120.0"), -2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("-100.0"), Const.round(new BigDecimal("-120.0"), -2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-120.0"), -2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("-100.0"), Const.round(new BigDecimal("-120.0"), -2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("-100.0"), Const.round(new BigDecimal("-120.0"), -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("-100.0"), Const.round(new BigDecimal("-120.0"), -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("-100.0"), Const.round(new BigDecimal("-120.0"), -2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-150.0"), -2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("-100.0"), Const.round(new BigDecimal("-150.0"), -2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("-100.0"), Const.round(new BigDecimal("-150.0"), -2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-150.0"), -2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-150.0"), -2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("-100.0"), Const.round(new BigDecimal("-150.0"), -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-150.0"), -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("-100.0"), Const.round(new BigDecimal("-150.0"), -2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-170.0"), -2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("-100.0"), Const.round(new BigDecimal("-170.0"), -2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("-100.0"), Const.round(new BigDecimal("-170.0"), -2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-170.0"), -2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-170.0"), -2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-170.0"), -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-170.0"), -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-170.0"), -2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-200.0"), -2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-200.0"), -2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-200.0"), -2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-200.0"), -2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-200.0"), -2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-200.0"), -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-200.0"), -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-200.0"), -2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("-300.0"), Const.round(new BigDecimal("-220.0"), -2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-220.0"), -2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-220.0"), -2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("-300.0"), Const.round(new BigDecimal("-220.0"), -2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-220.0"), -2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-220.0"), -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-220.0"), -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-220.0"), -2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("-300.0"), Const.round(new BigDecimal("-250.0"), -2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-250.0"), -2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-250.0"), -2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("-300.0"), Const.round(new BigDecimal("-250.0"), -2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("-300.0"), Const.round(new BigDecimal("-250.0"), -2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-250.0"), -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-250.0"), -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-250.0"), -2, Const.ROUND_HALF_CEILING)); assertEquals(new BigDecimal("-300.0"), Const.round(new BigDecimal("-270.0"), -2, BigDecimal.ROUND_UP)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-270.0"), -2, BigDecimal.ROUND_DOWN)); assertEquals(new BigDecimal("-200.0"), Const.round(new BigDecimal("-270.0"), -2, BigDecimal.ROUND_CEILING)); assertEquals(new BigDecimal("-300.0"), Const.round(new BigDecimal("-270.0"), -2, BigDecimal.ROUND_FLOOR)); assertEquals(new BigDecimal("-300.0"), Const.round(new BigDecimal("-270.0"), -2, BigDecimal.ROUND_HALF_UP)); assertEquals(new BigDecimal("-300.0"), Const.round(new BigDecimal("-270.0"), -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(new BigDecimal("-300.0"), Const.round(new BigDecimal("-270.0"), -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(new BigDecimal("-300.0"), Const.round(new BigDecimal("-270.0"), -2, Const.ROUND_HALF_CEILING)); }
From source file:org.pentaho.di.core.ConstTest.java
@Test public void testRound() { assertEquals(1.0, Const.round(1.0, 0, BigDecimal.ROUND_UP)); assertEquals(1.0, Const.round(1.0, 0, BigDecimal.ROUND_DOWN)); assertEquals(1.0, Const.round(1.0, 0, BigDecimal.ROUND_CEILING)); assertEquals(1.0, Const.round(1.0, 0, BigDecimal.ROUND_FLOOR)); assertEquals(1.0, Const.round(1.0, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(1.0, Const.round(1.0, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(1.0, Const.round(1.0, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(1.0, Const.round(1.0, 0, Const.ROUND_HALF_CEILING)); assertEquals(2.0, Const.round(1.2, 0, BigDecimal.ROUND_UP)); assertEquals(1.0, Const.round(1.2, 0, BigDecimal.ROUND_DOWN)); assertEquals(2.0, Const.round(1.2, 0, BigDecimal.ROUND_CEILING)); assertEquals(1.0, Const.round(1.2, 0, BigDecimal.ROUND_FLOOR)); assertEquals(1.0, Const.round(1.2, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(1.0, Const.round(1.2, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(1.0, Const.round(1.2, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(1.0, Const.round(1.2, 0, Const.ROUND_HALF_CEILING)); assertEquals(2.0, Const.round(1.5, 0, BigDecimal.ROUND_UP)); assertEquals(1.0, Const.round(1.5, 0, BigDecimal.ROUND_DOWN)); assertEquals(2.0, Const.round(1.5, 0, BigDecimal.ROUND_CEILING)); assertEquals(1.0, Const.round(1.5, 0, BigDecimal.ROUND_FLOOR)); assertEquals(2.0, Const.round(1.5, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(1.0, Const.round(1.5, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(2.0, Const.round(1.5, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(2.0, Const.round(1.5, 0, Const.ROUND_HALF_CEILING)); assertEquals(2.0, Const.round(1.7, 0, BigDecimal.ROUND_UP)); assertEquals(1.0, Const.round(1.7, 0, BigDecimal.ROUND_DOWN)); assertEquals(2.0, Const.round(1.7, 0, BigDecimal.ROUND_CEILING)); assertEquals(1.0, Const.round(1.7, 0, BigDecimal.ROUND_FLOOR)); assertEquals(2.0, Const.round(1.7, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(2.0, Const.round(1.7, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(2.0, Const.round(1.7, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(2.0, Const.round(1.7, 0, Const.ROUND_HALF_CEILING)); assertEquals(2.0, Const.round(2.0, 0, BigDecimal.ROUND_UP)); assertEquals(2.0, Const.round(2.0, 0, BigDecimal.ROUND_DOWN)); assertEquals(2.0, Const.round(2.0, 0, BigDecimal.ROUND_CEILING)); assertEquals(2.0, Const.round(2.0, 0, BigDecimal.ROUND_FLOOR)); assertEquals(2.0, Const.round(2.0, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(2.0, Const.round(2.0, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(2.0, Const.round(2.0, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(2.0, Const.round(2.0, 0, Const.ROUND_HALF_CEILING)); assertEquals(3.0, Const.round(2.2, 0, BigDecimal.ROUND_UP)); assertEquals(2.0, Const.round(2.2, 0, BigDecimal.ROUND_DOWN)); assertEquals(3.0, Const.round(2.2, 0, BigDecimal.ROUND_CEILING)); assertEquals(2.0, Const.round(2.2, 0, BigDecimal.ROUND_FLOOR)); assertEquals(2.0, Const.round(2.2, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(2.0, Const.round(2.2, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(2.0, Const.round(2.2, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(2.0, Const.round(2.2, 0, Const.ROUND_HALF_CEILING)); assertEquals(3.0, Const.round(2.5, 0, BigDecimal.ROUND_UP)); assertEquals(2.0, Const.round(2.5, 0, BigDecimal.ROUND_DOWN)); assertEquals(3.0, Const.round(2.5, 0, BigDecimal.ROUND_CEILING)); assertEquals(2.0, Const.round(2.5, 0, BigDecimal.ROUND_FLOOR)); assertEquals(3.0, Const.round(2.5, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(2.0, Const.round(2.5, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(2.0, Const.round(2.5, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(3.0, Const.round(2.5, 0, Const.ROUND_HALF_CEILING)); assertEquals(3.0, Const.round(2.7, 0, BigDecimal.ROUND_UP)); assertEquals(2.0, Const.round(2.7, 0, BigDecimal.ROUND_DOWN)); assertEquals(3.0, Const.round(2.7, 0, BigDecimal.ROUND_CEILING)); assertEquals(2.0, Const.round(2.7, 0, BigDecimal.ROUND_FLOOR)); assertEquals(3.0, Const.round(2.7, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(3.0, Const.round(2.7, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(3.0, Const.round(2.7, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(3.0, Const.round(2.7, 0, Const.ROUND_HALF_CEILING)); assertEquals(-1.0, Const.round(-1.0, 0, BigDecimal.ROUND_UP)); assertEquals(-1.0, Const.round(-1.0, 0, BigDecimal.ROUND_DOWN)); assertEquals(-1.0, Const.round(-1.0, 0, BigDecimal.ROUND_CEILING)); assertEquals(-1.0, Const.round(-1.0, 0, BigDecimal.ROUND_FLOOR)); assertEquals(-1.0, Const.round(-1.0, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(-1.0, Const.round(-1.0, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-1.0, Const.round(-1.0, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-1.0, Const.round(-1.0, 0, Const.ROUND_HALF_CEILING)); assertEquals(-2.0, Const.round(-1.2, 0, BigDecimal.ROUND_UP)); assertEquals(-1.0, Const.round(-1.2, 0, BigDecimal.ROUND_DOWN)); assertEquals(-1.0, Const.round(-1.2, 0, BigDecimal.ROUND_CEILING)); assertEquals(-2.0, Const.round(-1.2, 0, BigDecimal.ROUND_FLOOR)); assertEquals(-1.0, Const.round(-1.2, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(-1.0, Const.round(-1.2, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-1.0, Const.round(-1.2, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-1.0, Const.round(-1.2, 0, Const.ROUND_HALF_CEILING)); assertEquals(-2.0, Const.round(-1.5, 0, BigDecimal.ROUND_UP)); assertEquals(-1.0, Const.round(-1.5, 0, BigDecimal.ROUND_DOWN)); assertEquals(-1.0, Const.round(-1.5, 0, BigDecimal.ROUND_CEILING)); assertEquals(-2.0, Const.round(-1.5, 0, BigDecimal.ROUND_FLOOR)); assertEquals(-2.0, Const.round(-1.5, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(-1.0, Const.round(-1.5, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-2.0, Const.round(-1.5, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-1.0, Const.round(-1.5, 0, Const.ROUND_HALF_CEILING)); assertEquals(-2.0, Const.round(-1.7, 0, BigDecimal.ROUND_UP)); assertEquals(-1.0, Const.round(-1.7, 0, BigDecimal.ROUND_DOWN)); assertEquals(-1.0, Const.round(-1.7, 0, BigDecimal.ROUND_CEILING)); assertEquals(-2.0, Const.round(-1.7, 0, BigDecimal.ROUND_FLOOR)); assertEquals(-2.0, Const.round(-1.7, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(-2.0, Const.round(-1.7, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-2.0, Const.round(-1.7, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-2.0, Const.round(-1.7, 0, Const.ROUND_HALF_CEILING)); assertEquals(-2.0, Const.round(-2.0, 0, BigDecimal.ROUND_UP)); assertEquals(-2.0, Const.round(-2.0, 0, BigDecimal.ROUND_DOWN)); assertEquals(-2.0, Const.round(-2.0, 0, BigDecimal.ROUND_CEILING)); assertEquals(-2.0, Const.round(-2.0, 0, BigDecimal.ROUND_FLOOR)); assertEquals(-2.0, Const.round(-2.0, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(-2.0, Const.round(-2.0, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-2.0, Const.round(-2.0, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-2.0, Const.round(-2.0, 0, Const.ROUND_HALF_CEILING)); assertEquals(-3.0, Const.round(-2.2, 0, BigDecimal.ROUND_UP)); assertEquals(-2.0, Const.round(-2.2, 0, BigDecimal.ROUND_DOWN)); assertEquals(-2.0, Const.round(-2.2, 0, BigDecimal.ROUND_CEILING)); assertEquals(-3.0, Const.round(-2.2, 0, BigDecimal.ROUND_FLOOR)); assertEquals(-2.0, Const.round(-2.2, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(-2.0, Const.round(-2.2, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-2.0, Const.round(-2.2, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-2.0, Const.round(-2.2, 0, Const.ROUND_HALF_CEILING)); assertEquals(-3.0, Const.round(-2.5, 0, BigDecimal.ROUND_UP)); assertEquals(-2.0, Const.round(-2.5, 0, BigDecimal.ROUND_DOWN)); assertEquals(-2.0, Const.round(-2.5, 0, BigDecimal.ROUND_CEILING)); assertEquals(-3.0, Const.round(-2.5, 0, BigDecimal.ROUND_FLOOR)); assertEquals(-3.0, Const.round(-2.5, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(-2.0, Const.round(-2.5, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-2.0, Const.round(-2.5, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-2.0, Const.round(-2.5, 0, Const.ROUND_HALF_CEILING)); assertEquals(-3.0, Const.round(-2.7, 0, BigDecimal.ROUND_UP)); assertEquals(-2.0, Const.round(-2.7, 0, BigDecimal.ROUND_DOWN)); assertEquals(-2.0, Const.round(-2.7, 0, BigDecimal.ROUND_CEILING)); assertEquals(-3.0, Const.round(-2.7, 0, BigDecimal.ROUND_FLOOR)); assertEquals(-3.0, Const.round(-2.7, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(-3.0, Const.round(-2.7, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-3.0, Const.round(-2.7, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-3.0, Const.round(-2.7, 0, Const.ROUND_HALF_CEILING)); assertEquals(0.010, Const.round(0.010, 2, BigDecimal.ROUND_UP)); assertEquals(0.010, Const.round(0.010, 2, BigDecimal.ROUND_DOWN)); assertEquals(0.010, Const.round(0.010, 2, BigDecimal.ROUND_CEILING)); assertEquals(0.010, Const.round(0.010, 2, BigDecimal.ROUND_FLOOR)); assertEquals(0.010, Const.round(0.010, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(0.010, Const.round(0.010, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(0.010, Const.round(0.010, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(0.010, Const.round(0.010, 2, Const.ROUND_HALF_CEILING)); assertEquals(0.020, Const.round(0.012, 2, BigDecimal.ROUND_UP)); assertEquals(0.010, Const.round(0.012, 2, BigDecimal.ROUND_DOWN)); assertEquals(0.020, Const.round(0.012, 2, BigDecimal.ROUND_CEILING)); assertEquals(0.010, Const.round(0.012, 2, BigDecimal.ROUND_FLOOR)); assertEquals(0.010, Const.round(0.012, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(0.010, Const.round(0.012, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(0.010, Const.round(0.012, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(0.010, Const.round(0.012, 2, Const.ROUND_HALF_CEILING)); assertEquals(0.020, Const.round(0.015, 2, BigDecimal.ROUND_UP)); assertEquals(0.010, Const.round(0.015, 2, BigDecimal.ROUND_DOWN)); assertEquals(0.020, Const.round(0.015, 2, BigDecimal.ROUND_CEILING)); assertEquals(0.010, Const.round(0.015, 2, BigDecimal.ROUND_FLOOR)); assertEquals(0.020, Const.round(0.015, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(0.010, Const.round(0.015, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(0.020, Const.round(0.015, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(0.020, Const.round(0.015, 2, Const.ROUND_HALF_CEILING)); assertEquals(0.020, Const.round(0.017, 2, BigDecimal.ROUND_UP)); assertEquals(0.010, Const.round(0.017, 2, BigDecimal.ROUND_DOWN)); assertEquals(0.020, Const.round(0.017, 2, BigDecimal.ROUND_CEILING)); assertEquals(0.010, Const.round(0.017, 2, BigDecimal.ROUND_FLOOR)); assertEquals(0.020, Const.round(0.017, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(0.020, Const.round(0.017, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(0.020, Const.round(0.017, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(0.020, Const.round(0.017, 2, Const.ROUND_HALF_CEILING)); assertEquals(0.020, Const.round(0.020, 2, BigDecimal.ROUND_UP)); assertEquals(0.020, Const.round(0.020, 2, BigDecimal.ROUND_DOWN)); assertEquals(0.020, Const.round(0.020, 2, BigDecimal.ROUND_CEILING)); assertEquals(0.020, Const.round(0.020, 2, BigDecimal.ROUND_FLOOR)); assertEquals(0.020, Const.round(0.020, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(0.020, Const.round(0.020, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(0.020, Const.round(0.020, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(0.020, Const.round(0.020, 2, Const.ROUND_HALF_CEILING)); assertEquals(0.030, Const.round(0.022, 2, BigDecimal.ROUND_UP)); assertEquals(0.020, Const.round(0.022, 2, BigDecimal.ROUND_DOWN)); assertEquals(0.030, Const.round(0.022, 2, BigDecimal.ROUND_CEILING)); assertEquals(0.020, Const.round(0.022, 2, BigDecimal.ROUND_FLOOR)); assertEquals(0.020, Const.round(0.022, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(0.020, Const.round(0.022, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(0.020, Const.round(0.022, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(0.020, Const.round(0.022, 2, Const.ROUND_HALF_CEILING)); assertEquals(0.030, Const.round(0.025, 2, BigDecimal.ROUND_UP)); assertEquals(0.020, Const.round(0.025, 2, BigDecimal.ROUND_DOWN)); assertEquals(0.030, Const.round(0.025, 2, BigDecimal.ROUND_CEILING)); assertEquals(0.020, Const.round(0.025, 2, BigDecimal.ROUND_FLOOR)); assertEquals(0.030, Const.round(0.025, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(0.020, Const.round(0.025, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(0.020, Const.round(0.025, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(0.030, Const.round(0.025, 2, Const.ROUND_HALF_CEILING)); assertEquals(0.030, Const.round(0.027, 2, BigDecimal.ROUND_UP)); assertEquals(0.020, Const.round(0.027, 2, BigDecimal.ROUND_DOWN)); assertEquals(0.030, Const.round(0.027, 2, BigDecimal.ROUND_CEILING)); assertEquals(0.020, Const.round(0.027, 2, BigDecimal.ROUND_FLOOR)); assertEquals(0.030, Const.round(0.027, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(0.030, Const.round(0.027, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(0.030, Const.round(0.027, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(0.030, Const.round(0.027, 2, Const.ROUND_HALF_CEILING)); assertEquals(-0.010, Const.round(-0.010, 2, BigDecimal.ROUND_UP)); assertEquals(-0.010, Const.round(-0.010, 2, BigDecimal.ROUND_DOWN)); assertEquals(-0.010, Const.round(-0.010, 2, BigDecimal.ROUND_CEILING)); assertEquals(-0.010, Const.round(-0.010, 2, BigDecimal.ROUND_FLOOR)); assertEquals(-0.010, Const.round(-0.010, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(-0.010, Const.round(-0.010, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-0.010, Const.round(-0.010, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-0.010, Const.round(-0.010, 2, Const.ROUND_HALF_CEILING)); assertEquals(-0.020, Const.round(-0.012, 2, BigDecimal.ROUND_UP)); assertEquals(-0.010, Const.round(-0.012, 2, BigDecimal.ROUND_DOWN)); assertEquals(-0.010, Const.round(-0.012, 2, BigDecimal.ROUND_CEILING)); assertEquals(-0.020, Const.round(-0.012, 2, BigDecimal.ROUND_FLOOR)); assertEquals(-0.010, Const.round(-0.012, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(-0.010, Const.round(-0.012, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-0.010, Const.round(-0.012, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-0.010, Const.round(-0.012, 2, Const.ROUND_HALF_CEILING)); assertEquals(-0.020, Const.round(-0.015, 2, BigDecimal.ROUND_UP)); assertEquals(-0.010, Const.round(-0.015, 2, BigDecimal.ROUND_DOWN)); assertEquals(-0.010, Const.round(-0.015, 2, BigDecimal.ROUND_CEILING)); assertEquals(-0.020, Const.round(-0.015, 2, BigDecimal.ROUND_FLOOR)); assertEquals(-0.020, Const.round(-0.015, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(-0.010, Const.round(-0.015, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-0.020, Const.round(-0.015, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-0.010, Const.round(-0.015, 2, Const.ROUND_HALF_CEILING)); assertEquals(-0.020, Const.round(-0.017, 2, BigDecimal.ROUND_UP)); assertEquals(-0.010, Const.round(-0.017, 2, BigDecimal.ROUND_DOWN)); assertEquals(-0.010, Const.round(-0.017, 2, BigDecimal.ROUND_CEILING)); assertEquals(-0.020, Const.round(-0.017, 2, BigDecimal.ROUND_FLOOR)); assertEquals(-0.020, Const.round(-0.017, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(-0.020, Const.round(-0.017, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-0.020, Const.round(-0.017, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-0.020, Const.round(-0.017, 2, Const.ROUND_HALF_CEILING)); assertEquals(-0.020, Const.round(-0.020, 2, BigDecimal.ROUND_UP)); assertEquals(-0.020, Const.round(-0.020, 2, BigDecimal.ROUND_DOWN)); assertEquals(-0.020, Const.round(-0.020, 2, BigDecimal.ROUND_CEILING)); assertEquals(-0.020, Const.round(-0.020, 2, BigDecimal.ROUND_FLOOR)); assertEquals(-0.020, Const.round(-0.020, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(-0.020, Const.round(-0.020, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-0.020, Const.round(-0.020, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-0.020, Const.round(-0.020, 2, Const.ROUND_HALF_CEILING)); assertEquals(-0.030, Const.round(-0.022, 2, BigDecimal.ROUND_UP)); assertEquals(-0.020, Const.round(-0.022, 2, BigDecimal.ROUND_DOWN)); assertEquals(-0.020, Const.round(-0.022, 2, BigDecimal.ROUND_CEILING)); assertEquals(-0.030, Const.round(-0.022, 2, BigDecimal.ROUND_FLOOR)); assertEquals(-0.020, Const.round(-0.022, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(-0.020, Const.round(-0.022, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-0.020, Const.round(-0.022, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-0.020, Const.round(-0.022, 2, Const.ROUND_HALF_CEILING)); assertEquals(-0.030, Const.round(-0.025, 2, BigDecimal.ROUND_UP)); assertEquals(-0.020, Const.round(-0.025, 2, BigDecimal.ROUND_DOWN)); assertEquals(-0.020, Const.round(-0.025, 2, BigDecimal.ROUND_CEILING)); assertEquals(-0.030, Const.round(-0.025, 2, BigDecimal.ROUND_FLOOR)); assertEquals(-0.030, Const.round(-0.025, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(-0.020, Const.round(-0.025, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-0.020, Const.round(-0.025, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-0.020, Const.round(-0.025, 2, Const.ROUND_HALF_CEILING)); assertEquals(-0.030, Const.round(-0.027, 2, BigDecimal.ROUND_UP)); assertEquals(-0.020, Const.round(-0.027, 2, BigDecimal.ROUND_DOWN)); assertEquals(-0.020, Const.round(-0.027, 2, BigDecimal.ROUND_CEILING)); assertEquals(-0.030, Const.round(-0.027, 2, BigDecimal.ROUND_FLOOR)); assertEquals(-0.030, Const.round(-0.027, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(-0.030, Const.round(-0.027, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-0.030, Const.round(-0.027, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-0.030, Const.round(-0.027, 2, Const.ROUND_HALF_CEILING)); assertEquals(100.0, Const.round(100.0, -2, BigDecimal.ROUND_UP)); assertEquals(100.0, Const.round(100.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(100.0, Const.round(100.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(100.0, Const.round(100.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(100.0, Const.round(100.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(100.0, Const.round(100.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(100.0, Const.round(100.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(100.0, Const.round(100.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(200.0, Const.round(120.0, -2, BigDecimal.ROUND_UP)); assertEquals(100.0, Const.round(120.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(200.0, Const.round(120.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(100.0, Const.round(120.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(100.0, Const.round(120.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(100.0, Const.round(120.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(100.0, Const.round(120.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(100.0, Const.round(120.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(200.0, Const.round(150.0, -2, BigDecimal.ROUND_UP)); assertEquals(100.0, Const.round(150.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(200.0, Const.round(150.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(100.0, Const.round(150.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(200.0, Const.round(150.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(100.0, Const.round(150.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(200.0, Const.round(150.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(200.0, Const.round(150.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(200.0, Const.round(170.0, -2, BigDecimal.ROUND_UP)); assertEquals(100.0, Const.round(170.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(200.0, Const.round(170.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(100.0, Const.round(170.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(200.0, Const.round(170.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(200.0, Const.round(170.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(200.0, Const.round(170.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(200.0, Const.round(170.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(200.0, Const.round(200.0, -2, BigDecimal.ROUND_UP)); assertEquals(200.0, Const.round(200.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(200.0, Const.round(200.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(200.0, Const.round(200.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(200.0, Const.round(200.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(200.0, Const.round(200.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(200.0, Const.round(200.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(200.0, Const.round(200.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(300.0, Const.round(220.0, -2, BigDecimal.ROUND_UP)); assertEquals(200.0, Const.round(220.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(300.0, Const.round(220.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(200.0, Const.round(220.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(200.0, Const.round(220.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(200.0, Const.round(220.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(200.0, Const.round(220.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(200.0, Const.round(220.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(300.0, Const.round(250.0, -2, BigDecimal.ROUND_UP)); assertEquals(200.0, Const.round(250.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(300.0, Const.round(250.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(200.0, Const.round(250.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(300.0, Const.round(250.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(200.0, Const.round(250.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(200.0, Const.round(250.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(300.0, Const.round(250.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(300.0, Const.round(270.0, -2, BigDecimal.ROUND_UP)); assertEquals(200.0, Const.round(270.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(300.0, Const.round(270.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(200.0, Const.round(270.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(300.0, Const.round(270.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(300.0, Const.round(270.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(300.0, Const.round(270.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(300.0, Const.round(270.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(-100.0, Const.round(-100.0, -2, BigDecimal.ROUND_UP)); assertEquals(-100.0, Const.round(-100.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(-100.0, Const.round(-100.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(-100.0, Const.round(-100.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(-100.0, Const.round(-100.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(-100.0, Const.round(-100.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-100.0, Const.round(-100.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-100.0, Const.round(-100.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(-200.0, Const.round(-120.0, -2, BigDecimal.ROUND_UP)); assertEquals(-100.0, Const.round(-120.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(-100.0, Const.round(-120.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(-200.0, Const.round(-120.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(-100.0, Const.round(-120.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(-100.0, Const.round(-120.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-100.0, Const.round(-120.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-100.0, Const.round(-120.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(-200.0, Const.round(-150.0, -2, BigDecimal.ROUND_UP)); assertEquals(-100.0, Const.round(-150.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(-100.0, Const.round(-150.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(-200.0, Const.round(-150.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(-200.0, Const.round(-150.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(-100.0, Const.round(-150.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-200.0, Const.round(-150.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-100.0, Const.round(-150.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(-200.0, Const.round(-170.0, -2, BigDecimal.ROUND_UP)); assertEquals(-100.0, Const.round(-170.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(-100.0, Const.round(-170.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(-200.0, Const.round(-170.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(-200.0, Const.round(-170.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(-200.0, Const.round(-170.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-200.0, Const.round(-170.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-200.0, Const.round(-170.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(-200.0, Const.round(-200.0, -2, BigDecimal.ROUND_UP)); assertEquals(-200.0, Const.round(-200.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(-200.0, Const.round(-200.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(-200.0, Const.round(-200.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(-200.0, Const.round(-200.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(-200.0, Const.round(-200.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-200.0, Const.round(-200.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-200.0, Const.round(-200.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(-300.0, Const.round(-220.0, -2, BigDecimal.ROUND_UP)); assertEquals(-200.0, Const.round(-220.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(-200.0, Const.round(-220.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(-300.0, Const.round(-220.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(-200.0, Const.round(-220.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(-200.0, Const.round(-220.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-200.0, Const.round(-220.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-200.0, Const.round(-220.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(-300.0, Const.round(-250.0, -2, BigDecimal.ROUND_UP)); assertEquals(-200.0, Const.round(-250.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(-200.0, Const.round(-250.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(-300.0, Const.round(-250.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(-300.0, Const.round(-250.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(-200.0, Const.round(-250.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-200.0, Const.round(-250.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-200.0, Const.round(-250.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(-300.0, Const.round(-270.0, -2, BigDecimal.ROUND_UP)); assertEquals(-200.0, Const.round(-270.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(-200.0, Const.round(-270.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(-300.0, Const.round(-270.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(-300.0, Const.round(-270.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(-300.0, Const.round(-270.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-300.0, Const.round(-270.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-300.0, Const.round(-270.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(Double.NaN, Const.round(Double.NaN, 0, BigDecimal.ROUND_UP)); assertEquals(Double.NEGATIVE_INFINITY, Const.round(Double.NEGATIVE_INFINITY, 0, BigDecimal.ROUND_UP)); assertEquals(Double.POSITIVE_INFINITY, Const.round(Double.POSITIVE_INFINITY, 0, BigDecimal.ROUND_UP)); }
From source file:org.pentaho.di.core.ConstTest.java
@Test public void testRound_Long() { assertEquals(1L, Const.round(1L, 0, BigDecimal.ROUND_UP)); assertEquals(1L, Const.round(1L, 0, BigDecimal.ROUND_DOWN)); assertEquals(1L, Const.round(1L, 0, BigDecimal.ROUND_CEILING)); assertEquals(1L, Const.round(1L, 0, BigDecimal.ROUND_FLOOR)); assertEquals(1L, Const.round(1L, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(1L, Const.round(1L, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(1L, Const.round(1L, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(1L, Const.round(1L, 0, Const.ROUND_HALF_CEILING)); assertEquals(2L, Const.round(2L, 0, BigDecimal.ROUND_UP)); assertEquals(2L, Const.round(2L, 0, BigDecimal.ROUND_DOWN)); assertEquals(2L, Const.round(2L, 0, BigDecimal.ROUND_CEILING)); assertEquals(2L, Const.round(2L, 0, BigDecimal.ROUND_FLOOR)); assertEquals(2L, Const.round(2L, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(2L, Const.round(2L, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(2L, Const.round(2L, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(2L, Const.round(2L, 0, Const.ROUND_HALF_CEILING)); assertEquals(-1L, Const.round(-1L, 0, BigDecimal.ROUND_UP)); assertEquals(-1L, Const.round(-1L, 0, BigDecimal.ROUND_DOWN)); assertEquals(-1L, Const.round(-1L, 0, BigDecimal.ROUND_CEILING)); assertEquals(-1L, Const.round(-1L, 0, BigDecimal.ROUND_FLOOR)); assertEquals(-1L, Const.round(-1L, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(-1L, Const.round(-1L, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-1L, Const.round(-1L, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-1L, Const.round(-1L, 0, Const.ROUND_HALF_CEILING)); assertEquals(-2L, Const.round(-2L, 0, BigDecimal.ROUND_UP)); assertEquals(-2L, Const.round(-2L, 0, BigDecimal.ROUND_DOWN)); assertEquals(-2L, Const.round(-2L, 0, BigDecimal.ROUND_CEILING)); assertEquals(-2L, Const.round(-2L, 0, BigDecimal.ROUND_FLOOR)); assertEquals(-2L, Const.round(-2L, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(-2L, Const.round(-2L, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-2L, Const.round(-2L, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-2L, Const.round(-2L, 0, Const.ROUND_HALF_CEILING)); assertEquals(100L, Const.round(100L, -2, BigDecimal.ROUND_UP)); assertEquals(100L, Const.round(100L, -2, BigDecimal.ROUND_DOWN)); assertEquals(100L, Const.round(100L, -2, BigDecimal.ROUND_CEILING)); assertEquals(100L, Const.round(100L, -2, BigDecimal.ROUND_FLOOR)); assertEquals(100L, Const.round(100L, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(100L, Const.round(100L, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(100L, Const.round(100L, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(100L, Const.round(100L, -2, Const.ROUND_HALF_CEILING)); assertEquals(200L, Const.round(120L, -2, BigDecimal.ROUND_UP)); assertEquals(100L, Const.round(120L, -2, BigDecimal.ROUND_DOWN)); assertEquals(200L, Const.round(120L, -2, BigDecimal.ROUND_CEILING)); assertEquals(100L, Const.round(120L, -2, BigDecimal.ROUND_FLOOR)); assertEquals(100L, Const.round(120L, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(100L, Const.round(120L, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(100L, Const.round(120L, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(100L, Const.round(120L, -2, Const.ROUND_HALF_CEILING)); assertEquals(200L, Const.round(150L, -2, BigDecimal.ROUND_UP)); assertEquals(100L, Const.round(150L, -2, BigDecimal.ROUND_DOWN)); assertEquals(200L, Const.round(150L, -2, BigDecimal.ROUND_CEILING)); assertEquals(100L, Const.round(150L, -2, BigDecimal.ROUND_FLOOR)); assertEquals(200L, Const.round(150L, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(100L, Const.round(150L, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(200L, Const.round(150L, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(200L, Const.round(150L, -2, Const.ROUND_HALF_CEILING)); assertEquals(200L, Const.round(170L, -2, BigDecimal.ROUND_UP)); assertEquals(100L, Const.round(170L, -2, BigDecimal.ROUND_DOWN)); assertEquals(200L, Const.round(170L, -2, BigDecimal.ROUND_CEILING)); assertEquals(100L, Const.round(170L, -2, BigDecimal.ROUND_FLOOR)); assertEquals(200L, Const.round(170L, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(200L, Const.round(170L, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(200L, Const.round(170L, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(200L, Const.round(170L, -2, Const.ROUND_HALF_CEILING)); assertEquals(200L, Const.round(200L, -2, BigDecimal.ROUND_UP)); assertEquals(200L, Const.round(200L, -2, BigDecimal.ROUND_DOWN)); assertEquals(200L, Const.round(200L, -2, BigDecimal.ROUND_CEILING)); assertEquals(200L, Const.round(200L, -2, BigDecimal.ROUND_FLOOR)); assertEquals(200L, Const.round(200L, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(200L, Const.round(200L, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(200L, Const.round(200L, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(200L, Const.round(200L, -2, Const.ROUND_HALF_CEILING)); assertEquals(300L, Const.round(220L, -2, BigDecimal.ROUND_UP)); assertEquals(200L, Const.round(220L, -2, BigDecimal.ROUND_DOWN)); assertEquals(300L, Const.round(220L, -2, BigDecimal.ROUND_CEILING)); assertEquals(200L, Const.round(220L, -2, BigDecimal.ROUND_FLOOR)); assertEquals(200L, Const.round(220L, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(200L, Const.round(220L, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(200L, Const.round(220L, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(200L, Const.round(220L, -2, Const.ROUND_HALF_CEILING)); assertEquals(300L, Const.round(250L, -2, BigDecimal.ROUND_UP)); assertEquals(200L, Const.round(250L, -2, BigDecimal.ROUND_DOWN)); assertEquals(300L, Const.round(250L, -2, BigDecimal.ROUND_CEILING)); assertEquals(200L, Const.round(250L, -2, BigDecimal.ROUND_FLOOR)); assertEquals(300L, Const.round(250L, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(200L, Const.round(250L, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(200L, Const.round(250L, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(300L, Const.round(250L, -2, Const.ROUND_HALF_CEILING)); assertEquals(300L, Const.round(270L, -2, BigDecimal.ROUND_UP)); assertEquals(200L, Const.round(270L, -2, BigDecimal.ROUND_DOWN)); assertEquals(300L, Const.round(270L, -2, BigDecimal.ROUND_CEILING)); assertEquals(200L, Const.round(270L, -2, BigDecimal.ROUND_FLOOR)); assertEquals(300L, Const.round(270L, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(300L, Const.round(270L, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(300L, Const.round(270L, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(300L, Const.round(270L, -2, Const.ROUND_HALF_CEILING)); assertEquals(-100L, Const.round(-100L, -2, BigDecimal.ROUND_UP)); assertEquals(-100L, Const.round(-100L, -2, BigDecimal.ROUND_DOWN)); assertEquals(-100L, Const.round(-100L, -2, BigDecimal.ROUND_CEILING)); assertEquals(-100L, Const.round(-100L, -2, BigDecimal.ROUND_FLOOR)); assertEquals(-100L, Const.round(-100L, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(-100L, Const.round(-100L, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-100L, Const.round(-100L, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-100L, Const.round(-100L, -2, Const.ROUND_HALF_CEILING)); assertEquals(-200L, Const.round(-120L, -2, BigDecimal.ROUND_UP)); assertEquals(-100L, Const.round(-120L, -2, BigDecimal.ROUND_DOWN)); assertEquals(-100L, Const.round(-120L, -2, BigDecimal.ROUND_CEILING)); assertEquals(-200L, Const.round(-120L, -2, BigDecimal.ROUND_FLOOR)); assertEquals(-100L, Const.round(-120L, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(-100L, Const.round(-120L, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-100L, Const.round(-120L, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-100L, Const.round(-120L, -2, Const.ROUND_HALF_CEILING)); assertEquals(-200L, Const.round(-150L, -2, BigDecimal.ROUND_UP)); assertEquals(-100L, Const.round(-150L, -2, BigDecimal.ROUND_DOWN)); assertEquals(-100L, Const.round(-150L, -2, BigDecimal.ROUND_CEILING)); assertEquals(-200L, Const.round(-150L, -2, BigDecimal.ROUND_FLOOR)); assertEquals(-200L, Const.round(-150L, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(-100L, Const.round(-150L, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-200L, Const.round(-150L, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-100L, Const.round(-150L, -2, Const.ROUND_HALF_CEILING)); assertEquals(-200L, Const.round(-170L, -2, BigDecimal.ROUND_UP)); assertEquals(-100L, Const.round(-170L, -2, BigDecimal.ROUND_DOWN)); assertEquals(-100L, Const.round(-170L, -2, BigDecimal.ROUND_CEILING)); assertEquals(-200L, Const.round(-170L, -2, BigDecimal.ROUND_FLOOR)); assertEquals(-200L, Const.round(-170L, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(-200L, Const.round(-170L, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-200L, Const.round(-170L, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-200L, Const.round(-170L, -2, Const.ROUND_HALF_CEILING)); assertEquals(-200L, Const.round(-200L, -2, BigDecimal.ROUND_UP)); assertEquals(-200L, Const.round(-200L, -2, BigDecimal.ROUND_DOWN)); assertEquals(-200L, Const.round(-200L, -2, BigDecimal.ROUND_CEILING)); assertEquals(-200L, Const.round(-200L, -2, BigDecimal.ROUND_FLOOR)); assertEquals(-200L, Const.round(-200L, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(-200L, Const.round(-200L, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-200L, Const.round(-200L, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-200L, Const.round(-200L, -2, Const.ROUND_HALF_CEILING)); assertEquals(-300L, Const.round(-220L, -2, BigDecimal.ROUND_UP)); assertEquals(-200L, Const.round(-220L, -2, BigDecimal.ROUND_DOWN)); assertEquals(-200L, Const.round(-220L, -2, BigDecimal.ROUND_CEILING)); assertEquals(-300L, Const.round(-220L, -2, BigDecimal.ROUND_FLOOR)); assertEquals(-200L, Const.round(-220L, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(-200L, Const.round(-220L, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-200L, Const.round(-220L, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-200L, Const.round(-220L, -2, Const.ROUND_HALF_CEILING)); assertEquals(-300L, Const.round(-250L, -2, BigDecimal.ROUND_UP)); assertEquals(-200L, Const.round(-250L, -2, BigDecimal.ROUND_DOWN)); assertEquals(-200L, Const.round(-250L, -2, BigDecimal.ROUND_CEILING)); assertEquals(-300L, Const.round(-250L, -2, BigDecimal.ROUND_FLOOR)); assertEquals(-300L, Const.round(-250L, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(-200L, Const.round(-250L, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-200L, Const.round(-250L, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-200L, Const.round(-250L, -2, Const.ROUND_HALF_CEILING)); assertEquals(-300L, Const.round(-270L, -2, BigDecimal.ROUND_UP)); assertEquals(-200L, Const.round(-270L, -2, BigDecimal.ROUND_DOWN)); assertEquals(-200L, Const.round(-270L, -2, BigDecimal.ROUND_CEILING)); assertEquals(-300L, Const.round(-270L, -2, BigDecimal.ROUND_FLOOR)); assertEquals(-300L, Const.round(-270L, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(-300L, Const.round(-270L, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-300L, Const.round(-270L, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-300L, Const.round(-270L, -2, Const.ROUND_HALF_CEILING)); }
From source file:org.sakaiproject.tool.gradebook.jsf.FacesUtil.java
/** * All Faces number formatting options round instead of truncating. * For the Gradebook, virtually no displayed numbers are ever supposed to * round up./*w ww .ja va 2 s.c o m*/ * * This method moves the specified raw value into a higher-resolution * BigDecimal, rounding away noise at MAXIMUM_MEANINGFUL_DECIMAL_PLACES. * It then rounds down to reach the specified maximum number * of decimal places and returns the equivalent double for * further formatting. * * This is all necessary because we don't store scores as * BigDecimal and because Java / JSF lacks a DecimalFormat * class which uses "floor" instead of "round" when * trimming decimal places. */ public static double getRoundDown(double rawValue, int maxDecimalPlaces) { if (maxDecimalPlaces == 0) { return Math.floor(rawValue); } else if (rawValue != 0) { // We don't use the BigDecimal ROUND_DOWN functionality directly, // because moving from lower resolution storage to a higher // resolution form can introduce false truncations (e.g., // a "17.99" double being treated as a "17.9899999999999" // BigDecimal). BigDecimal bd = (new BigDecimal(rawValue)) .setScale(MAXIMUM_MEANINGFUL_DECIMAL_PLACES, BigDecimal.ROUND_HALF_DOWN) .setScale(maxDecimalPlaces, BigDecimal.ROUND_DOWN); if (logger.isDebugEnabled()) logger.debug("getRoundDown: rawValue=" + rawValue + ", maxDecimalPlaces=" + maxDecimalPlaces + ", bigDecimal=" + (new BigDecimal(rawValue)) + ", returning=" + bd.doubleValue()); return bd.doubleValue(); } else { return rawValue; } }
From source file:org.silverpeas.core.util.time.Duration.java
public String getFormattedDurationAsHMS() { Duration roundedDuration = UnitUtil.getDuration( getRoundedTimeConverted(TimeUnit.SECOND).setScale(0, BigDecimal.ROUND_HALF_DOWN), TimeUnit.SECOND); return roundedDuration.getFormattedDuration("HH:mm:ss"); }
From source file:org.silverpeas.core.util.time.TimeData.java
/** * @see #getFormattedDuration(String)//from w w w.j a va 2 s . c o m */ public String getFormattedDurationAsHMS() { TimeData roundedTimeData = UnitUtil.getTimeData( getRoundedTimeConverted(TimeUnit.SEC).setScale(0, BigDecimal.ROUND_HALF_DOWN), TimeUnit.SEC); return roundedTimeData.getFormattedDuration("HH:mm:ss"); }