@Test public void shouldReturnProperExponenentInScientificNotation() { assertEquals(0l, ops.getExponentInScientificNotation(0l)); assertEquals(0l, ops.getExponentInScientificNotation(1l)); assertEquals(0l, ops.getExponentInScientificNotation(2l)); assertEquals(0l, ops.getExponentInScientificNotation(9l)); assertEquals(1l, ops.getExponentInScientificNotation(10l)); assertEquals(1l, ops.getExponentInScientificNotation(20l)); assertEquals(1l, ops.getExponentInScientificNotation(99l)); assertEquals(2l, ops.getExponentInScientificNotation(100l)); assertEquals(2l, ops.getExponentInScientificNotation(200l)); assertEquals(2l, ops.getExponentInScientificNotation(999l)); assertEquals(3l, ops.getExponentInScientificNotation(1000l)); assertEquals(3l, ops.getExponentInScientificNotation(2000l)); assertEquals(3l, ops.getExponentInScientificNotation(9999l)); }
@Override public int getExponentInScientificNotation( Long value ) { long v = Math.abs(value); int exp = 0; if (v > 1l) { while (v >= 10l) { v /= 10l; ++exp; } } else if (v == 0l) { } else if (v < 1l) { while (v < 1l) { v *= 10l; --exp; } } return exp; }
LongOperations implements MathOperations<Long>, Comparator<Long> { @Override public int getExponentInScientificNotation( Long value ) { long v = Math.abs(value); int exp = 0; if (v > 1l) { while (v >= 10l) { v /= 10l; ++exp; } } else if (v == 0l) { } else if (v < 1l) { while (v < 1l) { v *= 10l; --exp; } } return exp; } }
LongOperations implements MathOperations<Long>, Comparator<Long> { @Override public int getExponentInScientificNotation( Long value ) { long v = Math.abs(value); int exp = 0; if (v > 1l) { while (v >= 10l) { v /= 10l; ++exp; } } else if (v == 0l) { } else if (v < 1l) { while (v < 1l) { v *= 10l; --exp; } } return exp; }  }
LongOperations implements MathOperations<Long>, Comparator<Long> { @Override public int getExponentInScientificNotation( Long value ) { long v = Math.abs(value); int exp = 0; if (v > 1l) { while (v >= 10l) { v /= 10l; ++exp; } } else if (v == 0l) { } else if (v < 1l) { while (v < 1l) { v *= 10l; --exp; } } return exp; }  @Override Class<Long> getOperandClass(); @Override Long add( Long value1,
                     Long value2 ); @Override Long subtract( Long value1,
                          Long value2 ); @Override Long multiply( Long value1,
                          Long value2 ); @Override double divide( Long value1,
                          Long value2 ); @Override Long negate( Long value ); @Override Long increment( Long value ); @Override Long maximum( Long value1,
                         Long value2 ); @Override Long minimum( Long value1,
                         Long value2 ); @Override int compare( Long value1,
                        Long value2 ); @Override BigDecimal asBigDecimal( Long value ); @Override Long fromBigDecimal( BigDecimal value ); @Override Long createZeroValue(); @Override Long create( int value ); @Override Long create( long value ); @Override Long create( double value ); @Override double sqrt( Long value ); @Override Comparator<Long> getComparator(); @Override Long random( Long minimum,
                        Long maximum,
                        Random rng ); @Override double doubleValue( Long value ); @Override float floatValue( Long value ); @Override int intValue( Long value ); @Override long longValue( Long value ); @Override short shortValue( Long value ); @Override int getExponentInScientificNotation( Long value ); @Override Long roundUp( Long value,
                         int decimalShift ); @Override Long roundDown( Long value,
                           int decimalShift ); @Override Long keepSignificantFigures( Long value,
                                        int numSigFigs ); }
LongOperations implements MathOperations<Long>, Comparator<Long> { @Override public int getExponentInScientificNotation( Long value ) { long v = Math.abs(value); int exp = 0; if (v > 1l) { while (v >= 10l) { v /= 10l; ++exp; } } else if (v == 0l) { } else if (v < 1l) { while (v < 1l) { v *= 10l; --exp; } } return exp; }  @Override Class<Long> getOperandClass(); @Override Long add( Long value1,
                     Long value2 ); @Override Long subtract( Long value1,
                          Long value2 ); @Override Long multiply( Long value1,
                          Long value2 ); @Override double divide( Long value1,
                          Long value2 ); @Override Long negate( Long value ); @Override Long increment( Long value ); @Override Long maximum( Long value1,
                         Long value2 ); @Override Long minimum( Long value1,
                         Long value2 ); @Override int compare( Long value1,
                        Long value2 ); @Override BigDecimal asBigDecimal( Long value ); @Override Long fromBigDecimal( BigDecimal value ); @Override Long createZeroValue(); @Override Long create( int value ); @Override Long create( long value ); @Override Long create( double value ); @Override double sqrt( Long value ); @Override Comparator<Long> getComparator(); @Override Long random( Long minimum,
                        Long maximum,
                        Random rng ); @Override double doubleValue( Long value ); @Override float floatValue( Long value ); @Override int intValue( Long value ); @Override long longValue( Long value ); @Override short shortValue( Long value ); @Override int getExponentInScientificNotation( Long value ); @Override Long roundUp( Long value,
                         int decimalShift ); @Override Long roundDown( Long value,
                           int decimalShift ); @Override Long keepSignificantFigures( Long value,
                                        int numSigFigs );  }