예제 #1
0
    def test_round_to_even_for_two_nearest_integers(self):
        self.assertEqual(0, numbers.bankersround(Decimal('0.5')))
        self.assertEqual(2, numbers.bankersround(Decimal('1.5')))
        self.assertEqual(-2, numbers.bankersround(Decimal('-2.5')))

        self.assertEqual(0, numbers.bankersround(Decimal('0.05'), ndigits=1))
        self.assertEqual(Decimal('0.2'), numbers.bankersround(Decimal('0.15'), ndigits=1))
예제 #2
0
def test_bankersround():
    assert numbers.bankersround(5.5, 0) == 6.0
    assert numbers.bankersround(6.5, 0) == 6.0
    assert numbers.bankersround(-6.5, 0) == -6.0
    assert numbers.bankersround(1234.0, -2) == 1200.0
예제 #3
0
 def test_round_to_nearest_integer(self):
     self.assertEqual(1, numbers.bankersround(Decimal('0.5001')))