def test_MultiplyDec(test_data_dir): # Reading test data from the file with open(test_data_dir / "testData_MultiplyDec", "r") as multiplyDec_txt: for x in multiplyDec_txt: decNumber = x.split(",") # multiply two big numbers of arbitrary precision in dec actual_Value = PyBigNumbers.multiplyFromDec( decNumber[0], decNumber[1]) # Verifying the actual value with expected value assert actual_Value == decNumber[2].rstrip("\n"), "Test failed"
def __mul__(self, obj): if (self.isDec): if (self.mod is None): prodVal = PyBigNumbers.multiplyFromDec(self.value, obj.value) else: #print ('%s * %s mod %s' % (self.value, obj.value, self.mod)) prodVal = PyBigNumbers.Mul_mod_Dec(self.value, obj.value, self.mod) retVal = BigNum(prodVal, self.mod, self.isDec) return retVal else: if (self.mod is None): prodVal = PyBigNumbers.multiplyFromHex(self.value, obj.value) else: #print ('%s * %s mod %s' % (self.value, obj.value, self.mod)) prodVal = PyBigNumbers.Mul_mod_Hex(self.value, obj.value, self.mod) retVal = BigNum(prodVal, self.mod, self.isDec) return retVal