@Test
public void mBtcRounding() throws Exception {

    assertEquals("0", format(ZERO, 3, 0));
    assertEquals("0.00", format(ZERO, 3, 2));
    assertEquals("1000", format(COIN, 3, 0));
    assertEquals("1000.0", format(COIN, 3, 1));
    assertEquals("1000.00", format(COIN, 3, 2));
    assertEquals("1000.00", format(COIN, 3, 2, 2));
    assertEquals("1000.000", format(COIN, 3, 3));
    assertEquals("1000.0000", format(COIN, 3, 4));
    final Coin justNot = COIN.subtract(SATOSHI.multiply(10));
    assertEquals("1000", format(justNot, 3, 0));
    assertEquals("1000.0", format(justNot, 3, 1));
    assertEquals("1000.00", format(justNot, 3, 2));
    assertEquals("999.9999", format(justNot, 3, 2, 2));
    assertEquals("1000.000", format(justNot, 3, 3));
    assertEquals("999.9999", format(justNot, 3, 4));
    final Coin slightlyMore = COIN.add(SATOSHI.multiply(10));
    assertEquals("1000", format(slightlyMore, 3, 0));
    assertEquals("1000.0", format(slightlyMore, 3, 1));
    assertEquals("1000.00", format(slightlyMore, 3, 2));
    assertEquals("1000.000", format(slightlyMore, 3, 3));
    assertEquals("1000.0001", format(slightlyMore, 3, 2, 2));
    assertEquals("1000.0001", format(slightlyMore, 3, 4));
    final Coin pivot = COIN.add(SATOSHI.multiply(50));
    assertEquals("1000.0005", format(pivot, 3, 4));
    assertEquals("1000.0005", format(pivot, 3, 3, 1));
    assertEquals("1000.001", format(pivot, 3, 3));
    final Coin value = Coin.valueOf(1122334455667788l);
    assertEquals("11223344557", format(value, 3, 0));
    assertEquals("11223344556.7", format(value, 3, 1));
    assertEquals("11223344556.68", format(value, 3, 2));
    assertEquals("11223344556.6779", format(value, 3, 2, 2));
    assertEquals("11223344556.678", format(value, 3, 3));
    assertEquals("11223344556.6779", format(value, 3, 4));
}