def test_zero_start(self): fraction = normalize(0b000101) >> 3 yk, t = partition(fraction, 4) self.assertTrue(yk.positive) self.assertEqual(yk.whole, 1) self.assertEqual(yk.fraction, normalize(0b0001) >> 3) self.assertTrue(t.positive) self.assertEqual(t.whole, 0) self.assertEqual(t.fraction, normalize(1) >> 1)
def test_one_zero(self): fraction = normalize(0b101001) yk, t = partition(fraction, 4) self.assertTrue(yk.positive) self.assertEqual(yk.whole, 1) self.assertEqual(yk.fraction, normalize(0b1011)) self.assertFalse(t.positive) self.assertEqual(t.whole, 0) self.assertEqual(t.fraction, -normalize(0b11))