@Test public void shouldReturnProperExponenentInScientificNotation() { assertEquals(-3, ops.getExponentInScientificNotation(0.0010f)); assertEquals(-3, ops.getExponentInScientificNotation(0.0020f)); assertEquals(-3, ops.getExponentInScientificNotation(0.009999f)); assertEquals(-2, ops.getExponentInScientificNotation(0.020000000f)); assertEquals(-2, ops.getExponentInScientificNotation(0.09999f)); assertEquals(-1, ops.getExponentInScientificNotation(0.10f)); assertEquals(-1, ops.getExponentInScientificNotation(0.20f)); assertEquals(-1, ops.getExponentInScientificNotation(0.9999f)); assertEquals(0, ops.getExponentInScientificNotation(0.0f)); assertEquals(0, ops.getExponentInScientificNotation(1.0f)); assertEquals(0, ops.getExponentInScientificNotation(2.0f)); assertEquals(0, ops.getExponentInScientificNotation(9.999f)); assertEquals(1, ops.getExponentInScientificNotation(10.0f)); assertEquals(1, ops.getExponentInScientificNotation(20.0f)); assertEquals(1, ops.getExponentInScientificNotation(99.999f)); assertEquals(2, ops.getExponentInScientificNotation(100.0f)); assertEquals(2, ops.getExponentInScientificNotation(200.0f)); assertEquals(2, ops.getExponentInScientificNotation(999.999f)); assertEquals(3, ops.getExponentInScientificNotation(1000.0f)); assertEquals(3, ops.getExponentInScientificNotation(2000.0f)); assertEquals(3, ops.getExponentInScientificNotation(9999.999f)); }
@Override public int getExponentInScientificNotation( Float value ) { double v = Math.abs(value); int exp = 0; if (v > 1.0d) { while (v >= 10.0d) { v /= 10.0d; ++exp; } } else if (v == 0.0d) { } else if (v < 1.0d) { while (v < 1.0d) { v *= 10.0d; --exp; } } return exp; }
FloatOperations implements MathOperations<Float>, Comparator<Float> { @Override public int getExponentInScientificNotation( Float value ) { double v = Math.abs(value); int exp = 0; if (v > 1.0d) { while (v >= 10.0d) { v /= 10.0d; ++exp; } } else if (v == 0.0d) { } else if (v < 1.0d) { while (v < 1.0d) { v *= 10.0d; --exp; } } return exp; } }
FloatOperations implements MathOperations<Float>, Comparator<Float> { @Override public int getExponentInScientificNotation( Float value ) { double v = Math.abs(value); int exp = 0; if (v > 1.0d) { while (v >= 10.0d) { v /= 10.0d; ++exp; } } else if (v == 0.0d) { } else if (v < 1.0d) { while (v < 1.0d) { v *= 10.0d; --exp; } } return exp; }  }
FloatOperations implements MathOperations<Float>, Comparator<Float> { @Override public int getExponentInScientificNotation( Float value ) { double v = Math.abs(value); int exp = 0; if (v > 1.0d) { while (v >= 10.0d) { v /= 10.0d; ++exp; } } else if (v == 0.0d) { } else if (v < 1.0d) { while (v < 1.0d) { v *= 10.0d; --exp; } } return exp; }  @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 int getExponentInScientificNotation( Float value ) { double v = Math.abs(value); int exp = 0; if (v > 1.0d) { while (v >= 10.0d) { v /= 10.0d; ++exp; } } else if (v == 0.0d) { } else if (v < 1.0d) { while (v < 1.0d) { v *= 10.0d; --exp; } } return exp; }  @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 );  }