[Python-checkins] python/nondist/sandbox/decimal Decimal.py,1.10,1.11

eprice@users.sourceforge.net eprice@users.sourceforge.net
Thu, 03 Jul 2003 20:11:44 -0700


Update of /cvsroot/python/python/nondist/sandbox/decimal
In directory sc8-pr-cvs1:/tmp/cvs-serv16079

Modified Files:
	Decimal.py 
Log Message:
Removed debugging output.




Index: Decimal.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/decimal/Decimal.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** Decimal.py	2 Jul 2003 23:48:22 -0000	1.10
--- Decimal.py	4 Jul 2003 03:11:42 -0000	1.11
***************
*** 489,501 ****
          2 if sNaN
          """
-         #print repr(self), repr(self._exp)
-         #print 'here', self._exp
          if self._exp == 'n':
-             #print 'Gone'
              return 1
          elif self._exp == 'N':
-             #print 'Gone'
              return 2
-         #print 'Gone'
          return 0
  
--- 489,496 ----
***************
*** 621,625 ****
          1  => a > b
          NaN => one is NaN
!         Returns Decimal instances, though.
          """
          if context is None:
--- 616,620 ----
          1  => a > b
          NaN => one is NaN
!         Like __cmp__, but returns Decimal instances.
          """
          if context is None:
***************
*** 627,681 ****
          if not isinstance(other, Decimal):
              other = Decimal(other)
-         #print repr(self), repr(other)
- 
          ans = self._check_nans(other, context)
          #compare(NaN, NaN) = NaN
-         #print 'Here'
          if ans:
-             #print 'Yay', self, other, ans
              return ans
-         #print self, other
- 
-         if not self and not other:
-             return Decimal(0) #If both 0, sign comparison isn't certain.
  
!         #If different signs, neg one is less
!         if other._sign < self._sign:
!             return Decimal(-1)
!         if self._sign < other._sign:
!             return Decimal(1)
! 
!         # INF = INF
!         if self._isinfinity() and other._isinfinity():
!             return Decimal(0)
!         if self._isinfinity():
!             return Decimal((-1)**self._sign)
!         if other._isinfinity():
!             return Decimal(-((-1)**other._sign))
! 
!         if self.adjusted() == other.adjusted() and \
!            self._int + (0,)*(self._exp - other._exp) == \
!            other._int + (0,)*(other._exp - self._exp):
!             return Decimal(0) #equal, except in precision. ([0]*(-x) = [])
!         elif self.adjusted() > other.adjusted() and self._int[0] != 0:
!             return Decimal((-1)**self._sign)
!         elif self.adjusted < other.adjusted() and other._int[0] != 0:
!             return Decimal(-((-1)**self._sign))
! 
!         context = copy.copy(context)
!         rounding = context.set_rounding(ROUND_UP) #round away from 0
! 
!         flags = context.ignore_all_flags()
!         res = self.__sub__(other, context=context)
! 
!         context.regard_flags(*flags)
! 
!         context.rounding = rounding
! 
!         if not res:
!             return Decimal(0)
!         elif res._sign:
!             return Decimal(-1)
!         return Decimal(1)
  
      def __hash__(self):
--- 622,631 ----
          if not isinstance(other, Decimal):
              other = Decimal(other)
          ans = self._check_nans(other, context)
          #compare(NaN, NaN) = NaN
          if ans:
              return ans
  
!         return Decimal(self.__cmp__(other, context))
  
      def __hash__(self):
***************
*** 1383,1389 ****
          if self._isnan():
              
-             print "mmoo"
-             raise "ACK"
-             #raise "AIIII"
              context = getcontext()
              return context.raise_error(InvalidContext)
--- 1333,1336 ----
***************
*** 1411,1416 ****
          Equivalent to int(long(self))
          """
-         #print 'M', repr(self), repr(self._exp)
-         print self._exp == 'n'
          return int(self.__long__())
  
--- 1358,1361 ----