MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / normalize

Method normalize

tools/python-3.11.9-amd64/Lib/_pydecimal.py:5064–5086  ·  view source on GitHub ↗

normalize reduces an operand to its simplest form. Essentially a plus operation with all trailing zeros removed from the result. >>> ExtendedContext.normalize(Decimal('2.1')) Decimal('2.1') >>> ExtendedContext.normalize(Decimal('-2.0')) Decim

(self, a)

Source from the content-addressed store, hash-verified

5062 return a.next_toward(b, context=self)
5063
5064 def normalize(self, a):
5065 """normalize reduces an operand to its simplest form.
5066
5067 Essentially a plus operation with all trailing zeros removed from the
5068 result.
5069
5070 >>> ExtendedContext.normalize(Decimal('2.1'))
5071 Decimal('2.1')
5072 >>> ExtendedContext.normalize(Decimal('-2.0'))
5073 Decimal('-2')
5074 >>> ExtendedContext.normalize(Decimal('1.200'))
5075 Decimal('1.2')
5076 >>> ExtendedContext.normalize(Decimal('-120'))
5077 Decimal('-1.2E+2')
5078 >>> ExtendedContext.normalize(Decimal('120.00'))
5079 Decimal('1.2E+2')
5080 >>> ExtendedContext.normalize(Decimal('0.00'))
5081 Decimal('0')
5082 >>> ExtendedContext.normalize(6)
5083 Decimal('6')
5084 """
5085 a = _convert_other(a, raiseit=True)
5086 return a.normalize(context=self)
5087
5088 def number_class(self, a):
5089 """Returns an indication of the class of the operand.

Callers

nothing calls this directly

Calls 2

_convert_otherFunction · 0.85
normalizeMethod · 0.45

Tested by

no test coverage detected