@Test
public void uBtcRounding() throws Exception {

    assertEquals("0", format(ZERO, 6, 0));
    assertEquals("0.00", format(ZERO, 6, 2));
    assertEquals("1000000", format(COIN, 6, 0));
    assertEquals("1000000", format(COIN, 6, 0, 2));
    assertEquals("1000000.0", format(COIN, 6, 1));
    assertEquals("1000000.00", format(COIN, 6, 2));
    final Coin justNot = COIN.subtract(SATOSHI);
    assertEquals("1000000", format(justNot, 6, 0));
    assertEquals("999999.99", format(justNot, 6, 0, 2));
    assertEquals("1000000.0", format(justNot, 6, 1));
    assertEquals("999999.99", format(justNot, 6, 2));
    final Coin slightlyMore = COIN.add(SATOSHI);
    assertEquals("1000000", format(slightlyMore, 6, 0));
    assertEquals("1000000.01", format(slightlyMore, 6, 0, 2));
    assertEquals("1000000.0", format(slightlyMore, 6, 1));
    assertEquals("1000000.01", format(slightlyMore, 6, 2));
    final Coin pivot = COIN.add(SATOSHI.multiply(5));
    assertEquals("1000000.05", format(pivot, 6, 2));
    assertEquals("1000000.05", format(pivot, 6, 0, 2));
    assertEquals("1000000.1", format(pivot, 6, 1));
    assertEquals("1000000.1", format(pivot, 6, 0, 1));
    final Coin value = Coin.valueOf(1122334455667788l);
    assertEquals("11223344556678", format(value, 6, 0));
    assertEquals("11223344556677.88", format(value, 6, 2));
    assertEquals("11223344556677.9", format(value, 6, 1));
    assertEquals("11223344556677.88", format(value, 6, 2));
}