MCPcopy Create free account
hub / github.com/python/cpython / canonical

Method canonical

Lib/_pydecimal.py:4155–4166  ·  view source on GitHub ↗

Returns the same Decimal object. As we do not have different encodings for the same number, the received object already is in its canonical form. >>> ExtendedContext.canonical(Decimal('2.50')) Decimal('2.50')

(self, a)

Source from the content-addressed store, hash-verified

4153 return str(a._fix(self))
4154
4155 def canonical(self, a):
4156 """Returns the same Decimal object.
4157
4158 As we do not have different encodings for the same number, the
4159 received object already is in its canonical form.
4160
4161 >>> ExtendedContext.canonical(Decimal('2.50'))
4162 Decimal('2.50')
4163 """
4164 if not isinstance(a, Decimal):
4165 raise TypeError("canonical requires a Decimal as an argument.")
4166 return a.canonical()
4167
4168 def compare(self, a, b):
4169 """Compares values numerically.

Callers

nothing calls this directly

Calls 1

canonicalMethod · 0.45

Tested by

no test coverage detected