MCPcopy Create free account
hub / github.com/ccxt/ccxt / add

Method add

python/ccxt/base/precise.py:100–109  ·  view source on GitHub ↗
(self, other)

Source from the content-addressed store, hash-verified

98 return Precise(result, precision)
99
100 def add(self, other):
101 if self.decimals == other.decimals:
102 integer_result = self.integer + other.integer
103 return Precise(integer_result, self.decimals)
104 else:
105 smaller, bigger = [other, self] if self.decimals > other.decimals else [self, other]
106 exponent = bigger.decimals - smaller.decimals
107 normalised = smaller.integer * (self.base ** exponent)
108 result = normalised + bigger.integer
109 return Precise(result, bigger.decimals)
110
111 def sub(self, other):
112 negative = Precise(-other.integer, other.decimals)

Callers 8

__add__Method · 0.95
subMethod · 0.95
appendMethod · 0.45
appendMethod · 0.45
appendMethod · 0.45
string_addMethod · 0.45
walkFunction · 0.45

Calls 1

PreciseClass · 0.70

Tested by

no test coverage detected