@@ -243,7 +243,7 @@ class DivisionByZero(DecimalException, ZeroDivisionError):
243243 """
244244
245245 def handle (self , context , sign , * args ):
246- return _Infsign [sign ]
246+ return _SignedInfinity [sign ]
247247
248248class DivisionImpossible (InvalidOperation ):
249249 """Cannot perform the division adequately.
@@ -341,15 +341,15 @@ class Overflow(Inexact, Rounded):
341341 def handle (self , context , sign , * args ):
342342 if context .rounding in (ROUND_HALF_UP , ROUND_HALF_EVEN ,
343343 ROUND_HALF_DOWN , ROUND_UP ):
344- return _Infsign [sign ]
344+ return _SignedInfinity [sign ]
345345 if sign == 0 :
346346 if context .rounding == ROUND_CEILING :
347- return _Infsign [sign ]
347+ return _SignedInfinity [sign ]
348348 return _dec_from_triple (sign , '9' * context .prec ,
349349 context .Emax - context .prec + 1 )
350350 if sign == 1 :
351351 if context .rounding == ROUND_FLOOR :
352- return _Infsign [sign ]
352+ return _SignedInfinity [sign ]
353353 return _dec_from_triple (sign , '9' * context .prec ,
354354 context .Emax - context .prec + 1 )
355355
@@ -1173,12 +1173,12 @@ def __mul__(self, other, context=None):
11731173 if self ._isinfinity ():
11741174 if not other :
11751175 return context ._raise_error (InvalidOperation , '(+-)INF * 0' )
1176- return _Infsign [resultsign ]
1176+ return _SignedInfinity [resultsign ]
11771177
11781178 if other ._isinfinity ():
11791179 if not self :
11801180 return context ._raise_error (InvalidOperation , '0 * (+-)INF' )
1181- return _Infsign [resultsign ]
1181+ return _SignedInfinity [resultsign ]
11821182
11831183 resultexp = self ._exp + other ._exp
11841184
@@ -1228,7 +1228,7 @@ def __truediv__(self, other, context=None):
12281228 return context ._raise_error (InvalidOperation , '(+-)INF/(+-)INF' )
12291229
12301230 if self ._isinfinity ():
1231- return _Infsign [sign ]
1231+ return _SignedInfinity [sign ]
12321232
12331233 if other ._isinfinity ():
12341234 context ._raise_error (Clamped , 'Division by infinity' )
@@ -1328,7 +1328,7 @@ def __divmod__(self, other, context=None):
13281328 ans = context ._raise_error (InvalidOperation , 'divmod(INF, INF)' )
13291329 return ans , ans
13301330 else :
1331- return (_Infsign [sign ],
1331+ return (_SignedInfinity [sign ],
13321332 context ._raise_error (InvalidOperation , 'INF % x' ))
13331333
13341334 if not other :
@@ -1476,7 +1476,7 @@ def __floordiv__(self, other, context=None):
14761476 if other ._isinfinity ():
14771477 return context ._raise_error (InvalidOperation , 'INF // INF' )
14781478 else :
1479- return _Infsign [self ._sign ^ other ._sign ]
1479+ return _SignedInfinity [self ._sign ^ other ._sign ]
14801480
14811481 if not other :
14821482 if self :
@@ -1820,12 +1820,12 @@ def fma(self, other, third, context=None):
18201820 if not other :
18211821 return context ._raise_error (InvalidOperation ,
18221822 'INF * 0 in fma' )
1823- product = _Infsign [self ._sign ^ other ._sign ]
1823+ product = _SignedInfinity [self ._sign ^ other ._sign ]
18241824 elif other ._exp == 'F' :
18251825 if not self :
18261826 return context ._raise_error (InvalidOperation ,
18271827 '0 * INF in fma' )
1828- product = _Infsign [self ._sign ^ other ._sign ]
1828+ product = _SignedInfinity [self ._sign ^ other ._sign ]
18291829 else :
18301830 product = _dec_from_triple (self ._sign ^ other ._sign ,
18311831 str (int (self ._int ) * int (other ._int )),
@@ -2175,7 +2175,7 @@ def __pow__(self, other, modulo=None, context=None):
21752175 if not self :
21762176 return context ._raise_error (InvalidOperation , '0 ** 0' )
21772177 else :
2178- return _Dec_p1
2178+ return _One
21792179
21802180 # result has sign 1 iff self._sign is 1 and other is an odd integer
21812181 result_sign = 0
@@ -2197,19 +2197,19 @@ def __pow__(self, other, modulo=None, context=None):
21972197 if other ._sign == 0 :
21982198 return _dec_from_triple (result_sign , '0' , 0 )
21992199 else :
2200- return _Infsign [result_sign ]
2200+ return _SignedInfinity [result_sign ]
22012201
22022202 # Inf**(+ve or Inf) = Inf; Inf**(-ve or -Inf) = 0
22032203 if self ._isinfinity ():
22042204 if other ._sign == 0 :
2205- return _Infsign [result_sign ]
2205+ return _SignedInfinity [result_sign ]
22062206 else :
22072207 return _dec_from_triple (result_sign , '0' , 0 )
22082208
22092209 # 1**other = 1, but the choice of exponent and the flags
22102210 # depend on the exponent of self, and on whether other is a
22112211 # positive integer, a negative integer, or neither
2212- if self == _Dec_p1 :
2212+ if self == _One :
22132213 if other ._isinteger ():
22142214 # exp = max(self._exp*max(int(other), 0),
22152215 # 1-context.prec) but evaluating int(other) directly
@@ -2242,7 +2242,7 @@ def __pow__(self, other, modulo=None, context=None):
22422242 if (other ._sign == 0 ) == (self_adj < 0 ):
22432243 return _dec_from_triple (result_sign , '0' , 0 )
22442244 else :
2245- return _Infsign [result_sign ]
2245+ return _SignedInfinity [result_sign ]
22462246
22472247 # from here on, the result always goes through the call
22482248 # to _fix at the end of this function.
@@ -2762,9 +2762,9 @@ def compare_total(self, other):
27622762 """
27632763 # if one is negative and the other is positive, it's easy
27642764 if self ._sign and not other ._sign :
2765- return _Dec_n1
2765+ return _NegativeOne
27662766 if not self ._sign and other ._sign :
2767- return _Dec_p1
2767+ return _One
27682768 sign = self ._sign
27692769
27702770 # let's handle both NaN types
@@ -2774,51 +2774,51 @@ def compare_total(self, other):
27742774 if self_nan == other_nan :
27752775 if self ._int < other ._int :
27762776 if sign :
2777- return _Dec_p1
2777+ return _One
27782778 else :
2779- return _Dec_n1
2779+ return _NegativeOne
27802780 if self ._int > other ._int :
27812781 if sign :
2782- return _Dec_n1
2782+ return _NegativeOne
27832783 else :
2784- return _Dec_p1
2785- return _Dec_0
2784+ return _One
2785+ return _Zero
27862786
27872787 if sign :
27882788 if self_nan == 1 :
2789- return _Dec_n1
2789+ return _NegativeOne
27902790 if other_nan == 1 :
2791- return _Dec_p1
2791+ return _One
27922792 if self_nan == 2 :
2793- return _Dec_n1
2793+ return _NegativeOne
27942794 if other_nan == 2 :
2795- return _Dec_p1
2795+ return _One
27962796 else :
27972797 if self_nan == 1 :
2798- return _Dec_p1
2798+ return _One
27992799 if other_nan == 1 :
2800- return _Dec_n1
2800+ return _NegativeOne
28012801 if self_nan == 2 :
2802- return _Dec_p1
2802+ return _One
28032803 if other_nan == 2 :
2804- return _Dec_n1
2804+ return _NegativeOne
28052805
28062806 if self < other :
2807- return _Dec_n1
2807+ return _NegativeOne
28082808 if self > other :
2809- return _Dec_p1
2809+ return _One
28102810
28112811 if self ._exp < other ._exp :
28122812 if sign :
2813- return _Dec_p1
2813+ return _One
28142814 else :
2815- return _Dec_n1
2815+ return _NegativeOne
28162816 if self ._exp > other ._exp :
28172817 if sign :
2818- return _Dec_n1
2818+ return _NegativeOne
28192819 else :
2820- return _Dec_p1
2821- return _Dec_0
2820+ return _One
2821+ return _Zero
28222822
28232823
28242824 def compare_total_mag (self , other ):
@@ -2859,11 +2859,11 @@ def exp(self, context=None):
28592859
28602860 # exp(-Infinity) = 0
28612861 if self ._isinfinity () == - 1 :
2862- return _Dec_0
2862+ return _Zero
28632863
28642864 # exp(0) = 1
28652865 if not self :
2866- return _Dec_p1
2866+ return _One
28672867
28682868 # exp(Infinity) = Infinity
28692869 if self ._isinfinity () == 1 :
@@ -3015,15 +3015,15 @@ def ln(self, context=None):
30153015
30163016 # ln(0.0) == -Infinity
30173017 if not self :
3018- return _negInf
3018+ return _NegativeInfinity
30193019
30203020 # ln(Infinity) = Infinity
30213021 if self ._isinfinity () == 1 :
3022- return _Inf
3022+ return _Infinity
30233023
30243024 # ln(1.0) == 0.0
3025- if self == _Dec_p1 :
3026- return _Dec_0
3025+ if self == _One :
3026+ return _Zero
30273027
30283028 # ln(negative) raises InvalidOperation
30293029 if self ._sign == 1 :
@@ -3095,11 +3095,11 @@ def log10(self, context=None):
30953095
30963096 # log10(0.0) == -Infinity
30973097 if not self :
3098- return _negInf
3098+ return _NegativeInfinity
30993099
31003100 # log10(Infinity) = Infinity
31013101 if self ._isinfinity () == 1 :
3102- return _Inf
3102+ return _Infinity
31033103
31043104 # log10(negative or -Infinity) raises InvalidOperation
31053105 if self ._sign == 1 :
@@ -3151,7 +3151,7 @@ def logb(self, context=None):
31513151
31523152 # logb(+/-Inf) = +Inf
31533153 if self ._isinfinity ():
3154- return _Inf
3154+ return _Infinity
31553155
31563156 # logb(0) = -Inf, DivisionByZero
31573157 if not self :
@@ -3308,7 +3308,7 @@ def next_minus(self, context=None):
33083308 return ans
33093309
33103310 if self ._isinfinity () == - 1 :
3311- return _negInf
3311+ return _NegativeInfinity
33123312 if self ._isinfinity () == 1 :
33133313 return _dec_from_triple (0 , '9' * context .prec , context .Etop ())
33143314
@@ -3331,7 +3331,7 @@ def next_plus(self, context=None):
33313331 return ans
33323332
33333333 if self ._isinfinity () == 1 :
3334- return _Inf
3334+ return _Infinity
33353335 if self ._isinfinity () == - 1 :
33363336 return _dec_from_triple (1 , '9' * context .prec , context .Etop ())
33373337
@@ -5572,15 +5572,15 @@ def _format_align(body, spec_dict):
55725572##### Useful Constants (internal use only) ################################
55735573
55745574# Reusable defaults
5575- _Inf = Decimal ('Inf' )
5576- _negInf = Decimal ('-Inf' )
5575+ _Infinity = Decimal ('Inf' )
5576+ _NegativeInfinity = Decimal ('-Inf' )
55775577_NaN = Decimal ('NaN' )
5578- _Dec_0 = Decimal (0 )
5579- _Dec_p1 = Decimal (1 )
5580- _Dec_n1 = Decimal (- 1 )
5578+ _Zero = Decimal (0 )
5579+ _One = Decimal (1 )
5580+ _NegativeOne = Decimal (- 1 )
55815581
5582- # _Infsign [sign] is infinity w/ that sign
5583- _Infsign = (_Inf , _negInf )
5582+ # _SignedInfinity [sign] is infinity w/ that sign
5583+ _SignedInfinity = (_Infinity , _NegativeInfinity )
55845584
55855585
55865586
0 commit comments