def test_divide_int_fixed_point_infinite_precision(self): a = 10 b = FixedPoint(3, QFormat(8, 8)) c = a / b self.assertIsInstance(c, FixedPoint) self.assertEqual(c, FixedPoint(3.33203125))
def test_divide_complex_fixed_point(self): a = 12 + 6j b = FixedPoint(3, QFormat(5, 11)) c = a / b self.assertIsInstance(c, complex) self.assertEqual(c, (4 + 2j))
def test_divide_fixed_point_complex(self): a = FixedPoint(14.625, QFormat(5, 11)) b = 3 - 1j c = a / b self.assertIsInstance(c, complex) self.assertEqual(c, (4.3875 + 1.4625j))
def test_divide_int_fixed_point(self): a = 12 b = FixedPoint(4, QFormat(8, 8)) c = a / b self.assertIsInstance(c, FixedPoint) self.assertEqual(c, FixedPoint(3))
def test_multiply_complex_fixed_point(self): a = 3 - 2j b = FixedPoint(14.625, QFormat(5, 11)) c = a * b self.assertIsInstance(c, complex) self.assertEqual(c, 43.875 - 29.25j)
def test_divide_fixed_point_int_infinite_precision(self): a = FixedPoint(10, QFormat(8, 8)) b = 3 c = a / b self.assertIsInstance(c, FixedPoint) self.assertEqual(c, FixedPoint(3.33349609375))
def test_multiply_int_fixed_point(self): a = 7 b = FixedPoint(12.1875, QFormat(8, 8)) c = a * b self.assertIsInstance(c, FixedPoint) self.assertEqual(c, FixedPoint(85.3125))
def test_multiply_fraction_fixed_point(self): a = Fraction(1, 3) b = FixedPoint(12.1875, QFormat(8, 8)) c = a * b self.assertIsInstance(c, Fraction) self.assertEqual(c, Fraction(65, 16))
def test_multiply_fixed_point_fixed_point_fractional(self): a = FixedPoint(3.125, QFormat(8, 8)) b = FixedPoint(12.1875, QFormat(8, 8)) c = a * b self.assertIsInstance(c, FixedPoint) self.assertEqual(c, FixedPoint(38.0859375))
def test_multiply_float_fixed_point(self): a = 12.1875 b = FixedPoint(3.125, QFormat(8, 8)) c = a * b self.assertIsInstance(c, float) self.assertEqual(c, 38.0859375)
def test_multiply_fixed_point_fixed_point_integers(self): a = FixedPoint(3, QFormat(5, 3)) b = FixedPoint(5, QFormat(6, 2)) c = a * b self.assertIsInstance(c, FixedPoint) self.assertEqual(c, FixedPoint(15))
def test_pow_fixed_point_complex(self): a = FixedPoint(2.5, QFormat(5, 11)) b = 3 - 2j c = a**b self.assertIsInstance(c, complex) self.assertEqual(c, (-4.043832497129643 - 15.092648665332344j))
def test_mod_complex_fixed_point(self): a = 12 + 6j b = FixedPoint(3, QFormat(5, 11)) with self.assertRaises(TypeError): c = a % b
def test_mod_int_fixed_point(self): a = 12 b = FixedPoint(5, QFormat(8, 8)) c = a % b self.assertIsInstance(c, FixedPoint) self.assertEqual(c, FixedPoint(2))
def test_mod_fixed_point_complex(self): a = FixedPoint(14.625, QFormat(5, 11)) b = 3 - 1j with self.assertRaises(TypeError): c = a % b