@@ -243,7 +243,7 @@ class DivisionByZero(DecimalException, ZeroDivisionError):
243
243
"""
244
244
245
245
def handle (self , context , sign , * args ):
246
- return _Infsign [sign ]
246
+ return _SignedInfinity [sign ]
247
247
248
248
class DivisionImpossible (InvalidOperation ):
249
249
"""Cannot perform the division adequately.
@@ -341,15 +341,15 @@ class Overflow(Inexact, Rounded):
341
341
def handle (self , context , sign , * args ):
342
342
if context .rounding in (ROUND_HALF_UP , ROUND_HALF_EVEN ,
343
343
ROUND_HALF_DOWN , ROUND_UP ):
344
- return _Infsign [sign ]
344
+ return _SignedInfinity [sign ]
345
345
if sign == 0 :
346
346
if context .rounding == ROUND_CEILING :
347
- return _Infsign [sign ]
347
+ return _SignedInfinity [sign ]
348
348
return _dec_from_triple (sign , '9' * context .prec ,
349
349
context .Emax - context .prec + 1 )
350
350
if sign == 1 :
351
351
if context .rounding == ROUND_FLOOR :
352
- return _Infsign [sign ]
352
+ return _SignedInfinity [sign ]
353
353
return _dec_from_triple (sign , '9' * context .prec ,
354
354
context .Emax - context .prec + 1 )
355
355
@@ -1204,12 +1204,12 @@ def __mul__(self, other, context=None):
1204
1204
if self ._isinfinity ():
1205
1205
if not other :
1206
1206
return context ._raise_error (InvalidOperation , '(+-)INF * 0' )
1207
- return _Infsign [resultsign ]
1207
+ return _SignedInfinity [resultsign ]
1208
1208
1209
1209
if other ._isinfinity ():
1210
1210
if not self :
1211
1211
return context ._raise_error (InvalidOperation , '0 * (+-)INF' )
1212
- return _Infsign [resultsign ]
1212
+ return _SignedInfinity [resultsign ]
1213
1213
1214
1214
resultexp = self ._exp + other ._exp
1215
1215
@@ -1259,7 +1259,7 @@ def __truediv__(self, other, context=None):
1259
1259
return context ._raise_error (InvalidOperation , '(+-)INF/(+-)INF' )
1260
1260
1261
1261
if self ._isinfinity ():
1262
- return _Infsign [sign ]
1262
+ return _SignedInfinity [sign ]
1263
1263
1264
1264
if other ._isinfinity ():
1265
1265
context ._raise_error (Clamped , 'Division by infinity' )
@@ -1362,7 +1362,7 @@ def __divmod__(self, other, context=None):
1362
1362
ans = context ._raise_error (InvalidOperation , 'divmod(INF, INF)' )
1363
1363
return ans , ans
1364
1364
else :
1365
- return (_Infsign [sign ],
1365
+ return (_SignedInfinity [sign ],
1366
1366
context ._raise_error (InvalidOperation , 'INF % x' ))
1367
1367
1368
1368
if not other :
@@ -1510,7 +1510,7 @@ def __floordiv__(self, other, context=None):
1510
1510
if other ._isinfinity ():
1511
1511
return context ._raise_error (InvalidOperation , 'INF // INF' )
1512
1512
else :
1513
- return _Infsign [self ._sign ^ other ._sign ]
1513
+ return _SignedInfinity [self ._sign ^ other ._sign ]
1514
1514
1515
1515
if not other :
1516
1516
if self :
@@ -1765,12 +1765,12 @@ def fma(self, other, third, context=None):
1765
1765
if not other :
1766
1766
return context ._raise_error (InvalidOperation ,
1767
1767
'INF * 0 in fma' )
1768
- product = _Infsign [self ._sign ^ other ._sign ]
1768
+ product = _SignedInfinity [self ._sign ^ other ._sign ]
1769
1769
elif other ._exp == 'F' :
1770
1770
if not self :
1771
1771
return context ._raise_error (InvalidOperation ,
1772
1772
'0 * INF in fma' )
1773
- product = _Infsign [self ._sign ^ other ._sign ]
1773
+ product = _SignedInfinity [self ._sign ^ other ._sign ]
1774
1774
else :
1775
1775
product = _dec_from_triple (self ._sign ^ other ._sign ,
1776
1776
str (int (self ._int ) * int (other ._int )),
@@ -2120,7 +2120,7 @@ def __pow__(self, other, modulo=None, context=None):
2120
2120
if not self :
2121
2121
return context ._raise_error (InvalidOperation , '0 ** 0' )
2122
2122
else :
2123
- return _Dec_p1
2123
+ return _One
2124
2124
2125
2125
# result has sign 1 iff self._sign is 1 and other is an odd integer
2126
2126
result_sign = 0
@@ -2142,19 +2142,19 @@ def __pow__(self, other, modulo=None, context=None):
2142
2142
if other ._sign == 0 :
2143
2143
return _dec_from_triple (result_sign , '0' , 0 )
2144
2144
else :
2145
- return _Infsign [result_sign ]
2145
+ return _SignedInfinity [result_sign ]
2146
2146
2147
2147
# Inf**(+ve or Inf) = Inf; Inf**(-ve or -Inf) = 0
2148
2148
if self ._isinfinity ():
2149
2149
if other ._sign == 0 :
2150
- return _Infsign [result_sign ]
2150
+ return _SignedInfinity [result_sign ]
2151
2151
else :
2152
2152
return _dec_from_triple (result_sign , '0' , 0 )
2153
2153
2154
2154
# 1**other = 1, but the choice of exponent and the flags
2155
2155
# depend on the exponent of self, and on whether other is a
2156
2156
# positive integer, a negative integer, or neither
2157
- if self == _Dec_p1 :
2157
+ if self == _One :
2158
2158
if other ._isinteger ():
2159
2159
# exp = max(self._exp*max(int(other), 0),
2160
2160
# 1-context.prec) but evaluating int(other) directly
@@ -2187,7 +2187,7 @@ def __pow__(self, other, modulo=None, context=None):
2187
2187
if (other ._sign == 0 ) == (self_adj < 0 ):
2188
2188
return _dec_from_triple (result_sign , '0' , 0 )
2189
2189
else :
2190
- return _Infsign [result_sign ]
2190
+ return _SignedInfinity [result_sign ]
2191
2191
2192
2192
# from here on, the result always goes through the call
2193
2193
# to _fix at the end of this function.
@@ -2707,9 +2707,9 @@ def compare_total(self, other):
2707
2707
"""
2708
2708
# if one is negative and the other is positive, it's easy
2709
2709
if self ._sign and not other ._sign :
2710
- return _Dec_n1
2710
+ return _NegativeOne
2711
2711
if not self ._sign and other ._sign :
2712
- return _Dec_p1
2712
+ return _One
2713
2713
sign = self ._sign
2714
2714
2715
2715
# let's handle both NaN types
@@ -2719,51 +2719,51 @@ def compare_total(self, other):
2719
2719
if self_nan == other_nan :
2720
2720
if self ._int < other ._int :
2721
2721
if sign :
2722
- return _Dec_p1
2722
+ return _One
2723
2723
else :
2724
- return _Dec_n1
2724
+ return _NegativeOne
2725
2725
if self ._int > other ._int :
2726
2726
if sign :
2727
- return _Dec_n1
2727
+ return _NegativeOne
2728
2728
else :
2729
- return _Dec_p1
2730
- return _Dec_0
2729
+ return _One
2730
+ return _Zero
2731
2731
2732
2732
if sign :
2733
2733
if self_nan == 1 :
2734
- return _Dec_n1
2734
+ return _NegativeOne
2735
2735
if other_nan == 1 :
2736
- return _Dec_p1
2736
+ return _One
2737
2737
if self_nan == 2 :
2738
- return _Dec_n1
2738
+ return _NegativeOne
2739
2739
if other_nan == 2 :
2740
- return _Dec_p1
2740
+ return _One
2741
2741
else :
2742
2742
if self_nan == 1 :
2743
- return _Dec_p1
2743
+ return _One
2744
2744
if other_nan == 1 :
2745
- return _Dec_n1
2745
+ return _NegativeOne
2746
2746
if self_nan == 2 :
2747
- return _Dec_p1
2747
+ return _One
2748
2748
if other_nan == 2 :
2749
- return _Dec_n1
2749
+ return _NegativeOne
2750
2750
2751
2751
if self < other :
2752
- return _Dec_n1
2752
+ return _NegativeOne
2753
2753
if self > other :
2754
- return _Dec_p1
2754
+ return _One
2755
2755
2756
2756
if self ._exp < other ._exp :
2757
2757
if sign :
2758
- return _Dec_p1
2758
+ return _One
2759
2759
else :
2760
- return _Dec_n1
2760
+ return _NegativeOne
2761
2761
if self ._exp > other ._exp :
2762
2762
if sign :
2763
- return _Dec_n1
2763
+ return _NegativeOne
2764
2764
else :
2765
- return _Dec_p1
2766
- return _Dec_0
2765
+ return _One
2766
+ return _Zero
2767
2767
2768
2768
2769
2769
def compare_total_mag (self , other ):
@@ -2804,11 +2804,11 @@ def exp(self, context=None):
2804
2804
2805
2805
# exp(-Infinity) = 0
2806
2806
if self ._isinfinity () == - 1 :
2807
- return _Dec_0
2807
+ return _Zero
2808
2808
2809
2809
# exp(0) = 1
2810
2810
if not self :
2811
- return _Dec_p1
2811
+ return _One
2812
2812
2813
2813
# exp(Infinity) = Infinity
2814
2814
if self ._isinfinity () == 1 :
@@ -2960,15 +2960,15 @@ def ln(self, context=None):
2960
2960
2961
2961
# ln(0.0) == -Infinity
2962
2962
if not self :
2963
- return _negInf
2963
+ return _NegativeInfinity
2964
2964
2965
2965
# ln(Infinity) = Infinity
2966
2966
if self ._isinfinity () == 1 :
2967
- return _Inf
2967
+ return _Infinity
2968
2968
2969
2969
# ln(1.0) == 0.0
2970
- if self == _Dec_p1 :
2971
- return _Dec_0
2970
+ if self == _One :
2971
+ return _Zero
2972
2972
2973
2973
# ln(negative) raises InvalidOperation
2974
2974
if self ._sign == 1 :
@@ -3040,11 +3040,11 @@ def log10(self, context=None):
3040
3040
3041
3041
# log10(0.0) == -Infinity
3042
3042
if not self :
3043
- return _negInf
3043
+ return _NegativeInfinity
3044
3044
3045
3045
# log10(Infinity) = Infinity
3046
3046
if self ._isinfinity () == 1 :
3047
- return _Inf
3047
+ return _Infinity
3048
3048
3049
3049
# log10(negative or -Infinity) raises InvalidOperation
3050
3050
if self ._sign == 1 :
@@ -3096,7 +3096,7 @@ def logb(self, context=None):
3096
3096
3097
3097
# logb(+/-Inf) = +Inf
3098
3098
if self ._isinfinity ():
3099
- return _Inf
3099
+ return _Infinity
3100
3100
3101
3101
# logb(0) = -Inf, DivisionByZero
3102
3102
if not self :
@@ -3253,7 +3253,7 @@ def next_minus(self, context=None):
3253
3253
return ans
3254
3254
3255
3255
if self ._isinfinity () == - 1 :
3256
- return _negInf
3256
+ return _NegativeInfinity
3257
3257
if self ._isinfinity () == 1 :
3258
3258
return _dec_from_triple (0 , '9' * context .prec , context .Etop ())
3259
3259
@@ -3276,7 +3276,7 @@ def next_plus(self, context=None):
3276
3276
return ans
3277
3277
3278
3278
if self ._isinfinity () == 1 :
3279
- return _Inf
3279
+ return _Infinity
3280
3280
if self ._isinfinity () == - 1 :
3281
3281
return _dec_from_triple (1 , '9' * context .prec , context .Etop ())
3282
3282
@@ -5540,15 +5540,15 @@ def _format_align(body, spec_dict):
5540
5540
##### Useful Constants (internal use only) ################################
5541
5541
5542
5542
# Reusable defaults
5543
- _Inf = Decimal ('Inf' )
5544
- _negInf = Decimal ('-Inf' )
5543
+ _Infinity = Decimal ('Inf' )
5544
+ _NegativeInfinity = Decimal ('-Inf' )
5545
5545
_NaN = Decimal ('NaN' )
5546
- _Dec_0 = Decimal (0 )
5547
- _Dec_p1 = Decimal (1 )
5548
- _Dec_n1 = Decimal (- 1 )
5546
+ _Zero = Decimal (0 )
5547
+ _One = Decimal (1 )
5548
+ _NegativeOne = Decimal (- 1 )
5549
5549
5550
- # _Infsign [sign] is infinity w/ that sign
5551
- _Infsign = (_Inf , _negInf )
5550
+ # _SignedInfinity [sign] is infinity w/ that sign
5551
+ _SignedInfinity = (_Infinity , _NegativeInfinity )
5552
5552
5553
5553
5554
5554
0 commit comments