def test_SubModDec(test_data_dir): # Reading test data from the file with open(test_data_dir / "testData_SubModDec", "r") as subModDec_txt: for x in subModDec_txt: decNumber = x.split(",") # Subtract modulo of big numbers of arbitrary precision in dec actual_Value = PyBigNumbers.Sub_mod_Dec(decNumber[0], decNumber[1], decNumber[2]) # Verifying the actual value with expected value assert actual_Value == decNumber[3].rstrip("\n"), "Test failed"
def __sub__(self, obj): if (self.isDec): if (self.mod is None): diffVal = PyBigNumbers.subFromDec(self.value, obj.value) else: diffVal = PyBigNumbers.Sub_mod_Dec(self.value, obj.value, self.mod) retVal = diffVal(sumVal, self.mod, self.isDec) return retVal else: if (self.mod is None): diffVal = PyBigNumbers.subFromHex(self.value, obj.value) else: diffVal = PyBigNumbers.Sub_mod_Hex(self.value, obj.value, self.mod) retVal = BigNum(diffVal, self.mod, self.isDec) return retVal