MCPcopy Index your code
hub / github.com/python/cpython / number_class

Method number_class

Lib/_pydecimal.py:5055–5103  ·  view source on GitHub ↗

Returns an indication of the class of the operand. The class is one of the following strings: -sNaN -NaN -Infinity -Normal -Subnormal -Zero +Zero +Subnormal +Normal +Infinity >>> c =

(self, a)

Source from the content-addressed store, hash-verified

5053 return a.normalize(context=self)
5054
5055 def number_class(self, a):
5056 """Returns an indication of the class of the operand.
5057
5058 The class is one of the following strings:
5059 -sNaN
5060 -NaN
5061 -Infinity
5062 -Normal
5063 -Subnormal
5064 -Zero
5065 +Zero
5066 +Subnormal
5067 +Normal
5068 +Infinity
5069
5070 >>> c = ExtendedContext.copy()
5071 >>> c.Emin = -999
5072 >>> c.Emax = 999
5073 >>> c.number_class(Decimal('Infinity'))
5074 '+Infinity'
5075 >>> c.number_class(Decimal('1E-10'))
5076 '+Normal'
5077 >>> c.number_class(Decimal('2.50'))
5078 '+Normal'
5079 >>> c.number_class(Decimal('0.1E-999'))
5080 '+Subnormal'
5081 >>> c.number_class(Decimal('0'))
5082 '+Zero'
5083 >>> c.number_class(Decimal('-0'))
5084 '-Zero'
5085 >>> c.number_class(Decimal('-0.1E-999'))
5086 '-Subnormal'
5087 >>> c.number_class(Decimal('-1E-10'))
5088 '-Normal'
5089 >>> c.number_class(Decimal('-2.50'))
5090 '-Normal'
5091 >>> c.number_class(Decimal('-Infinity'))
5092 '-Infinity'
5093 >>> c.number_class(Decimal('NaN'))
5094 'NaN'
5095 >>> c.number_class(Decimal('-NaN'))
5096 'NaN'
5097 >>> c.number_class(Decimal('sNaN'))
5098 'sNaN'
5099 >>> c.number_class(123)
5100 '+Normal'
5101 """
5102 a = _convert_other(a, raiseit=True)
5103 return a.number_class(context=self)
5104
5105 def plus(self, a):
5106 """Plus corresponds to unary prefix plus in Python.

Callers 1

test_number_classMethod · 0.95

Calls 2

_convert_otherFunction · 0.85
number_classMethod · 0.45

Tested by 1

test_number_classMethod · 0.76