예제 #1
0
 def test_big_integer_mul_empty_to_empty(self):
     a = BigInteger()
     b = BigInteger()
     c = a * b
     self.assertEqual(c, BigInteger())
예제 #2
0
 def test_big_integer_sub_full_to_empty(self):
     a = BigInteger([9, 9, 9])
     b = BigInteger()
     c = a - b
     self.assertEqual(c, BigInteger([9, 9, 9]))
예제 #3
0
 def test_big_integer_sub_full_border(self):
     a = BigInteger([8, 5, 0, 1])
     b = BigInteger([9, 5])
     c = a - b
     self.assertEqual(c, BigInteger([9, 9, 9]))
예제 #4
0
 def test_big_integer_can_create(self):
     big_integer = BigInteger()
     self.assertTrue(isinstance(big_integer, BigInteger))
예제 #5
0
 def test_big_integer_sub_full_to_full(self):
     a = BigInteger([6, 7, 3])
     b = BigInteger([5, 5])
     c = a - b
     self.assertEqual(c, BigInteger([1, 2, 3]))
예제 #6
0
 def test_big_integer_eq_false_empty(self):
     a = BigInteger()
     b = BigInteger([2, 1, 1, 4, 5])
     self.assertNotEqual(a, b)
예제 #7
0
 def test_big_integer_eq_true_empty_diff(self):
     a = BigInteger()
     b = BigInteger([])
     self.assertEqual(a, b)
예제 #8
0
 def test_big_integer_eq_false_diff_size(self):
     a = BigInteger([1, 1, 1])
     b = BigInteger([2, 1, 1, 4, 5])
     self.assertNotEqual(a, b)
예제 #9
0
 def test_big_integer_eq_true(self):
     a = BigInteger([1, 1, 1])
     b = BigInteger([1, 1, 1])
     self.assertEqual(a, b)
예제 #10
0
 def test_big_integer_can_create_full(self):
     big_integer = BigInteger([2, 1, 4])
     self.assertTrue(isinstance(big_integer, BigInteger))
예제 #11
0
 def test_big_integer_mul_full_to_full(self):
     a = BigInteger([8, 7, 1])
     b = BigInteger([5, 5])
     c = a * b
     self.assertEqual(c, BigInteger([0, 9, 7, 9]))
예제 #12
0
def string_to_big_integer(string):
    np_array = np.array([])
    for i, v in enumerate(string):
        np_array = np.insert(np_array, 0, int(v))
    return BigInteger(np_array.tolist())