@Test public void shouldRoundNumbersGreaterThan10() { assertEquals(101.0f, ops.roundUp(101.2523f, 0), 0.01f); assertEquals(101.0f, ops.roundUp(101.2323f, 0), 0.01f); assertEquals(101.3f, ops.roundUp(101.2523f, 1), 0.01f); assertEquals(101.2f, ops.roundUp(101.2323f, 1), 0.01f); assertEquals(110.0f, ops.roundUp(109.2323f, -1), 1f); assertEquals(100.0f, ops.roundUp(101.2323f, -1), 1f); }
@Override public Float roundUp( Float value, int decimalShift ) { if (value == 0) return 0.0f; double shiftedValue = (Math.abs(value.doubleValue()) * Math.pow(10.0d, decimalShift) + 0.5d) * Math.signum(value); double roundedValue = (long)shiftedValue; return (float)(roundedValue * Math.pow(10.0d, -decimalShift)); }
FloatOperations implements MathOperations<Float>, Comparator<Float> { @Override public Float roundUp( Float value, int decimalShift ) { if (value == 0) return 0.0f; double shiftedValue = (Math.abs(value.doubleValue()) * Math.pow(10.0d, decimalShift) + 0.5d) * Math.signum(value); double roundedValue = (long)shiftedValue; return (float)(roundedValue * Math.pow(10.0d, -decimalShift)); } }
FloatOperations implements MathOperations<Float>, Comparator<Float> { @Override public Float roundUp( Float value, int decimalShift ) { if (value == 0) return 0.0f; double shiftedValue = (Math.abs(value.doubleValue()) * Math.pow(10.0d, decimalShift) + 0.5d) * Math.signum(value); double roundedValue = (long)shiftedValue; return (float)(roundedValue * Math.pow(10.0d, -decimalShift)); }  }
FloatOperations implements MathOperations<Float>, Comparator<Float> { @Override public Float roundUp( Float value, int decimalShift ) { if (value == 0) return 0.0f; double shiftedValue = (Math.abs(value.doubleValue()) * Math.pow(10.0d, decimalShift) + 0.5d) * Math.signum(value); double roundedValue = (long)shiftedValue; return (float)(roundedValue * Math.pow(10.0d, -decimalShift)); }  @Override Class<Float> getOperandClass(); @Override Float add( Float value1,
                      Float value2 ); @Override Float subtract( Float value1,
                           Float value2 ); @Override Float multiply( Float value1,
                           Float value2 ); @Override double divide( Float value1,
                          Float value2 ); @Override Float negate( Float value ); @Override Float increment( Float value ); @Override Float maximum( Float value1,
                          Float value2 ); @Override Float minimum( Float value1,
                          Float value2 ); @Override int compare( Float value1,
                        Float value2 ); @Override BigDecimal asBigDecimal( Float value ); @Override Float fromBigDecimal( BigDecimal value ); @Override Float createZeroValue(); @Override Float create( int value ); @Override Float create( long value ); @Override Float create( double value ); @Override double sqrt( Float value ); @Override Comparator<Float> getComparator(); @Override Float random( Float minimum,
                         Float maximum,
                         Random rng ); @Override double doubleValue( Float value ); @Override float floatValue( Float value ); @Override int intValue( Float value ); @Override long longValue( Float value ); @Override short shortValue( Float value ); @Override int getExponentInScientificNotation( Float value ); @Override Float roundUp( Float value,
                          int decimalShift ); @Override Float roundDown( Float value,
                            int decimalShift ); @Override Float keepSignificantFigures( Float value,
                                         int numSigFigs ); }
FloatOperations implements MathOperations<Float>, Comparator<Float> { @Override public Float roundUp( Float value, int decimalShift ) { if (value == 0) return 0.0f; double shiftedValue = (Math.abs(value.doubleValue()) * Math.pow(10.0d, decimalShift) + 0.5d) * Math.signum(value); double roundedValue = (long)shiftedValue; return (float)(roundedValue * Math.pow(10.0d, -decimalShift)); }  @Override Class<Float> getOperandClass(); @Override Float add( Float value1,
                      Float value2 ); @Override Float subtract( Float value1,
                           Float value2 ); @Override Float multiply( Float value1,
                           Float value2 ); @Override double divide( Float value1,
                          Float value2 ); @Override Float negate( Float value ); @Override Float increment( Float value ); @Override Float maximum( Float value1,
                          Float value2 ); @Override Float minimum( Float value1,
                          Float value2 ); @Override int compare( Float value1,
                        Float value2 ); @Override BigDecimal asBigDecimal( Float value ); @Override Float fromBigDecimal( BigDecimal value ); @Override Float createZeroValue(); @Override Float create( int value ); @Override Float create( long value ); @Override Float create( double value ); @Override double sqrt( Float value ); @Override Comparator<Float> getComparator(); @Override Float random( Float minimum,
                         Float maximum,
                         Random rng ); @Override double doubleValue( Float value ); @Override float floatValue( Float value ); @Override int intValue( Float value ); @Override long longValue( Float value ); @Override short shortValue( Float value ); @Override int getExponentInScientificNotation( Float value ); @Override Float roundUp( Float value,
                          int decimalShift ); @Override Float roundDown( Float value,
                            int decimalShift ); @Override Float keepSignificantFigures( Float value,
                                         int numSigFigs );  }