Java Code Examples for com.google.common.math.IntMath#log10()

The following examples show how to use com.google.common.math.IntMath#log10() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GuavaMathUnitTest.java    From tutorials with MIT License 4 votes vote down vote up
@Test
public void should_round_log10_result() {
    int result = IntMath.log10(11, RoundingMode.HALF_UP);
    assertThat(result, equalTo(1));
}
 
Example 2
Source File: GuavaIntMathUnitTest.java    From tutorials with MIT License 4 votes vote down vote up
@Test
public void whenLog10IntegerValues_shouldLog10ThemAndReturnTheResultForCeilingRounding() {
    int result = IntMath.log10(30, RoundingMode.CEILING);
    assertEquals(2, result);
}
 
Example 3
Source File: GuavaIntMathUnitTest.java    From tutorials with MIT License 4 votes vote down vote up
@Test
public void whenLog10IntegerValues_shouldog10ThemAndReturnTheResultForFloorRounding() {
    int result = IntMath.log10(30, RoundingMode.FLOOR);
    assertEquals(1, result);
}
 
Example 4
Source File: GuavaIntMathUnitTest.java    From tutorials with MIT License 4 votes vote down vote up
@Test(expected = ArithmeticException.class)
public void whenLog10IntegerValues_shouldThrowArithmeticExceptionIfRoundingNotDefinedButNecessary() {
    IntMath.log10(30, RoundingMode.UNNECESSARY);
}