示例#1
0
 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))
示例#2
0
 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))
示例#3
0
 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))
示例#4
0
 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))
示例#5
0
 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)
示例#6
0
 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))
示例#7
0
 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))
示例#8
0
 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))
示例#9
0
 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))
示例#10
0
 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)
示例#11
0
 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))
示例#12
0
 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))
示例#13
0
 def test_mod_complex_fixed_point(self):
     a = 12 + 6j
     b = FixedPoint(3, QFormat(5, 11))
     with self.assertRaises(TypeError):
         c = a % b
示例#14
0
 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))
示例#15
0
 def test_mod_fixed_point_complex(self):
     a = FixedPoint(14.625, QFormat(5, 11))
     b = 3 - 1j
     with self.assertRaises(TypeError):
         c = a % b