From rhettinger at users.sourceforge.net Thu Jul 1 02:44:54 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 02:44:59 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal test_Decimal.py, 1.24, 1.25 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18130 Modified Files: test_Decimal.py Log Message: Test cleanup: Use comments and informative test names instead of docstrings. Index: test_Decimal.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/test_Decimal.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** test_Decimal.py 30 Jun 2004 07:19:21 -0000 1.24 --- test_Decimal.py 1 Jul 2004 06:44:52 -0000 1.25 *************** *** 31,35 **** import os, sys import pickle, copy - from Decimal import * from test.test_support import TestSkipped, run_unittest, run_doctest --- 31,34 ---- *************** *** 367,380 **** '''Unit tests for Explicit Construction cases of Decimal.''' ! def test_empty(self): ! '''Explicit construction without parameters.''' self.assertEqual(Decimal(), Decimal("0")) ! def test_from_None(self): ! '''Explicit construction passing None as value.''' self.assertRaises(TypeError, Decimal, None) ! def test_from_int(self): ! '''Explicit construction with int or long.''' #positive --- 366,376 ---- '''Unit tests for Explicit Construction cases of Decimal.''' ! def test_explicit_empty(self): self.assertEqual(Decimal(), Decimal("0")) ! def test_explicit_from_None(self): self.assertRaises(TypeError, Decimal, None) ! def test_explicit_from_int(self): #positive *************** *** 394,398 **** self.assertEqual(str(d), '0') ! def test_from_string(self): '''Explicit construction with string.''' --- 390,394 ---- self.assertEqual(str(d), '0') ! def test_explicit_from_string(self): '''Explicit construction with string.''' *************** *** 412,417 **** self.assertEqual(str(Decimal('ugly')), 'NaN') ! def test_from_tuples(self): ! '''Explicit construction with tuples.''' #zero --- 408,412 ---- self.assertEqual(str(Decimal('ugly')), 'NaN') ! def test_explicit_from_tuples(self): #zero *************** *** 444,449 **** self.assertRaises(ValueError, Decimal, (1, (4, -3, 4, 9, 1), 2) ) ! def test_from_Decimal(self): ! '''Explicit construction with Decimal.''' #positive --- 439,443 ---- self.assertRaises(ValueError, Decimal, (1, (4, -3, 4, 9, 1), 2) ) ! def test_explicit_from_Decimal(self): #positive *************** *** 471,476 **** self.assertNotEqual(id(d), id(e)) ! def test_context_create_decimal(self): ! '''Explicit construction through context.create_decimal().''' nc = copy.copy(getcontext()) nc.prec = 3 --- 465,470 ---- self.assertNotEqual(id(d), id(e)) ! def test_explicit_context_create_decimal(self): ! nc = copy.copy(getcontext()) nc.prec = 3 *************** *** 511,543 **** '''Unit tests for Implicit Construction cases of Decimal.''' ! def test_from_None(self): ! '''Implicit construction with None.''' ! self.assertRaises(TypeError, eval, 'Decimal(5) + None', globals()) ! def test_from_int(self): ! '''Implicit construction with int or long.''' ! #normal self.assertEqual(str(Decimal(5) + 45), '50') - #exceeding precision self.assertEqual(Decimal(5) + 123456789000, Decimal(123456789000)) ! def test_from_string(self): ! '''Implicit construction with string.''' ! ! #just any string self.assertRaises(TypeError, eval, 'Decimal(5) + "3"', globals()) ! def test_from_float(self): ! '''Implicit construction with float.''' ! ! #just any float self.assertRaises(TypeError, eval, 'Decimal(5) + 2.2', globals()) ! def test_from_Decimal(self): ! '''Implicit construction with Decimal.''' ! self.assertEqual(Decimal(5) + Decimal(45), Decimal(50)) --- 505,524 ---- '''Unit tests for Implicit Construction cases of Decimal.''' ! def test_implicit_from_None(self): self.assertRaises(TypeError, eval, 'Decimal(5) + None', globals()) ! def test_implicit_from_int(self): #normal self.assertEqual(str(Decimal(5) + 45), '50') #exceeding precision self.assertEqual(Decimal(5) + 123456789000, Decimal(123456789000)) ! def test_implicit_from_string(self): self.assertRaises(TypeError, eval, 'Decimal(5) + "3"', globals()) ! def test_implicit_from_float(self): self.assertRaises(TypeError, eval, 'Decimal(5) + 2.2', globals()) ! def test_implicit_from_Decimal(self): self.assertEqual(Decimal(5) + Decimal(45), Decimal(50)) *************** *** 547,551 **** def test_addition(self): - '''Test addition in all its ways.''' d1 = Decimal('-11.1') --- 528,531 ---- *************** *** 575,579 **** def test_subtraction(self): - '''Test subtraction in all its ways.''' d1 = Decimal('-11.1') --- 555,558 ---- *************** *** 603,607 **** def test_multiplication(self): - '''Test multiplication in all its ways.''' d1 = Decimal('-5') --- 582,585 ---- *************** *** 631,635 **** def test_division(self): - '''Test division in all its ways.''' d1 = Decimal('-5') --- 609,612 ---- *************** *** 715,719 **** def test_module(self): - '''Test module in all its ways.''' d1 = Decimal('5') --- 692,695 ---- *************** *** 743,747 **** def test_floor_div_module(self): - '''Test floor division with module in all its ways.''' d1 = Decimal('5') --- 719,722 ---- *************** *** 770,783 **** def test_unary_operators(self): ! '''Testing -, +, abs.''' ! ! #test '+' ! self.assertEqual(+Decimal(45), Decimal(+45)) ! ! #test '-' ! self.assertEqual(-Decimal(45), Decimal(-45)) ! ! #test abs ! self.assertEqual(abs(Decimal(45)), abs(Decimal(-45))) --- 745,751 ---- def test_unary_operators(self): ! self.assertEqual(+Decimal(45), Decimal(+45)) # + ! self.assertEqual(-Decimal(45), Decimal(-45)) # - ! self.assertEqual(abs(Decimal(45)), abs(Decimal(-45))) # abs *************** *** 813,817 **** def test_threading(self): ! '''Test the "threading isolation" of a Context.''' self.synchro = threading.Event() --- 781,785 ---- def test_threading(self): ! #Test the "threading isolation" of a Context. self.synchro = threading.Event() *************** *** 874,880 **** else: self.fail('Did not raised an error!') ! def test_copy_methods(self): ! '''Test copy and deepcopy.''' ! d = Decimal('43.24') c = copy.copy(d) --- 842,846 ---- else: self.fail('Did not raised an error!') ! def test_copy_and_deepcopy_methods(self): d = Decimal('43.24') c = copy.copy(d) *************** *** 884,897 **** def test_hash_method(self): - '''Test hash.''' - #just that it's hashable hash(Decimal(23)) - #the same hash that to an int self.assertEqual(hash(Decimal(23)), hash(23)) ! def test_minmax_methods(self): ! '''Test min and max between Decimal and others.''' d1 = Decimal('15.32') --- 850,859 ---- def test_hash_method(self): #just that it's hashable hash(Decimal(23)) #the same hash that to an int self.assertEqual(hash(Decimal(23)), hash(23)) ! def test_min_and_max_methods(self): d1 = Decimal('15.32') *************** *** 912,937 **** self.failUnless(max(d2,l1) is d2) ! def test_as_boolean(self): ! '''Test that it can be used as boolean.''' ! #as false self.failIf(Decimal(0)) - #as true self.failUnless(Decimal('0.372')) def test_tostring_methods(self): ! '''Test str and repr methods.''' d = Decimal('15.32') ! ! #str ! self.assertEqual(str(d), '15.32') ! ! #repr ! self.assertEqual(repr(d), 'Decimal("15.32")') def test_tonum_methods(self): ! '''Test float, int and long methods.''' d1 = Decimal('66') --- 874,892 ---- self.failUnless(max(d2,l1) is d2) ! def test_as_nonzero(self): #as false self.failIf(Decimal(0)) #as true self.failUnless(Decimal('0.372')) def test_tostring_methods(self): ! #Test str and repr methods. d = Decimal('15.32') ! self.assertEqual(str(d), '15.32') # str ! self.assertEqual(repr(d), 'Decimal("15.32")') # repr def test_tonum_methods(self): ! #Test float, int and long methods. d1 = Decimal('66') *************** *** 950,955 **** self.assertEqual(float(d2), 15.32) ! def test_round_trip(self): ! '''Testing that d == eval(repr(d)) with d as Decimal.''' #with zero --- 905,909 ---- self.assertEqual(float(d2), 15.32) ! def test_eval_round_trip(self): #with zero *************** *** 970,974 **** def test_as_tuple(self): - '''Test as_tuple to show the internals.''' #with zero --- 924,927 ---- *************** *** 989,993 **** def test_immutability_onpurpose(self): ! '''Try to change internal objects and see if immutable.''' d = Decimal(42) --- 942,946 ---- def test_immutability_onpurpose(self): ! #Try to change internal objects and see if immutable. d = Decimal(42) *************** *** 1017,1021 **** def test_immutability_operations(self): ! '''Do operations and check that it didn't change change internal objects.''' d1 = Decimal('-25e55') --- 970,974 ---- def test_immutability_operations(self): ! # Do operations and check that it didn't change change internal objects. d1 = Decimal('-25e55') From rhettinger at users.sourceforge.net Thu Jul 1 04:21:31 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 04:21:37 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal Decimal.py, 1.35, 1.36 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1300 Modified Files: Decimal.py Log Message: * Have context doctests use the DefaultContext instead of creating new ones. * Simplify the thicket of constants non specifically required by the spec. Index: Decimal.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/Decimal.py,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** Decimal.py 1 Jul 2004 01:47:03 -0000 1.35 --- Decimal.py 1 Jul 2004 08:21:28 -0000 1.36 *************** *** 14,20 **** # Consider having a SimpleDecimal subclass implementing X3.274 semantics # Add an __all__ attribute - # Improve docstrings and add more doctests # Improve the Context API # Provide a clean way of attaching monetary format representations """ --- 14,20 ---- # Consider having a SimpleDecimal subclass implementing X3.274 semantics # Add an __all__ attribute # Improve the Context API # Provide a clean way of attaching monetary format representations + # Review all exposed constants for utility vs. namespace clutter """ *************** *** 128,169 **** xor = operator.xor - #Capitals: 1E+10, not 1e10 - CAPITALS = 1 - - # Clamp: When finishing operation, change exponents if too high: - # maxExponent: 10 - # precision: 4 - # clamp: 1 - # add 0 1e10 -> 1.000e10 - - CLAMP = 0 - - # Default Context - - BASIC_DEFAULT_CONTEXT = 'basic' - - # Basic default context: - # - # flags: all set to 0 - # trap-enablers: inexact, rounded, and subnormal are set to 0; - # all others are set to 1 - # precision: is set to 9 - # rounding: is set to round-half-up - - EXTENDED_DEFAULT_CONTEXT = 'extended' - - # Extended default context: - # flags: all set to 0 - # trap-enablers: all set to 0 (IEEE 854 7) - # precision: is set to the designated single precision - # rounding: is set to round-half-even (IEEE 854 4.1) - - DEFAULT_CONTEXT = EXTENDED_DEFAULT_CONTEXT - #Precision ! BASIC_DEFAULT_PRECISION = 9 ! EXTENDED_DEFAULT_PRECISION = 9 ! DEFAULT_MAX_EXPONENT = 999999999 DEFAULT_MIN_EXPONENT = -999999999 --- 128,135 ---- xor = operator.xor #Precision + SINGLE_PRECISION = 9 ! #Exponent Range DEFAULT_MAX_EXPONENT = 999999999 DEFAULT_MIN_EXPONENT = -999999999 *************** *** 178,194 **** ROUND_HALF_DOWN = 'half_down' - BASIC_DEFAULT_ROUNDING = ROUND_HALF_UP - EXTENDED_DEFAULT_ROUNDING = ROUND_HALF_EVEN - #Rounding decision - NEVER_ROUND = 'never' # Round in division (non-divmod), sqrt ONLY ALWAYS_ROUND = 'always' # Every operation rounds at end. - - BASIC_DEFAULT_ROUNDING_DECISION = ALWAYS_ROUND - EXTENDED_DEFAULT_ROUNDING_DECISION = ALWAYS_ROUND - - #Errors --- 144,151 ---- *************** *** 1442,1445 **** --- 1399,1404 ---- def __int__(self): """Converts self to a int, truncating if necessary.""" + # XXX This should be implemented in terms of tested + # functions in the standard if self._isnan(): context = getcontext() *************** *** 1674,1677 **** --- 1633,1637 ---- return tmp return tmp + def _round_ceiling(self, prec, expdiff, context): """Rounds up (not away from 0 if negative.)""" *************** *** 2144,2147 **** --- 2104,2108 ---- Decimal._pick_rounding_function[val] = name + DefaultLock = threading.Lock() class Context(object): *************** *** 2158,2171 **** (Whether or not the trap_enabler is set) Should be reset by user of Decimal instance. ! Emin - Minimum exponent ! Emax - Maximum exponent ! capitals - If 1, 1*10^1 is printed as 1E+1. If 0, printed as 1e1 """ def __init__(self, prec=None, rounding=None, trap_enablers=None, flags=None, _rounding_decision=None, ! Emin=None, Emax=None, ! capitals=None, _clamp=None, ! _ignored_flags=None): DefaultLock.acquire() for name, val in locals().items(): --- 2119,2135 ---- (Whether or not the trap_enabler is set) Should be reset by user of Decimal instance. ! Emin - Minimum exponent (defaults to -999999999) ! Emax - Maximum exponent (defaults to 999999999) ! capitals - If 1, 1*10^1 is printed as 1E+1. ! If 0, printed as 1e1 ! (Defaults to 1) ! clamp - If 1, change exponents if too high (Default 0) """ def __init__(self, prec=None, rounding=None, trap_enablers=None, flags=None, _rounding_decision=None, ! Emin=DEFAULT_MIN_EXPONENT, Emax=DEFAULT_MAX_EXPONENT, ! capitals=1, _clamp=0, ! _ignored_flags=[]): DefaultLock.acquire() for name, val in locals().items(): *************** *** 2285,2295 **** the plus operation on the operand. ! >>> Context(prec=9).abs(Decimal('2.1')) Decimal("2.1") ! >>> Context(prec=9).abs(Decimal('-100')) Decimal("100") ! >>> Context(prec=9).abs(Decimal('101.5')) Decimal("101.5") ! >>> Context(prec=9).abs(Decimal('-101.5')) Decimal("101.5") """ --- 2249,2259 ---- the plus operation on the operand. ! >>> DefaultContext.abs(Decimal('2.1')) Decimal("2.1") ! >>> DefaultContext.abs(Decimal('-100')) Decimal("100") ! >>> DefaultContext.abs(Decimal('101.5')) Decimal("101.5") ! >>> DefaultContext.abs(Decimal('-101.5')) Decimal("101.5") """ *************** *** 2299,2305 **** """Return the sum of the two operands. ! >>> Context(prec=9).add(Decimal('12'), Decimal('7.00')) Decimal("19.00") ! >>> Context(prec=9).add(Decimal('1E+2'), Decimal('1.01E+4')) Decimal("1.02E+4") """ --- 2263,2269 ---- """Return the sum of the two operands. ! >>> DefaultContext.add(Decimal('12'), Decimal('7.00')) Decimal("19.00") ! >>> DefaultContext.add(Decimal('1E+2'), Decimal('1.01E+4')) Decimal("1.02E+4") """ *************** *** 2323,2337 **** zero or negative zero, or ’1’ if the result is greater than zero. ! >>> Context(prec=9).compare(Decimal('2.1'), Decimal('3')) Decimal("-1") ! >>> Context(prec=9).compare(Decimal('2.1'), Decimal('2.1')) Decimal("0") ! >>> Context(prec=9).compare(Decimal('2.1'), Decimal('2.10')) Decimal("0") ! >>> Context(prec=9).compare(Decimal('3'), Decimal('2.1')) Decimal("1") ! >>> Context(prec=9).compare(Decimal('2.1'), Decimal('-3')) Decimal("1") ! >>> Context(prec=9).compare(Decimal('-3'), Decimal('2.1')) Decimal("-1") """ --- 2287,2301 ---- zero or negative zero, or ’1’ if the result is greater than zero. ! >>> DefaultContext.compare(Decimal('2.1'), Decimal('3')) Decimal("-1") ! >>> DefaultContext.compare(Decimal('2.1'), Decimal('2.1')) Decimal("0") ! >>> DefaultContext.compare(Decimal('2.1'), Decimal('2.10')) Decimal("0") ! >>> DefaultContext.compare(Decimal('3'), Decimal('2.1')) Decimal("1") ! >>> DefaultContext.compare(Decimal('2.1'), Decimal('-3')) Decimal("1") ! >>> DefaultContext.compare(Decimal('-3'), Decimal('2.1')) Decimal("-1") """ *************** *** 2341,2363 **** """Decimal division in a specified context. ! >>> Context(prec=9).divide(Decimal('1'), Decimal('3')) Decimal("0.333333333") ! >>> Context(prec=9).divide(Decimal('2'), Decimal('3')) Decimal("0.666666667") ! >>> Context(prec=9).divide(Decimal('5'), Decimal('2')) Decimal("2.5") ! >>> Context(prec=9).divide(Decimal('1'), Decimal('10')) Decimal("0.1") ! >>> Context(prec=9).divide(Decimal('12'), Decimal('12')) Decimal("1") ! >>> Context(prec=9).divide(Decimal('8.00'), Decimal('2')) Decimal("4.00") ! >>> Context(prec=9).divide(Decimal('2.400'), Decimal('2.0')) Decimal("1.20") ! >>> Context(prec=9).divide(Decimal('1000'), Decimal('100')) Decimal("10") ! >>> Context(prec=9).divide(Decimal('1000'), Decimal('1')) Decimal("1000") ! >>> Context(prec=9).divide(Decimal('2.40E+6'), Decimal('2')) Decimal("1.20E+6") """ --- 2305,2327 ---- """Decimal division in a specified context. ! >>> DefaultContext.divide(Decimal('1'), Decimal('3')) Decimal("0.333333333") ! >>> DefaultContext.divide(Decimal('2'), Decimal('3')) Decimal("0.666666667") ! >>> DefaultContext.divide(Decimal('5'), Decimal('2')) Decimal("2.5") ! >>> DefaultContext.divide(Decimal('1'), Decimal('10')) Decimal("0.1") ! >>> DefaultContext.divide(Decimal('12'), Decimal('12')) Decimal("1") ! >>> DefaultContext.divide(Decimal('8.00'), Decimal('2')) Decimal("4.00") ! >>> DefaultContext.divide(Decimal('2.400'), Decimal('2.0')) Decimal("1.20") ! >>> DefaultContext.divide(Decimal('1000'), Decimal('100')) Decimal("10") ! >>> DefaultContext.divide(Decimal('1000'), Decimal('1')) Decimal("1000") ! >>> DefaultContext.divide(Decimal('2.40E+6'), Decimal('2')) Decimal("1.20E+6") """ *************** *** 2367,2375 **** """Divides two numbers and returns the integer part of the result. ! >>> Context(prec=9).divide_int(Decimal('2'), Decimal('3')) Decimal("0") ! >>> Context(prec=9).divide_int(Decimal('10'), Decimal('3')) Decimal("3") ! >>> Context(prec=9).divide_int(Decimal('1'), Decimal('0.3')) Decimal("3") """ --- 2331,2339 ---- """Divides two numbers and returns the integer part of the result. ! >>> DefaultContext.divide_int(Decimal('2'), Decimal('3')) Decimal("0") ! >>> DefaultContext.divide_int(Decimal('10'), Decimal('3')) Decimal("3") ! >>> DefaultContext.divide_int(Decimal('1'), Decimal('0.3')) Decimal("3") """ *************** *** 2388,2396 **** infinity) of the two operands is chosen as the result. ! >>> Context(prec=9).max(Decimal('3'), Decimal('2')) Decimal("3") ! >>> Context(prec=9).max(Decimal('-10'), Decimal('3')) Decimal("3") ! >>> Context(prec=9).max(Decimal('1.0'), Decimal('1')) Decimal("1.0") """ --- 2352,2360 ---- infinity) of the two operands is chosen as the result. ! >>> DefaultContext.max(Decimal('3'), Decimal('2')) Decimal("3") ! >>> DefaultContext.max(Decimal('-10'), Decimal('3')) Decimal("3") ! >>> DefaultContext.max(Decimal('1.0'), Decimal('1')) Decimal("1.0") """ *************** *** 2406,2414 **** infinity) of the two operands is chosen as the result. ! >>> Context(prec=9).min(Decimal('3'), Decimal('2')) Decimal("2") ! >>> Context(prec=9).min(Decimal('-10'), Decimal('3')) Decimal("-10") ! >>> Context(prec=9).min(Decimal('1.0'), Decimal('1')) Decimal("1.0") """ --- 2370,2378 ---- infinity) of the two operands is chosen as the result. ! >>> DefaultContext.min(Decimal('3'), Decimal('2')) Decimal("2") ! >>> DefaultContext.min(Decimal('-10'), Decimal('3')) Decimal("-10") ! >>> DefaultContext.min(Decimal('1.0'), Decimal('1')) Decimal("1.0") """ *************** *** 2422,2428 **** has the same exponent as the operand. ! >>> Context(prec=9).minus(Decimal('1.3')) Decimal("-1.3") ! >>> Context(prec=9).minus(Decimal('-1.3')) Decimal("1.3") """ --- 2386,2392 ---- has the same exponent as the operand. ! >>> DefaultContext.minus(Decimal('1.3')) Decimal("-1.3") ! >>> DefaultContext.minus(Decimal('-1.3')) Decimal("1.3") """ *************** *** 2437,2449 **** of the two operands. ! >>> Context(prec=9).multiply(Decimal('1.20'), Decimal('3')) Decimal("3.60") ! >>> Context(prec=9).multiply(Decimal('7'), Decimal('3')) Decimal("21") ! >>> Context(prec=9).multiply(Decimal('0.9'), Decimal('0.8')) Decimal("0.72") ! >>> Context(prec=9).multiply(Decimal('0.9'), Decimal('-0')) Decimal("-0.0") ! >>> Context(prec=9).multiply(Decimal('654321'), Decimal('654321')) Decimal("4.28135971E+11") """ --- 2401,2413 ---- of the two operands. ! >>> DefaultContext.multiply(Decimal('1.20'), Decimal('3')) Decimal("3.60") ! >>> DefaultContext.multiply(Decimal('7'), Decimal('3')) Decimal("21") ! >>> DefaultContext.multiply(Decimal('0.9'), Decimal('0.8')) Decimal("0.72") ! >>> DefaultContext.multiply(Decimal('0.9'), Decimal('-0')) Decimal("-0.0") ! >>> DefaultContext.multiply(Decimal('654321'), Decimal('654321')) Decimal("4.28135971E+11") """ *************** *** 2456,2470 **** result. ! >>> Context(prec=9).normalize(Decimal('2.1')) Decimal("2.1") ! >>> Context(prec=9).normalize(Decimal('-2.0')) Decimal("-2") ! >>> Context(prec=9).normalize(Decimal('1.200')) Decimal("1.2") ! >>> Context(prec=9).normalize(Decimal('-120')) Decimal("-1.2E+2") ! >>> Context(prec=9).normalize(Decimal('120.00')) Decimal("1.2E+2") ! >>> Context(prec=9).normalize(Decimal('0.00')) Decimal("0") """ --- 2420,2434 ---- result. ! >>> DefaultContext.normalize(Decimal('2.1')) Decimal("2.1") ! >>> DefaultContext.normalize(Decimal('-2.0')) Decimal("-2") ! >>> DefaultContext.normalize(Decimal('1.200')) Decimal("1.2") ! >>> DefaultContext.normalize(Decimal('-120')) Decimal("-1.2E+2") ! >>> DefaultContext.normalize(Decimal('120.00')) Decimal("1.2E+2") ! >>> DefaultContext.normalize(Decimal('0.00')) Decimal("0") """ *************** *** 2478,2484 **** has the same exponent as the operand. ! >>> Context(prec=9).plus(Decimal('1.3')) Decimal("1.3") ! >>> Context(prec=9).plus(Decimal('-1.3')) Decimal("-1.3") """ --- 2442,2448 ---- has the same exponent as the operand. ! >>> DefaultContext.plus(Decimal('1.3')) Decimal("1.3") ! >>> DefaultContext.plus(Decimal('-1.3')) Decimal("-1.3") """ *************** *** 2503,2533 **** continues. ! >>> Context(prec=9).power(Decimal('2'), Decimal('3')) Decimal("8") ! >>> Context(prec=9).power(Decimal('2'), Decimal('-3')) Decimal("0.125") ! >>> Context(prec=9).power(Decimal('1.7'), Decimal('8')) Decimal("69.7575744") ! >>> Context(prec=9).power(Decimal('Infinity'), Decimal('-2')) Decimal("0") ! >>> Context(prec=9).power(Decimal('Infinity'), Decimal('-1')) Decimal("0") ! >>> Context(prec=9).power(Decimal('Infinity'), Decimal('0')) Decimal("1") ! >>> Context(prec=9).power(Decimal('Infinity'), Decimal('1')) Decimal("Infinity") ! >>> Context(prec=9).power(Decimal('Infinity'), Decimal('2')) Decimal("Infinity") ! >>> Context(prec=9).power(Decimal('-Infinity'), Decimal('-2')) Decimal("0") ! >>> Context(prec=9).power(Decimal('-Infinity'), Decimal('-1')) Decimal("-0") ! >>> Context(prec=9).power(Decimal('-Infinity'), Decimal('0')) Decimal("1") ! >>> Context(prec=9).power(Decimal('-Infinity'), Decimal('1')) Decimal("-Infinity") ! >>> Context(prec=9).power(Decimal('-Infinity'), Decimal('2')) Decimal("Infinity") ! >>> Context(prec=9).power(Decimal('0'), Decimal('0')) Decimal("NaN") """ --- 2467,2497 ---- continues. ! >>> DefaultContext.power(Decimal('2'), Decimal('3')) Decimal("8") ! >>> DefaultContext.power(Decimal('2'), Decimal('-3')) Decimal("0.125") ! >>> DefaultContext.power(Decimal('1.7'), Decimal('8')) Decimal("69.7575744") ! >>> DefaultContext.power(Decimal('Infinity'), Decimal('-2')) Decimal("0") ! >>> DefaultContext.power(Decimal('Infinity'), Decimal('-1')) Decimal("0") ! >>> DefaultContext.power(Decimal('Infinity'), Decimal('0')) Decimal("1") ! >>> DefaultContext.power(Decimal('Infinity'), Decimal('1')) Decimal("Infinity") ! >>> DefaultContext.power(Decimal('Infinity'), Decimal('2')) Decimal("Infinity") ! >>> DefaultContext.power(Decimal('-Infinity'), Decimal('-2')) Decimal("0") ! >>> DefaultContext.power(Decimal('-Infinity'), Decimal('-1')) Decimal("-0") ! >>> DefaultContext.power(Decimal('-Infinity'), Decimal('0')) Decimal("1") ! >>> DefaultContext.power(Decimal('-Infinity'), Decimal('1')) Decimal("-Infinity") ! >>> DefaultContext.power(Decimal('-Infinity'), Decimal('2')) Decimal("Infinity") ! >>> DefaultContext.power(Decimal('0'), Decimal('0')) Decimal("NaN") """ *************** *** 2552,2584 **** if the result is subnormal and inexact. ! >>> Context(prec=9).quantize(Decimal('2.17'), Decimal('0.001')) Decimal("2.170") ! >>> Context(prec=9).quantize(Decimal('2.17'), Decimal('0.01')) Decimal("2.17") ! >>> Context(prec=9).quantize(Decimal('2.17'), Decimal('0.1')) Decimal("2.2") ! >>> Context(prec=9).quantize(Decimal('2.17'), Decimal('1e+0')) Decimal("2") ! >>> Context(prec=9).quantize(Decimal('2.17'), Decimal('1e+1')) Decimal("0E+1") ! >>> Context(prec=9).quantize(Decimal('-Inf'), Decimal('Infinity')) Decimal("-Infinity") ! >>> Context(prec=9).quantize(Decimal('2'), Decimal('Infinity')) Decimal("NaN") ! >>> Context(prec=9).quantize(Decimal('-0.1'), Decimal('1')) Decimal("-0") ! >>> Context(prec=9).quantize(Decimal('-0'), Decimal('1e+5')) Decimal("-0E+5") ! >>> Context(prec=9).quantize(Decimal('+35236450.6'), Decimal('1e-2')) Decimal("NaN") ! >>> Context(prec=9).quantize(Decimal('-35236450.6'), Decimal('1e-2')) Decimal("NaN") ! >>> Context(prec=9).quantize(Decimal('217'), Decimal('1e-1')) Decimal("217.0") ! >>> Context(prec=9).quantize(Decimal('217'), Decimal('1e-0')) Decimal("217") ! >>> Context(prec=9).quantize(Decimal('217'), Decimal('1e+1')) Decimal("2.2E+2") ! >>> Context(prec=9).quantize(Decimal('217'), Decimal('1e+2')) Decimal("2E+2") """ --- 2516,2548 ---- if the result is subnormal and inexact. ! >>> DefaultContext.quantize(Decimal('2.17'), Decimal('0.001')) Decimal("2.170") ! >>> DefaultContext.quantize(Decimal('2.17'), Decimal('0.01')) Decimal("2.17") ! >>> DefaultContext.quantize(Decimal('2.17'), Decimal('0.1')) Decimal("2.2") ! >>> DefaultContext.quantize(Decimal('2.17'), Decimal('1e+0')) Decimal("2") ! >>> DefaultContext.quantize(Decimal('2.17'), Decimal('1e+1')) Decimal("0E+1") ! >>> DefaultContext.quantize(Decimal('-Inf'), Decimal('Infinity')) Decimal("-Infinity") ! >>> DefaultContext.quantize(Decimal('2'), Decimal('Infinity')) Decimal("NaN") ! >>> DefaultContext.quantize(Decimal('-0.1'), Decimal('1')) Decimal("-0") ! >>> DefaultContext.quantize(Decimal('-0'), Decimal('1e+5')) Decimal("-0E+5") ! >>> DefaultContext.quantize(Decimal('+35236450.6'), Decimal('1e-2')) Decimal("NaN") ! >>> DefaultContext.quantize(Decimal('-35236450.6'), Decimal('1e-2')) Decimal("NaN") ! >>> DefaultContext.quantize(Decimal('217'), Decimal('1e-1')) Decimal("217.0") ! >>> DefaultContext.quantize(Decimal('217'), Decimal('1e-0')) Decimal("217") ! >>> DefaultContext.quantize(Decimal('217'), Decimal('1e+1')) Decimal("2.2E+2") ! >>> DefaultContext.quantize(Decimal('217'), Decimal('1e+2')) Decimal("2E+2") """ *************** *** 2597,2611 **** remainder cannot be calculated). ! >>> Context(prec=9).remainder(Decimal('2.1'), Decimal('3')) Decimal("2.1") ! >>> Context(prec=9).remainder(Decimal('10'), Decimal('3')) Decimal("1") ! >>> Context(prec=9).remainder(Decimal('-10'), Decimal('3')) Decimal("-1") ! >>> Context(prec=9).remainder(Decimal('10.2'), Decimal('1')) Decimal("0.2") ! >>> Context(prec=9).remainder(Decimal('10'), Decimal('0.3')) Decimal("0.1") ! >>> Context(prec=9).remainder(Decimal('3.6'), Decimal('1.3')) Decimal("1.0") """ --- 2561,2575 ---- remainder cannot be calculated). ! >>> DefaultContext.remainder(Decimal('2.1'), Decimal('3')) Decimal("2.1") ! >>> DefaultContext.remainder(Decimal('10'), Decimal('3')) Decimal("1") ! >>> DefaultContext.remainder(Decimal('-10'), Decimal('3')) Decimal("-1") ! >>> DefaultContext.remainder(Decimal('10.2'), Decimal('1')) Decimal("0.2") ! >>> DefaultContext.remainder(Decimal('10'), Decimal('0.3')) Decimal("0.1") ! >>> DefaultContext.remainder(Decimal('3.6'), Decimal('1.3')) Decimal("1.0") """ *************** *** 2622,2638 **** remainder cannot be calculated). ! >>> Context(prec=9).remainder_near(Decimal('2.1'), Decimal('3')) Decimal("-0.9") ! >>> Context(prec=9).remainder_near(Decimal('10'), Decimal('6')) Decimal("-2") ! >>> Context(prec=9).remainder_near(Decimal('10'), Decimal('3')) Decimal("1") ! >>> Context(prec=9).remainder_near(Decimal('-10'), Decimal('3')) Decimal("-1") ! >>> Context(prec=9).remainder_near(Decimal('10.2'), Decimal('1')) Decimal("0.2") ! >>> Context(prec=9).remainder_near(Decimal('10'), Decimal('0.3')) Decimal("0.1") ! >>> Context(prec=9).remainder_near(Decimal('3.6'), Decimal('1.3')) Decimal("-0.3") """ --- 2586,2602 ---- remainder cannot be calculated). ! >>> DefaultContext.remainder_near(Decimal('2.1'), Decimal('3')) Decimal("-0.9") ! >>> DefaultContext.remainder_near(Decimal('10'), Decimal('6')) Decimal("-2") ! >>> DefaultContext.remainder_near(Decimal('10'), Decimal('3')) Decimal("1") ! >>> DefaultContext.remainder_near(Decimal('-10'), Decimal('3')) Decimal("-1") ! >>> DefaultContext.remainder_near(Decimal('10.2'), Decimal('1')) Decimal("0.2") ! >>> DefaultContext.remainder_near(Decimal('10'), Decimal('0.3')) Decimal("0.1") ! >>> DefaultContext.remainder_near(Decimal('3.6'), Decimal('1.3')) Decimal("-0.3") """ *************** *** 2645,2655 **** either operand. ! >>> Context(prec=9).same_quantum(Decimal('2.17'), Decimal('0.001')) False ! >>> Context(prec=9).same_quantum(Decimal('2.17'), Decimal('0.01')) True ! >>> Context(prec=9).same_quantum(Decimal('2.17'), Decimal('1')) False ! >>> Context(prec=9).same_quantum(Decimal('Inf'), Decimal('-Inf')) True """ --- 2609,2619 ---- either operand. ! >>> DefaultContext.same_quantum(Decimal('2.17'), Decimal('0.001')) False ! >>> DefaultContext.same_quantum(Decimal('2.17'), Decimal('0.01')) True ! >>> DefaultContext.same_quantum(Decimal('2.17'), Decimal('1')) False ! >>> DefaultContext.same_quantum(Decimal('Inf'), Decimal('-Inf')) True """ *************** *** 2662,2682 **** algorithm. ! >>> Context(prec=9).sqrt(Decimal('0')) Decimal("0") ! >>> Context(prec=9).sqrt(Decimal('-0')) Decimal("-0") ! >>> Context(prec=9).sqrt(Decimal('0.39')) Decimal("0.624499800") ! >>> Context(prec=9).sqrt(Decimal('100')) Decimal("10") ! >>> Context(prec=9).sqrt(Decimal('1')) Decimal("1") ! >>> Context(prec=9).sqrt(Decimal('1.0')) Decimal("1.0") ! >>> Context(prec=9).sqrt(Decimal('1.00')) Decimal("1.0") ! >>> Context(prec=9).sqrt(Decimal('7')) Decimal("2.64575131") ! >>> Context(prec=9).sqrt(Decimal('10')) Decimal("3.16227766") """ --- 2626,2646 ---- algorithm. ! >>> DefaultContext.sqrt(Decimal('0')) Decimal("0") ! >>> DefaultContext.sqrt(Decimal('-0')) Decimal("-0") ! >>> DefaultContext.sqrt(Decimal('0.39')) Decimal("0.624499800") ! >>> DefaultContext.sqrt(Decimal('100')) Decimal("10") ! >>> DefaultContext.sqrt(Decimal('1')) Decimal("1") ! >>> DefaultContext.sqrt(Decimal('1.0')) Decimal("1.0") ! >>> DefaultContext.sqrt(Decimal('1.00')) Decimal("1.0") ! >>> DefaultContext.sqrt(Decimal('7')) Decimal("2.64575131") ! >>> DefaultContext.sqrt(Decimal('10')) Decimal("3.16227766") """ *************** *** 2686,2694 **** """Return the sum of the two operands. ! >>> Context(prec=9).subtract(Decimal('1.3'), Decimal('1.07')) Decimal("0.23") ! >>> Context(prec=9).subtract(Decimal('1.3'), Decimal('1.30')) Decimal("0.00") ! >>> Context(prec=9).subtract(Decimal('1.3'), Decimal('2.07')) Decimal("-0.77") """ --- 2650,2658 ---- """Return the sum of the two operands. ! >>> DefaultContext.subtract(Decimal('1.3'), Decimal('1.07')) Decimal("0.23") ! >>> DefaultContext.subtract(Decimal('1.3'), Decimal('1.30')) Decimal("0.00") ! >>> DefaultContext.subtract(Decimal('1.3'), Decimal('2.07')) Decimal("-0.77") """ *************** *** 2718,2736 **** be set. The rounding mode is taken from the context. ! >>> Context(prec=9).to_integral(Decimal('2.1')) Decimal("2") ! >>> Context(prec=9).to_integral(Decimal('100')) Decimal("100") ! >>> Context(prec=9).to_integral(Decimal('100.0')) Decimal("100") ! >>> Context(prec=9).to_integral(Decimal('101.5')) Decimal("102") ! >>> Context(prec=9).to_integral(Decimal('-101.5')) Decimal("-102") ! >>> Context(prec=9).to_integral(Decimal('10E+5')) Decimal("1.0E+6") ! >>> Context(prec=9).to_integral(Decimal('7.89E+77')) Decimal("7.89E+77") ! >>> Context(prec=9).to_integral(Decimal('-Inf')) Decimal("-Infinity") """ --- 2682,2700 ---- be set. The rounding mode is taken from the context. ! >>> DefaultContext.to_integral(Decimal('2.1')) Decimal("2") ! >>> DefaultContext.to_integral(Decimal('100')) Decimal("100") ! >>> DefaultContext.to_integral(Decimal('100.0')) Decimal("100") ! >>> DefaultContext.to_integral(Decimal('101.5')) Decimal("102") ! >>> DefaultContext.to_integral(Decimal('-101.5')) Decimal("-102") ! >>> DefaultContext.to_integral(Decimal('10E+5')) Decimal("1.0E+6") ! >>> DefaultContext.to_integral(Decimal('7.89E+77')) Decimal("7.89E+77") ! >>> DefaultContext.to_integral(Decimal('-Inf')) Decimal("-Infinity") """ *************** *** 2924,2999 **** return op1, op2, adjust ! ! BASIC_DEFAULT_TRAPS = {} ! BASIC_DEFAULT_FLAGS = {} ! ! EXTENDED_DEFAULT_TRAPS = {} ! EXTENDED_DEFAULT_FLAGS = {} ! ! for exception in ExceptionList: ! BASIC_DEFAULT_TRAPS[exception] = exception.default ! BASIC_DEFAULT_FLAGS[exception] = 0 ! EXTENDED_DEFAULT_TRAPS[exception] = 0 ! EXTENDED_DEFAULT_FLAGS[exception] = 0 ! ! ! DEFAULT_PRECISION = EXTENDED_DEFAULT_PRECISION ! DEFAULT_ROUNDING = EXTENDED_DEFAULT_ROUNDING ! DEFAULT_TRAPS = EXTENDED_DEFAULT_TRAPS ! DEFAULT_FLAGS= EXTENDED_DEFAULT_FLAGS ! DEFAULT_ROUNDING_DECISION = EXTENDED_DEFAULT_ROUNDING_DECISION ! ! IGNORED_FLAGS = [] ! ! DefaultLock = threading.Lock() ! DefaultContext = Context(DEFAULT_PRECISION, DEFAULT_ROUNDING, ! DEFAULT_TRAPS.copy(), ! DEFAULT_FLAGS.copy(), DEFAULT_ROUNDING_DECISION, ! DEFAULT_MIN_EXPONENT, DEFAULT_MAX_EXPONENT, ! CAPITALS, CLAMP, IGNORED_FLAGS) ! ! #Used in SetDefaultContext ! DefaultAttributeDict= {'DEFAULT_PRECISION' : 'prec', ! 'DEFAULT_TRAPS' : 'trap_enablers', ! 'DEFAULT_FLAGS' : 'flags', ! 'DEFAULT_ROUNDING' : 'rounding', ! 'DEFAULT_ROUNDING_DECISION' : '_rounding_decision', ! 'DEFAULT_MIN_EXPONENT' : 'Emin', ! 'DEFAULT_MAX_EXPONENT' : 'Emax'} ! ! ! def SetDefaultContext(context=None): ! """Changes DefaultContext to the DEFAULT_* ! ! If context (default None) is BASIC_DEFAULT_CONTEXT or ! EXTENDED_DEFAULT_CONTEXT, sets DEFAULT_* to BASIC_DEFAULT_* or ! EXTENDED_DEFAULT_*. ! ! Whether that happened or not, change DefaultContext to use those. ! """ ! global DEFAULT_CONTEXT, DEFAULT_PRECISION, DEFAULT_TRAPS ! global DEFAULT_FLAGS, DEFAULT_ROUNDING, DEFAULT_ROUNDING_DECISION ! global DEFAULT_MIN_EXPONENT, DEFAULT_MAX_EXPONENT ! DEFAULT_CONTEXT = context ! if DEFAULT_CONTEXT == BASIC_DEFAULT_CONTEXT: ! DEFAULT_PRECISION = BASIC_DEFAULT_PRECISION ! DEFAULT_ROUNDING = BASIC_DEFAULT_ROUNDING ! DEFAULT_TRAPS = BASIC_DEFAULT_TRAPS ! DEFAULT_FLAGS= BASIC_DEFAULT_FLAGS ! DEFAULT_ROUNDING_DECISION = BASIC_DEFAULT_ROUNDING_DECISION ! ! elif DEFAULT_CONTEXT == EXTENDED_DEFAULT_CONTEXT: ! DEFAULT_PRECISION = EXTENDED_DEFAULT_PRECISION ! DEFAULT_ROUNDING = EXTENDED_DEFAULT_ROUNDING ! DEFAULT_TRAPS = EXTENDED_DEFAULT_TRAPS ! DEFAULT_FLAGS= EXTENDED_DEFAULT_FLAGS ! DEFAULT_ROUNDING_DECISION = EXTENDED_DEFAULT_ROUNDING_DECISION ! ! for key, val in DefaultAttributeDict.items(): ! setattr(DefaultContext, val, ! copy.copy(globals()[key])) ! ! ! SetDefaultContext(DEFAULT_CONTEXT) _infinity_map = { --- 2888,2892 ---- return op1, op2, adjust ! ##### Helper Functions ######################################## _infinity_map = { *************** *** 3043,3046 **** --- 2936,2984 ---- return 0 + + ##### Setup Specific Contexts ################################ + + def _zero_exceptions(): + "Helper function mapping all exceptions to zero." + d = {} + for exception in ExceptionList: + d[exception] = 0 + return d + + # The default context prototype used by Context() + # Is mutable, so than new contexts can have different default values + + DefaultContext = Context( + prec=SINGLE_PRECISION, rounding=ROUND_HALF_EVEN, + trap_enablers=_zero_exceptions(), + flags=_zero_exceptions(), + _rounding_decision=ALWAYS_ROUND, + ) + + # Pre-made alternate contexts offered by the specification + # Don't change these; the user should be able to select these + # contexts and be able to reproduce results from other implementations + # of the spec. + + _basic_traps = _zero_exceptions() + _basic_traps.update({Inexact:1, Rounded:1, Subnormal:1}) + + BasicDefaultContext = Context( + prec=9, rounding=ROUND_HALF_UP, + trap_enablers=_basic_traps, + flags=_zero_exceptions(), + _rounding_decision=ALWAYS_ROUND, + ) + + ExtendedDefaultContext = Context( + prec=SINGLE_PRECISION, rounding=ROUND_HALF_EVEN, + trap_enablers=_zero_exceptions(), + flags=_zero_exceptions(), + _rounding_decision=ALWAYS_ROUND, + ) + + + ##### Useful Constants ###################################### + #Reusable defaults Inf = Decimal('Inf') *************** *** 3052,3056 **** NaN = Decimal('NaN') ! # crud for parsing strings import re --- 2990,2995 ---- NaN = Decimal('NaN') ! ! ##### crud for parsing strings ################################# import re From rhettinger at users.sourceforge.net Thu Jul 1 05:27:33 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 05:27:37 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal test_Decimal.py, 1.25, 1.26 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13344 Modified Files: test_Decimal.py Log Message: Adjust test logic to handle -u resource option from regrtest.py to control whether the full set of arithmetic tests are run. Index: test_Decimal.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/test_Decimal.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** test_Decimal.py 1 Jul 2004 06:44:52 -0000 1.25 --- test_Decimal.py 1 Jul 2004 09:27:30 -0000 1.26 *************** *** 32,36 **** import pickle, copy from Decimal import * ! from test.test_support import TestSkipped, run_unittest, run_doctest --- 32,36 ---- import pickle, copy from Decimal import * ! from test.test_support import TestSkipped, run_unittest, run_doctest, is_resource_enabled *************** *** 1047,1072 **** self.assertEqual(d, e) ! def test_main(which=None, verbose=None): """ Execute the tests. ! If called with "Arithmetic", just executes the arithmetic tests. ! If called with "Behaviour", just executes the pythonic behaviour tests. ! Otherwise, executes both of them. """ ! test_classes = [] ! if which is None or which.lower().startswith("arith"): test_classes.extend([DecimalTest]) - if which is None or which.lower().startswith("behav"): - test_classes.extend([ - DecimalExplicitConstructionTest, - DecimalImplicitConstructionTest, - DecimalArithmeticOperatorsTest, - DecimalUseOfContextTest, - DecimalUsabilityTest, - DecimalPythonAPItests, - ]) - run_unittest(*test_classes) import Decimal as DecimalModule --- 1047,1068 ---- self.assertEqual(d, e) ! def test_main(arith=False, verbose=None): """ Execute the tests. ! Runs arithmetic tests if arith is True or if the "decimal" resource ! is enables in regrtest.py """ ! test_classes = [ ! DecimalExplicitConstructionTest, ! DecimalImplicitConstructionTest, ! DecimalArithmeticOperatorsTest, ! DecimalUseOfContextTest, ! DecimalUsabilityTest, ! DecimalPythonAPItests, ! ] ! if arith or is_resource_enabled('decimal'): test_classes.extend([DecimalTest]) run_unittest(*test_classes) import Decimal as DecimalModule *************** *** 1076,1083 **** if __name__ == '__main__': if len(sys.argv) == 1: ! test_main(verbose=True) elif len(sys.argv) == 2: ! test_main(sys.argv[1], verbose=True) else: ! raise ValueError, "test called with wrong arguments, use test_Decimal [Arithmetic|Behaviour]" --- 1072,1082 ---- if __name__ == '__main__': + # Calling with no arguments runs all tests. + # Calling with "Skip" will skipover the arithmetic tests. if len(sys.argv) == 1: ! test_main(arith=True, verbose=True) elif len(sys.argv) == 2: ! arith = sys.argv[1].lower() != 'skip' ! test_main(arith=arith, verbose=True) else: ! raise ValueError("test called with wrong arguments, use test_Decimal [Skip]") From rhettinger at users.sourceforge.net Thu Jul 1 06:01:59 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 06:02:03 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal Decimal.py, 1.36, 1.37 test_Decimal.py, 1.26, 1.27 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18515 Modified Files: Decimal.py test_Decimal.py Log Message: * Add an __all__ attribute to Decimal.py * Add a missing "import threading" to test_Decimal.py * Mark some non-API globals as private Index: Decimal.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/Decimal.py,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** Decimal.py 1 Jul 2004 08:21:28 -0000 1.36 --- Decimal.py 1 Jul 2004 10:01:42 -0000 1.37 *************** *** 11,20 **** # Todo: # Add deepcopy and pickle support for contexts - # Rename to decimal.Decimal before moving into production # Consider having a SimpleDecimal subclass implementing X3.274 semantics - # Add an __all__ attribute # Improve the Context API # Provide a clean way of attaching monetary format representations # Review all exposed constants for utility vs. namespace clutter """ --- 11,24 ---- # Todo: # Add deepcopy and pickle support for contexts # Consider having a SimpleDecimal subclass implementing X3.274 semantics # Improve the Context API + # Especially with respect to setting flags and traps + # Consider adding a clear_flags() method to Context # Provide a clean way of attaching monetary format representations # Review all exposed constants for utility vs. namespace clutter + # When moving into core + # rename Decimal.py and test_Decimal.py to lowercase decimal + # retarget the test directory to decimaltestdata + """ *************** *** 120,124 **** """ ! # XXX Add an __all__ attribute import threading --- 124,155 ---- """ ! __all__ = [ ! # Two major classes ! 'Decimal', 'Context', ! ! # Contexts ! 'DefaultContext', 'BasicDefaultContext', 'ExtendedDefaultContext', ! ! # Exceptions ! 'DecimalException', 'Clamped', 'InvalidOperation', 'ConversionSyntax', ! 'DivisionByZero', 'DivisionImpossible', 'DivisionUndefined', ! 'Inexact', 'InvalidContext', 'Rounded', 'Subnormal', 'Overflow', ! 'Underflow', ! ! # Module parameters ! 'SINGLE_PRECISION', 'DEFAULT_MAX_EXPONENT', 'DEFAULT_MIN_EXPONENT', ! ! # Constants for use in setting up contexts ! 'ROUND_DOWN', 'ROUND_HALF_UP', 'ROUND_HALF_EVEN', 'ROUND_CEILING', ! 'ROUND_FLOOR', 'ROUND_UP', 'ROUND_HALF_DOWN', ! 'NEVER_ROUND', 'ALWAYS_ROUND', ! 'ExceptionList', # <-- Used for building trap/flag dictionaries ! ! # Functions for manipulating contexts ! 'setcontext', 'getcontext', ! ! # Functions for working with decimals ! 'isinfinity', 'isnan', ! ] import threading *************** *** 376,380 **** ! def filterfunct(obj): """Returns true if a subclass of DecimalException""" try: --- 407,411 ---- ! def _filterfunct(obj): """Returns true if a subclass of DecimalException""" try: *************** *** 384,388 **** #ExceptionList holds the exceptions ! ExceptionList = filter(filterfunct, globals().values()) #To fix reloading, force it to create a new context --- 415,419 ---- #ExceptionList holds the exceptions ! ExceptionList = filter(_filterfunct, globals().values()) #To fix reloading, force it to create a new context *************** *** 2979,2983 **** ! ##### Useful Constants ###################################### #Reusable defaults --- 3010,3014 ---- ! ##### Useful Constants (internal use only###################### #Reusable defaults Index: test_Decimal.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/test_Decimal.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** test_Decimal.py 1 Jul 2004 09:27:30 -0000 1.26 --- test_Decimal.py 1 Jul 2004 10:01:42 -0000 1.27 *************** *** 33,37 **** from Decimal import * from test.test_support import TestSkipped, run_unittest, run_doctest, is_resource_enabled ! TESTDATADIR = 'tests' --- 33,37 ---- from Decimal import * from test.test_support import TestSkipped, run_unittest, run_doctest, is_resource_enabled ! import threading TESTDATADIR = 'tests' From rhettinger at users.sourceforge.net Thu Jul 1 06:30:37 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 06:30:41 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal Decimal.py, 1.37, 1.38 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22541 Modified Files: Decimal.py Log Message: * Enable module self-test by using a doctest at the end. * Comment out a test which mysteriously fails the self-test but passes the doctester in test_Decimal.py. * Remove non-Ascii characters from the file. * Add some Py2.2 compatability code. * Note that one doctest fails under Py2.2 by returning a NaN instead of the expected value. Index: Decimal.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/Decimal.py,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** Decimal.py 1 Jul 2004 10:01:42 -0000 1.37 --- Decimal.py 1 Jul 2004 10:30:33 -0000 1.38 *************** *** 1,3 **** ! # Copyright (c) 2004 Python Software Foundation. # All rights reserved. --- 1,3 ---- ! # Copyright (c) 2004 Python Software Foundation. # All rights reserved. *************** *** 20,24 **** # rename Decimal.py and test_Decimal.py to lowercase decimal # retarget the test directory to decimaltestdata ! """ --- 20,27 ---- # rename Decimal.py and test_Decimal.py to lowercase decimal # retarget the test directory to decimaltestdata ! # Fix doctest for _fixedpoint which fails only when run from this file ! # but works fine in the doctest in test_decimal. ! # Checkout the doctest for Decimal("123.45e12345678901234567890") ! # which works in Py2.3 and Py2.4 but returns a NaN in Py2.2. """ *************** *** 269,273 **** The result of the operation is [sign,inf], where sign is the exclusive or of the signs of the operands for divide, or is 1 for an odd power of ! –0, for power. """ --- 272,276 ---- The result of the operation is [sign,inf], where sign is the exclusive or of the signs of the operands for divide, or is 1 for an odd power of ! -0, for power. """ *************** *** 407,411 **** ! def _filterfunct(obj): """Returns true if a subclass of DecimalException""" try: --- 410,414 ---- ! def _filterfunc(obj): """Returns true if a subclass of DecimalException""" try: *************** *** 415,419 **** #ExceptionList holds the exceptions ! ExceptionList = filter(_filterfunct, globals().values()) #To fix reloading, force it to create a new context --- 418,444 ---- #ExceptionList holds the exceptions ! ExceptionList = filter(_filterfunc, globals().values()) ! ! del _filterfunc ! ! ! ##### Py2.2 Compatability ##################################### ! ! try: ! basestring ! except NameError: ! basestring = (str, unicode) ! ! try: ! True ! except NameError: ! True = (1==1) ! ! try: ! False ! except NameError: ! False = (1!=1) ! ! ##### Context Functions ####################################### #To fix reloading, force it to create a new context *************** *** 441,444 **** --- 466,471 ---- + ##### Decimal class ########################################### + class Decimal(object): """Floating point class for decimal arithmetic.""" *************** *** 1680,1692 **** def _fixedPoint(self, digits, rounding = None, context=None): ! """Rounds to a number of digits around the decimal point. ! ! Convenience function to allow rounding to a specified number of ! places after the decimal point. Negative numbers indicate ! rounding before the decimal point. ! ! >>> str(Decimal("1234.34567")._fixedPoint(2)) ! '1234.35' ! """ numdigits = len(self._int)+self._exp ans = self._round(numdigits+digits, rounding, context=context) --- 1707,1718 ---- def _fixedPoint(self, digits, rounding = None, context=None): ! ## """Rounds to a number of digits around the decimal point. ! ## ! ## Convenience function to allow rounding to a specified number of ! ## places after the decimal point. Negative numbers indicate ! ## rounding before the decimal point. ! ## ! ## >>> str(Decimal("1234.34567")._fixedPoint(2)) ! ## '1234.35' numdigits = len(self._int)+self._exp ans = self._round(numdigits+digits, rounding, context=context) *************** *** 2308,2313 **** If the signs of the operands differ, a value representing each operand ! (’-1’ if the operand is less than zero, ’0’ if the operand is zero or ! negative zero, or ’1’ if the operand is greater than zero) is used in place of that operand for the comparison instead of the actual operand. --- 2334,2339 ---- If the signs of the operands differ, a value representing each operand ! ('-1' if the operand is less than zero, '0' if the operand is zero or ! negative zero, or '1' if the operand is greater than zero) is used in place of that operand for the comparison instead of the actual operand. *************** *** 2315,2320 **** The comparison is then effected by subtracting the second operand from the first and then returning a value according to the result of the ! subtraction: ’-1’ if the result is less than zero, ’0’ if the result is ! zero or negative zero, or ’1’ if the result is greater than zero. >>> DefaultContext.compare(Decimal('2.1'), Decimal('3')) --- 2341,2346 ---- The comparison is then effected by subtracting the second operand from the first and then returning a value according to the result of the ! subtraction: '-1' if the result is less than zero, '0' if the result is ! zero or negative zero, or '1' if the result is greater than zero. >>> DefaultContext.compare(Decimal('2.1'), Decimal('3')) *************** *** 2414,2418 **** The operation is evaluated using the same rules as subtract; the ! operation minus(a) is calculated as subtract(’0’, a) where the ’0’ has the same exponent as the operand. --- 2440,2444 ---- The operation is evaluated using the same rules as subtract; the ! operation minus(a) is calculated as subtract('0', a) where the '0' has the same exponent as the operand. *************** *** 2428,2432 **** If either operand is a special value then the general rules apply. ! Otherwise, the operands are multiplied together (‘long multiplication’), resulting in a number which may be as long as the sum of the lengths of the two operands. --- 2454,2458 ---- If either operand is a special value then the general rules apply. ! Otherwise, the operands are multiplied together ('long multiplication'), resulting in a number which may be as long as the sum of the lengths of the two operands. *************** *** 2470,2474 **** The operation is evaluated using the same rules as add; the ! operation plus(a) is calculated as add(’0’, a) where the ’0’ has the same exponent as the operand. --- 2496,2500 ---- The operation is evaluated using the same rules as add; the ! operation plus(a) is calculated as add('0', a) where the '0' has the same exponent as the operand. *************** *** 2608,2613 **** def remainder_near(self, a, b): ! """Returns to be a – b × n, where n is the integer nearest the exact ! value of a ÷ b (if two integers are equally near then the even one is chosen). If the result is equal to 0 then its sign will be the sign of a. --- 2634,2639 ---- def remainder_near(self, a, b): ! """Returns to be "a - b * n", where n is the integer nearest the exact ! value of "x / b" (if two integers are equally near then the even one is chosen). If the result is equal to 0 then its sign will be the sign of a. *************** *** 3091,3095 **** ! ##if __name__ == '__main__': ! ## import doctest, sys ! ## doctest.testmod(sys.modules[__name__]) --- 3117,3121 ---- ! if __name__ == '__main__': ! import doctest, sys ! doctest.testmod(sys.modules[__name__]) From rhettinger at users.sourceforge.net Thu Jul 1 06:35:47 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 06:35:50 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal Decimal.py, 1.38, 1.39 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23601 Modified Files: Decimal.py Log Message: Remove unused private method. Index: Decimal.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/Decimal.py,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** Decimal.py 1 Jul 2004 10:30:33 -0000 1.38 --- Decimal.py 1 Jul 2004 10:35:45 -0000 1.39 *************** *** 20,25 **** # rename Decimal.py and test_Decimal.py to lowercase decimal # retarget the test directory to decimaltestdata - # Fix doctest for _fixedpoint which fails only when run from this file - # but works fine in the doctest in test_decimal. # Checkout the doctest for Decimal("123.45e12345678901234567890") # which works in Py2.3 and Py2.4 but returns a NaN in Py2.2. --- 20,23 ---- *************** *** 1706,1722 **** return self._round_up(prec, expdiff, context) - def _fixedPoint(self, digits, rounding = None, context=None): - ## """Rounds to a number of digits around the decimal point. - ## - ## Convenience function to allow rounding to a specified number of - ## places after the decimal point. Negative numbers indicate - ## rounding before the decimal point. - ## - ## >>> str(Decimal("1234.34567")._fixedPoint(2)) - ## '1234.35' - numdigits = len(self._int)+self._exp - ans = self._round(numdigits+digits, rounding, context=context) - return ans - def __pow__(self, n, modulo = None, context=None): """Return self ** n (mod modulo) --- 1704,1707 ---- From rhettinger at users.sourceforge.net Thu Jul 1 06:53:46 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 06:53:49 2004 Subject: [Python-checkins] python/dist/src/Lib/test/decimaltestdata - New directory Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/decimaltestdata In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25836/decimaltestdata Log Message: Directory /cvsroot/python/python/dist/src/Lib/test/decimaltestdata added to the repository From rhettinger at users.sourceforge.net Thu Jul 1 07:01:33 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 07:01:37 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26988/Lib Added Files: decimal.py Log Message: Move Decimal from the sandbox into production. --- NEW FILE: decimal.py --- # Copyright (c) 2004 Python Software Foundation. # All rights reserved. # Written by Eric Price # and Facundo Batista # and Raymond Hettinger # and Aahz (aahz at pobox.com) # and Tim Peters # Todo: # Add deepcopy and pickle support for contexts # Consider having a SimpleDecimal subclass implementing X3.274 semantics # Improve the Context API # Especially with respect to setting flags and traps # Consider adding a clear_flags() method to Context # Provide a clean way of attaching monetary format representations # Review all exposed constants for utility vs. namespace clutter [...3046 lines suppressed...] mantissa = intpart + fracpart tmp = map(int, mantissa) backup = tmp while tmp and tmp[0] == 0: del tmp[0] # It's a zero if not tmp: if backup: return (sign, tuple(backup), exp) return (sign, (0,), exp) mantissa = tuple(tmp) return (sign, mantissa, exp) if __name__ == '__main__': import doctest, sys doctest.testmod(sys.modules[__name__]) From rhettinger at users.sourceforge.net Thu Jul 1 07:01:37 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 07:01:53 2004 Subject: [Python-checkins] python/dist/src/Lib/test/decimaltestdata abs.decTest, NONE, 1.1 add.decTest, NONE, 1.1 base.decTest, NONE, 1.1 clamp.decTest, NONE, 1.1 compare.decTest, NONE, 1.1 decimal64.decTest, NONE, 1.1 divide.decTest, NONE, 1.1 divideint.decTest, NONE, 1.1 inexact.decTest, NONE, 1.1 integer.decTest, NONE, 1.1 max.decTest, NONE, 1.1 min.decTest, NONE, 1.1 minus.decTest, NONE, 1.1 multiply.decTest, NONE, 1.1 normalize.decTest, NONE, 1.1 plus.decTest, NONE, 1.1 power.decTest, NONE, 1.1 quantize.decTest, NONE, 1.1 randomBound32.decTest, NONE, 1.1 randoms.decTest, NONE, 1.1 remainder.decTest, NONE, 1.1 remainderNear.decTest, NONE, 1.1 rescale.decTest, NONE, 1.1 rounding.decTest, NONE, 1.1 samequantum.decTest, NONE, 1.1 squareroot.decTest, NONE, 1.1 subtract.decTest, NONE, 1.1 testall.decTest, NONE, 1.1 tointegral.decTest, NONE, 1.1 trim.decTest, NONE, 1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/decimaltestdata In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26988/Lib/test/decimaltestdata Added Files: abs.decTest add.decTest base.decTest clamp.decTest compare.decTest decimal64.decTest divide.decTest divideint.decTest inexact.decTest integer.decTest max.decTest min.decTest minus.decTest multiply.decTest normalize.decTest plus.decTest power.decTest quantize.decTest randomBound32.decTest randoms.decTest remainder.decTest remainderNear.decTest rescale.decTest rounding.decTest samequantum.decTest squareroot.decTest subtract.decTest testall.decTest tointegral.decTest trim.decTest Log Message: Move Decimal from the sandbox into production. --- NEW FILE: abs.decTest --- ------------------------------------------------------------------------ -- abs.decTest -- decimal absolute value -- -- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 -- This set of tests primarily tests the existence of the operator. -- Additon, subtraction, rounding, and more overflows are tested -- elsewhere. precision: 9 rounding: half_up maxExponent: 384 minexponent: -383 extended: 1 absx001 abs '1' -> '1' absx002 abs '-1' -> '1' absx003 abs '1.00' -> '1.00' absx004 abs '-1.00' -> '1.00' absx005 abs '0' -> '0' absx006 abs '0.00' -> '0.00' absx007 abs '00.0' -> '0.0' absx008 abs '00.00' -> '0.00' absx009 abs '00' -> '0' absx010 abs '-2' -> '2' absx011 abs '2' -> '2' absx012 abs '-2.00' -> '2.00' absx013 abs '2.00' -> '2.00' absx014 abs '-0' -> '0' absx015 abs '-0.00' -> '0.00' absx016 abs '-00.0' -> '0.0' absx017 abs '-00.00' -> '0.00' absx018 abs '-00' -> '0' absx020 abs '-2000000' -> '2000000' absx021 abs '2000000' -> '2000000' precision: 7 absx022 abs '-2000000' -> '2000000' absx023 abs '2000000' -> '2000000' precision: 6 absx024 abs '-2000000' -> '2.00000E+6' Rounded absx025 abs '2000000' -> '2.00000E+6' Rounded precision: 3 absx026 abs '-2000000' -> '2.00E+6' Rounded absx027 abs '2000000' -> '2.00E+6' Rounded absx030 abs '+0.1' -> '0.1' absx031 abs '-0.1' -> '0.1' absx032 abs '+0.01' -> '0.01' absx033 abs '-0.01' -> '0.01' absx034 abs '+0.001' -> '0.001' absx035 abs '-0.001' -> '0.001' absx036 abs '+0.000001' -> '0.000001' absx037 abs '-0.000001' -> '0.000001' absx038 abs '+0.000000000001' -> '1E-12' absx039 abs '-0.000000000001' -> '1E-12' -- examples from decArith precision: 9 absx040 abs '2.1' -> '2.1' absx041 abs '-100' -> '100' absx042 abs '101.5' -> '101.5' absx043 abs '-101.5' -> '101.5' -- more fixed, potential LHS swaps/overlays if done by subtract 0 precision: 9 absx060 abs '-56267E-10' -> '0.0000056267' absx061 abs '-56267E-5' -> '0.56267' absx062 abs '-56267E-2' -> '562.67' absx063 abs '-56267E-1' -> '5626.7' absx065 abs '-56267E-0' -> '56267' -- overflow tests maxexponent: 999999999 minexponent: -999999999 precision: 3 absx120 abs 9.999E+999999999 -> Infinity Inexact Overflow Rounded -- subnormals and underflow precision: 3 maxexponent: 999 minexponent: -999 absx210 abs 1.00E-999 -> 1.00E-999 absx211 abs 0.1E-999 -> 1E-1000 Subnormal absx212 abs 0.10E-999 -> 1.0E-1000 Subnormal absx213 abs 0.100E-999 -> 1.0E-1000 Subnormal Rounded absx214 abs 0.01E-999 -> 1E-1001 Subnormal -- next is rounded to Emin absx215 abs 0.999E-999 -> 1.00E-999 Inexact Rounded Subnormal Underflow absx216 abs 0.099E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow absx217 abs 0.009E-999 -> 1E-1001 Inexact Rounded Subnormal Underflow absx218 abs 0.001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow absx219 abs 0.0009E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow absx220 abs 0.0001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow absx230 abs -1.00E-999 -> 1.00E-999 absx231 abs -0.1E-999 -> 1E-1000 Subnormal absx232 abs -0.10E-999 -> 1.0E-1000 Subnormal absx233 abs -0.100E-999 -> 1.0E-1000 Subnormal Rounded absx234 abs -0.01E-999 -> 1E-1001 Subnormal -- next is rounded to Emin absx235 abs -0.999E-999 -> 1.00E-999 Inexact Rounded Subnormal Underflow absx236 abs -0.099E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow absx237 abs -0.009E-999 -> 1E-1001 Inexact Rounded Subnormal Underflow absx238 abs -0.001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow absx239 abs -0.0009E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow absx240 abs -0.0001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow -- long operand tests maxexponent: 999 minexponent: -999 precision: 9 absx301 abs 12345678000 -> 1.23456780E+10 Rounded absx302 abs 1234567800 -> 1.23456780E+9 Rounded absx303 abs 1234567890 -> 1.23456789E+9 Rounded absx304 abs 1234567891 -> 1.23456789E+9 Inexact Rounded absx305 abs 12345678901 -> 1.23456789E+10 Inexact Rounded absx306 abs 1234567896 -> 1.23456790E+9 Inexact Rounded precision: 15 absx321 abs 12345678000 -> 12345678000 absx322 abs 1234567800 -> 1234567800 absx323 abs 1234567890 -> 1234567890 absx324 abs 1234567891 -> 1234567891 absx325 abs 12345678901 -> 12345678901 absx326 abs 1234567896 -> 1234567896 -- Specials precision: 9 -- specials absx520 abs 'Inf' -> 'Infinity' absx521 abs '-Inf' -> 'Infinity' absx522 abs NaN -> NaN absx523 abs sNaN -> NaN Invalid_operation absx524 abs NaN22 -> NaN22 absx525 abs sNaN33 -> NaN33 Invalid_operation absx526 abs -NaN22 -> -NaN22 absx527 abs -sNaN33 -> -NaN33 Invalid_operation -- Null tests absx900 abs # -> NaN Invalid_operation --- NEW FILE: add.decTest --- ------------------------------------------------------------------------ -- add.decTest -- decimal addition -- -- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ [...1088 lines suppressed...] addx1141 add 10E-101 -1e-200 -> 9E-101 Subnormal Inexact Rounded Underflow addx1142 add 1E-101 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow addx1143 add 0E-101 -1e-200 -> -0E-101 Subnormal Inexact Rounded Underflow addx1144 add 1E-102 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow addx1151 add 10000E-102 -1e-200 -> 9.99E-99 Subnormal Inexact Rounded Underflow addx1152 add 1000E-102 -1e-200 -> 9.9E-100 Subnormal Inexact Rounded Underflow addx1153 add 100E-102 -1e-200 -> 9E-101 Subnormal Inexact Rounded Underflow addx1154 add 10E-102 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow addx1155 add 1E-102 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow addx1156 add 0E-102 -1e-200 -> -0E-101 Subnormal Inexact Rounded Underflow addx1157 add 1E-103 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow addx1160 add 100E-105 -1e-101 -> -0E-101 Subnormal Inexact Rounded Underflow addx1161 add 100E-105 -1e-201 -> 0E-101 Subnormal Inexact Rounded Underflow -- Null tests addx9990 add 10 # -> NaN Invalid_operation addx9991 add # 10 -> NaN Invalid_operation --- NEW FILE: base.decTest --- ------------------------------------------------------------------------ -- base.decTest -- base decimal <--> string conversions -- -- Copyright (c) IBM Corporation, 1981, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ [...1227 lines suppressed...] basx1026 tosci 1e-2147483649 -> 0E-1000000014 Underflow Subnormal Inexact Rounded -- same unbalanced precision: 7 maxExponent: 96 minexponent: -95 basx1031 tosci 1e+2147483649 -> Infinity Overflow Inexact Rounded basx1032 tosci 1e+2147483648 -> Infinity Overflow Inexact Rounded basx1033 tosci 1e+2147483647 -> Infinity Overflow Inexact Rounded basx1034 tosci 1e-2147483647 -> 0E-101 Underflow Subnormal Inexact Rounded basx1035 tosci 1e-2147483648 -> 0E-101 Underflow Subnormal Inexact Rounded basx1036 tosci 1e-2147483649 -> 0E-101 Underflow Subnormal Inexact Rounded -- check for double-rounded subnormals precision: 5 maxexponent: 79 minexponent: -79 basx1041 toSci 1.52444E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow basx1042 toSci 1.52445E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow basx1043 toSci 1.52446E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow --- NEW FILE: clamp.decTest --- ------------------------------------------------------------------------ -- clamp.decTest -- clamped exponent tests (format-independent) -- -- Copyright (c) IBM Corporation, 2000, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 -- This set of tests uses the same limits as the 8-byte concrete -- representation, but applies clamping without using format-specific -- conversions. extended: 1 precision: 16 rounding: half_even maxExponent: 384 minExponent: -383 clamp: 1 -- General testcases -- Normality clam010 apply 1234567890123456 -> 1234567890123456 clam011 apply 1234567890123456.0 -> 1234567890123456 Rounded clam012 apply 1234567890123456.1 -> 1234567890123456 Rounded Inexact clam013 apply -1234567890123456 -> -1234567890123456 clam014 apply -1234567890123456.0 -> -1234567890123456 Rounded clam015 apply -1234567890123456.1 -> -1234567890123456 Rounded Inexact -- Nmax and similar clam022 apply 9.999999999999999E+384 -> 9.999999999999999E+384 clam024 apply 1.234567890123456E+384 -> 1.234567890123456E+384 -- fold-downs (more below) clam030 apply 1.23E+384 -> 1.230000000000000E+384 Clamped clam032 apply 1E+384 -> 1.000000000000000E+384 Clamped clam051 apply 12345 -> 12345 clam053 apply 1234 -> 1234 clam055 apply 123 -> 123 clam057 apply 12 -> 12 clam059 apply 1 -> 1 clam061 apply 1.23 -> 1.23 clam063 apply 123.45 -> 123.45 -- Nmin and below clam071 apply 1E-383 -> 1E-383 clam073 apply 1.000000000000000E-383 -> 1.000000000000000E-383 clam075 apply 1.000000000000001E-383 -> 1.000000000000001E-383 clam077 apply 0.100000000000000E-383 -> 1.00000000000000E-384 Subnormal clam079 apply 0.000000000000010E-383 -> 1.0E-397 Subnormal clam081 apply 0.00000000000001E-383 -> 1E-397 Subnormal clam083 apply 0.000000000000001E-383 -> 1E-398 Subnormal -- underflows clam090 apply 1e-398 -> #0000000000000001 Subnormal clam091 apply 1.9e-398 -> #0000000000000002 Subnormal Underflow Inexact Rounded clam092 apply 1.1e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded clam093 apply 1.00000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded clam094 apply 1.00000000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded clam095 apply 1.000000000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded clam096 apply 0.1e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded clam097 apply 0.00000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded clam098 apply 0.00000000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded clam099 apply 0.000000000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded -- Same again, negatives -- Nmax and similar clam122 apply -9.999999999999999E+384 -> -9.999999999999999E+384 clam124 apply -1.234567890123456E+384 -> -1.234567890123456E+384 -- fold-downs (more below) clam130 apply -1.23E+384 -> -1.230000000000000E+384 Clamped clam132 apply -1E+384 -> -1.000000000000000E+384 Clamped clam151 apply -12345 -> -12345 clam153 apply -1234 -> -1234 clam155 apply -123 -> -123 clam157 apply -12 -> -12 clam159 apply -1 -> -1 clam161 apply -1.23 -> -1.23 clam163 apply -123.45 -> -123.45 -- Nmin and below clam171 apply -1E-383 -> -1E-383 clam173 apply -1.000000000000000E-383 -> -1.000000000000000E-383 clam175 apply -1.000000000000001E-383 -> -1.000000000000001E-383 clam177 apply -0.100000000000000E-383 -> -1.00000000000000E-384 Subnormal clam179 apply -0.000000000000010E-383 -> -1.0E-397 Subnormal clam181 apply -0.00000000000001E-383 -> -1E-397 Subnormal clam183 apply -0.000000000000001E-383 -> -1E-398 Subnormal -- underflows clam189 apply -1e-398 -> #8000000000000001 Subnormal clam190 apply -1.0e-398 -> #8000000000000001 Subnormal Rounded clam191 apply -1.9e-398 -> #8000000000000002 Subnormal Underflow Inexact Rounded clam192 apply -1.1e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded clam193 apply -1.00000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded clam194 apply -1.00000000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded clam195 apply -1.000000000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded clam196 apply -0.1e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded clam197 apply -0.00000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded clam198 apply -0.00000000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded clam199 apply -0.000000000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded -- zeros clam401 apply 0E-500 -> 0E-398 Clamped clam402 apply 0E-400 -> 0E-398 Clamped clam403 apply 0E-398 -> 0E-398 clam404 apply 0.000000000000000E-383 -> 0E-398 clam405 apply 0E-2 -> 0.00 clam406 apply 0 -> 0 clam407 apply 0E+3 -> 0E+3 clam408 apply 0E+369 -> 0E+369 -- clamped zeros... clam410 apply 0E+370 -> 0E+369 Clamped clam411 apply 0E+384 -> 0E+369 Clamped clam412 apply 0E+400 -> 0E+369 Clamped clam413 apply 0E+500 -> 0E+369 Clamped -- negative zeros clam420 apply -0E-500 -> -0E-398 Clamped clam421 apply -0E-400 -> -0E-398 Clamped clam422 apply -0E-398 -> -0E-398 clam423 apply -0.000000000000000E-383 -> -0E-398 clam424 apply -0E-2 -> -0.00 clam425 apply -0 -> -0 clam426 apply -0E+3 -> -0E+3 clam427 apply -0E+369 -> -0E+369 -- clamped zeros... clam431 apply -0E+370 -> -0E+369 Clamped clam432 apply -0E+384 -> -0E+369 Clamped clam433 apply -0E+400 -> -0E+369 Clamped clam434 apply -0E+500 -> -0E+369 Clamped -- fold-down full sequence clam601 apply 1E+384 -> 1.000000000000000E+384 Clamped clam603 apply 1E+383 -> 1.00000000000000E+383 Clamped clam605 apply 1E+382 -> 1.0000000000000E+382 Clamped clam607 apply 1E+381 -> 1.000000000000E+381 Clamped clam609 apply 1E+380 -> 1.00000000000E+380 Clamped clam611 apply 1E+379 -> 1.0000000000E+379 Clamped clam613 apply 1E+378 -> 1.000000000E+378 Clamped clam615 apply 1E+377 -> 1.00000000E+377 Clamped clam617 apply 1E+376 -> 1.0000000E+376 Clamped clam619 apply 1E+375 -> 1.000000E+375 Clamped clam621 apply 1E+374 -> 1.00000E+374 Clamped clam623 apply 1E+373 -> 1.0000E+373 Clamped clam625 apply 1E+372 -> 1.000E+372 Clamped clam627 apply 1E+371 -> 1.00E+371 Clamped clam629 apply 1E+370 -> 1.0E+370 Clamped clam631 apply 1E+369 -> 1E+369 clam633 apply 1E+368 -> 1E+368 -- same with 9s clam641 apply 9E+384 -> 9.000000000000000E+384 Clamped clam643 apply 9E+383 -> 9.00000000000000E+383 Clamped clam645 apply 9E+382 -> 9.0000000000000E+382 Clamped clam647 apply 9E+381 -> 9.000000000000E+381 Clamped clam649 apply 9E+380 -> 9.00000000000E+380 Clamped clam651 apply 9E+379 -> 9.0000000000E+379 Clamped clam653 apply 9E+378 -> 9.000000000E+378 Clamped clam655 apply 9E+377 -> 9.00000000E+377 Clamped clam657 apply 9E+376 -> 9.0000000E+376 Clamped clam659 apply 9E+375 -> 9.000000E+375 Clamped clam661 apply 9E+374 -> 9.00000E+374 Clamped clam663 apply 9E+373 -> 9.0000E+373 Clamped clam665 apply 9E+372 -> 9.000E+372 Clamped clam667 apply 9E+371 -> 9.00E+371 Clamped clam669 apply 9E+370 -> 9.0E+370 Clamped clam671 apply 9E+369 -> 9E+369 clam673 apply 9E+368 -> 9E+368 -- example from documentation precision: 7 rounding: half_even maxExponent: +96 minExponent: -95 clamp: 0 clam700 apply 1.23E+96 -> 1.23E+96 clamp: 1 clam701 apply 1.23E+96 -> 1.230000E+96 Clamped --- NEW FILE: compare.decTest --- ------------------------------------------------------------------------ -- compare.decTest -- decimal comparison -- -- Copyright (c) IBM Corporation, 1981, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot -- overflow or underflow, so actual subtractions are not necesary). extended: 1 precision: 9 rounding: half_up maxExponent: 999 minexponent: -999 -- sanity checks comx001 compare -2 -2 -> 0 comx002 compare -2 -1 -> -1 comx003 compare -2 0 -> -1 comx004 compare -2 1 -> -1 comx005 compare -2 2 -> -1 comx006 compare -1 -2 -> 1 comx007 compare -1 -1 -> 0 comx008 compare -1 0 -> -1 comx009 compare -1 1 -> -1 comx010 compare -1 2 -> -1 comx011 compare 0 -2 -> 1 comx012 compare 0 -1 -> 1 comx013 compare 0 0 -> 0 comx014 compare 0 1 -> -1 comx015 compare 0 2 -> -1 comx016 compare 1 -2 -> 1 comx017 compare 1 -1 -> 1 comx018 compare 1 0 -> 1 comx019 compare 1 1 -> 0 comx020 compare 1 2 -> -1 comx021 compare 2 -2 -> 1 comx022 compare 2 -1 -> 1 comx023 compare 2 0 -> 1 comx025 compare 2 1 -> 1 comx026 compare 2 2 -> 0 comx031 compare -20 -20 -> 0 comx032 compare -20 -10 -> -1 comx033 compare -20 00 -> -1 comx034 compare -20 10 -> -1 comx035 compare -20 20 -> -1 comx036 compare -10 -20 -> 1 comx037 compare -10 -10 -> 0 comx038 compare -10 00 -> -1 comx039 compare -10 10 -> -1 comx040 compare -10 20 -> -1 comx041 compare 00 -20 -> 1 comx042 compare 00 -10 -> 1 comx043 compare 00 00 -> 0 comx044 compare 00 10 -> -1 comx045 compare 00 20 -> -1 comx046 compare 10 -20 -> 1 comx047 compare 10 -10 -> 1 comx048 compare 10 00 -> 1 comx049 compare 10 10 -> 0 comx050 compare 10 20 -> -1 comx051 compare 20 -20 -> 1 comx052 compare 20 -10 -> 1 comx053 compare 20 00 -> 1 comx055 compare 20 10 -> 1 comx056 compare 20 20 -> 0 comx061 compare -2.0 -2.0 -> 0 comx062 compare -2.0 -1.0 -> -1 comx063 compare -2.0 0.0 -> -1 comx064 compare -2.0 1.0 -> -1 comx065 compare -2.0 2.0 -> -1 comx066 compare -1.0 -2.0 -> 1 comx067 compare -1.0 -1.0 -> 0 comx068 compare -1.0 0.0 -> -1 comx069 compare -1.0 1.0 -> -1 comx070 compare -1.0 2.0 -> -1 comx071 compare 0.0 -2.0 -> 1 comx072 compare 0.0 -1.0 -> 1 comx073 compare 0.0 0.0 -> 0 comx074 compare 0.0 1.0 -> -1 comx075 compare 0.0 2.0 -> -1 comx076 compare 1.0 -2.0 -> 1 comx077 compare 1.0 -1.0 -> 1 comx078 compare 1.0 0.0 -> 1 comx079 compare 1.0 1.0 -> 0 comx080 compare 1.0 2.0 -> -1 comx081 compare 2.0 -2.0 -> 1 comx082 compare 2.0 -1.0 -> 1 comx083 compare 2.0 0.0 -> 1 comx085 compare 2.0 1.0 -> 1 comx086 compare 2.0 2.0 -> 0 -- now some cases which might overflow if subtract were used maxexponent: 999999999 minexponent: -999999999 comx090 compare 9.99999999E+999999999 9.99999999E+999999999 -> 0 comx091 compare -9.99999999E+999999999 9.99999999E+999999999 -> -1 comx092 compare 9.99999999E+999999999 -9.99999999E+999999999 -> 1 comx093 compare -9.99999999E+999999999 -9.99999999E+999999999 -> 0 -- some differing length/exponent cases comx100 compare 7.0 7.0 -> 0 comx101 compare 7.0 7 -> 0 comx102 compare 7 7.0 -> 0 comx103 compare 7E+0 7.0 -> 0 comx104 compare 70E-1 7.0 -> 0 comx105 compare 0.7E+1 7 -> 0 comx106 compare 70E-1 7 -> 0 comx107 compare 7.0 7E+0 -> 0 comx108 compare 7.0 70E-1 -> 0 comx109 compare 7 0.7E+1 -> 0 comx110 compare 7 70E-1 -> 0 comx120 compare 8.0 7.0 -> 1 comx121 compare 8.0 7 -> 1 comx122 compare 8 7.0 -> 1 comx123 compare 8E+0 7.0 -> 1 comx124 compare 80E-1 7.0 -> 1 comx125 compare 0.8E+1 7 -> 1 comx126 compare 80E-1 7 -> 1 comx127 compare 8.0 7E+0 -> 1 comx128 compare 8.0 70E-1 -> 1 comx129 compare 8 0.7E+1 -> 1 comx130 compare 8 70E-1 -> 1 comx140 compare 8.0 9.0 -> -1 comx141 compare 8.0 9 -> -1 comx142 compare 8 9.0 -> -1 comx143 compare 8E+0 9.0 -> -1 comx144 compare 80E-1 9.0 -> -1 comx145 compare 0.8E+1 9 -> -1 comx146 compare 80E-1 9 -> -1 comx147 compare 8.0 9E+0 -> -1 comx148 compare 8.0 90E-1 -> -1 comx149 compare 8 0.9E+1 -> -1 comx150 compare 8 90E-1 -> -1 -- and again, with sign changes -+ .. comx200 compare -7.0 7.0 -> -1 comx201 compare -7.0 7 -> -1 comx202 compare -7 7.0 -> -1 comx203 compare -7E+0 7.0 -> -1 comx204 compare -70E-1 7.0 -> -1 comx205 compare -0.7E+1 7 -> -1 comx206 compare -70E-1 7 -> -1 comx207 compare -7.0 7E+0 -> -1 comx208 compare -7.0 70E-1 -> -1 comx209 compare -7 0.7E+1 -> -1 comx210 compare -7 70E-1 -> -1 comx220 compare -8.0 7.0 -> -1 comx221 compare -8.0 7 -> -1 comx222 compare -8 7.0 -> -1 comx223 compare -8E+0 7.0 -> -1 comx224 compare -80E-1 7.0 -> -1 comx225 compare -0.8E+1 7 -> -1 comx226 compare -80E-1 7 -> -1 comx227 compare -8.0 7E+0 -> -1 comx228 compare -8.0 70E-1 -> -1 comx229 compare -8 0.7E+1 -> -1 comx230 compare -8 70E-1 -> -1 comx240 compare -8.0 9.0 -> -1 comx241 compare -8.0 9 -> -1 comx242 compare -8 9.0 -> -1 comx243 compare -8E+0 9.0 -> -1 comx244 compare -80E-1 9.0 -> -1 comx245 compare -0.8E+1 9 -> -1 comx246 compare -80E-1 9 -> -1 comx247 compare -8.0 9E+0 -> -1 comx248 compare -8.0 90E-1 -> -1 comx249 compare -8 0.9E+1 -> -1 comx250 compare -8 90E-1 -> -1 -- and again, with sign changes +- .. comx300 compare 7.0 -7.0 -> 1 comx301 compare 7.0 -7 -> 1 comx302 compare 7 -7.0 -> 1 comx303 compare 7E+0 -7.0 -> 1 comx304 compare 70E-1 -7.0 -> 1 comx305 compare .7E+1 -7 -> 1 comx306 compare 70E-1 -7 -> 1 comx307 compare 7.0 -7E+0 -> 1 comx308 compare 7.0 -70E-1 -> 1 comx309 compare 7 -.7E+1 -> 1 comx310 compare 7 -70E-1 -> 1 comx320 compare 8.0 -7.0 -> 1 comx321 compare 8.0 -7 -> 1 comx322 compare 8 -7.0 -> 1 comx323 compare 8E+0 -7.0 -> 1 comx324 compare 80E-1 -7.0 -> 1 comx325 compare .8E+1 -7 -> 1 comx326 compare 80E-1 -7 -> 1 comx327 compare 8.0 -7E+0 -> 1 comx328 compare 8.0 -70E-1 -> 1 comx329 compare 8 -.7E+1 -> 1 comx330 compare 8 -70E-1 -> 1 comx340 compare 8.0 -9.0 -> 1 comx341 compare 8.0 -9 -> 1 comx342 compare 8 -9.0 -> 1 comx343 compare 8E+0 -9.0 -> 1 comx344 compare 80E-1 -9.0 -> 1 comx345 compare .8E+1 -9 -> 1 comx346 compare 80E-1 -9 -> 1 comx347 compare 8.0 -9E+0 -> 1 comx348 compare 8.0 -90E-1 -> 1 comx349 compare 8 -.9E+1 -> 1 comx350 compare 8 -90E-1 -> 1 -- and again, with sign changes -- .. comx400 compare -7.0 -7.0 -> 0 comx401 compare -7.0 -7 -> 0 comx402 compare -7 -7.0 -> 0 comx403 compare -7E+0 -7.0 -> 0 comx404 compare -70E-1 -7.0 -> 0 comx405 compare -.7E+1 -7 -> 0 comx406 compare -70E-1 -7 -> 0 comx407 compare -7.0 -7E+0 -> 0 comx408 compare -7.0 -70E-1 -> 0 comx409 compare -7 -.7E+1 -> 0 comx410 compare -7 -70E-1 -> 0 comx420 compare -8.0 -7.0 -> -1 comx421 compare -8.0 -7 -> -1 comx422 compare -8 -7.0 -> -1 comx423 compare -8E+0 -7.0 -> -1 comx424 compare -80E-1 -7.0 -> -1 comx425 compare -.8E+1 -7 -> -1 comx426 compare -80E-1 -7 -> -1 comx427 compare -8.0 -7E+0 -> -1 comx428 compare -8.0 -70E-1 -> -1 comx429 compare -8 -.7E+1 -> -1 comx430 compare -8 -70E-1 -> -1 comx440 compare -8.0 -9.0 -> 1 comx441 compare -8.0 -9 -> 1 comx442 compare -8 -9.0 -> 1 comx443 compare -8E+0 -9.0 -> 1 comx444 compare -80E-1 -9.0 -> 1 comx445 compare -.8E+1 -9 -> 1 comx446 compare -80E-1 -9 -> 1 comx447 compare -8.0 -9E+0 -> 1 comx448 compare -8.0 -90E-1 -> 1 comx449 compare -8 -.9E+1 -> 1 comx450 compare -8 -90E-1 -> 1 -- testcases that subtract to lots of zeros at boundaries [pgr] precision: 40 comx470 compare 123.4560000000000000E789 123.456E789 -> 0 comx471 compare 123.456000000000000E-89 123.456E-89 -> 0 comx472 compare 123.45600000000000E789 123.456E789 -> 0 comx473 compare 123.4560000000000E-89 123.456E-89 -> 0 comx474 compare 123.456000000000E789 123.456E789 -> 0 comx475 compare 123.45600000000E-89 123.456E-89 -> 0 comx476 compare 123.4560000000E789 123.456E789 -> 0 comx477 compare 123.456000000E-89 123.456E-89 -> 0 comx478 compare 123.45600000E789 123.456E789 -> 0 comx479 compare 123.4560000E-89 123.456E-89 -> 0 comx480 compare 123.456000E789 123.456E789 -> 0 comx481 compare 123.45600E-89 123.456E-89 -> 0 comx482 compare 123.4560E789 123.456E789 -> 0 comx483 compare 123.456E-89 123.456E-89 -> 0 comx484 compare 123.456E-89 123.4560000000000000E-89 -> 0 comx485 compare 123.456E789 123.456000000000000E789 -> 0 comx486 compare 123.456E-89 123.45600000000000E-89 -> 0 comx487 compare 123.456E789 123.4560000000000E789 -> 0 comx488 compare 123.456E-89 123.456000000000E-89 -> 0 comx489 compare 123.456E789 123.45600000000E789 -> 0 comx490 compare 123.456E-89 123.4560000000E-89 -> 0 comx491 compare 123.456E789 123.456000000E789 -> 0 comx492 compare 123.456E-89 123.45600000E-89 -> 0 comx493 compare 123.456E789 123.4560000E789 -> 0 comx494 compare 123.456E-89 123.456000E-89 -> 0 comx495 compare 123.456E789 123.45600E789 -> 0 comx496 compare 123.456E-89 123.4560E-89 -> 0 comx497 compare 123.456E789 123.456E789 -> 0 -- wide-ranging, around precision; signs equal precision: 9 comx500 compare 1 1E-15 -> 1 comx501 compare 1 1E-14 -> 1 comx502 compare 1 1E-13 -> 1 comx503 compare 1 1E-12 -> 1 comx504 compare 1 1E-11 -> 1 comx505 compare 1 1E-10 -> 1 comx506 compare 1 1E-9 -> 1 comx507 compare 1 1E-8 -> 1 comx508 compare 1 1E-7 -> 1 comx509 compare 1 1E-6 -> 1 comx510 compare 1 1E-5 -> 1 comx511 compare 1 1E-4 -> 1 comx512 compare 1 1E-3 -> 1 comx513 compare 1 1E-2 -> 1 comx514 compare 1 1E-1 -> 1 comx515 compare 1 1E-0 -> 0 comx516 compare 1 1E+1 -> -1 comx517 compare 1 1E+2 -> -1 comx518 compare 1 1E+3 -> -1 comx519 compare 1 1E+4 -> -1 comx521 compare 1 1E+5 -> -1 comx522 compare 1 1E+6 -> -1 comx523 compare 1 1E+7 -> -1 comx524 compare 1 1E+8 -> -1 comx525 compare 1 1E+9 -> -1 comx526 compare 1 1E+10 -> -1 comx527 compare 1 1E+11 -> -1 comx528 compare 1 1E+12 -> -1 comx529 compare 1 1E+13 -> -1 comx530 compare 1 1E+14 -> -1 comx531 compare 1 1E+15 -> -1 -- LR swap comx540 compare 1E-15 1 -> -1 comx541 compare 1E-14 1 -> -1 comx542 compare 1E-13 1 -> -1 comx543 compare 1E-12 1 -> -1 comx544 compare 1E-11 1 -> -1 comx545 compare 1E-10 1 -> -1 comx546 compare 1E-9 1 -> -1 comx547 compare 1E-8 1 -> -1 comx548 compare 1E-7 1 -> -1 comx549 compare 1E-6 1 -> -1 comx550 compare 1E-5 1 -> -1 comx551 compare 1E-4 1 -> -1 comx552 compare 1E-3 1 -> -1 comx553 compare 1E-2 1 -> -1 comx554 compare 1E-1 1 -> -1 comx555 compare 1E-0 1 -> 0 comx556 compare 1E+1 1 -> 1 comx557 compare 1E+2 1 -> 1 comx558 compare 1E+3 1 -> 1 comx559 compare 1E+4 1 -> 1 comx561 compare 1E+5 1 -> 1 comx562 compare 1E+6 1 -> 1 comx563 compare 1E+7 1 -> 1 comx564 compare 1E+8 1 -> 1 comx565 compare 1E+9 1 -> 1 comx566 compare 1E+10 1 -> 1 comx567 compare 1E+11 1 -> 1 comx568 compare 1E+12 1 -> 1 comx569 compare 1E+13 1 -> 1 comx570 compare 1E+14 1 -> 1 comx571 compare 1E+15 1 -> 1 -- similar with an useful coefficient, one side only comx580 compare 0.000000987654321 1E-15 -> 1 comx581 compare 0.000000987654321 1E-14 -> 1 comx582 compare 0.000000987654321 1E-13 -> 1 comx583 compare 0.000000987654321 1E-12 -> 1 comx584 compare 0.000000987654321 1E-11 -> 1 comx585 compare 0.000000987654321 1E-10 -> 1 comx586 compare 0.000000987654321 1E-9 -> 1 comx587 compare 0.000000987654321 1E-8 -> 1 comx588 compare 0.000000987654321 1E-7 -> 1 comx589 compare 0.000000987654321 1E-6 -> -1 comx590 compare 0.000000987654321 1E-5 -> -1 comx591 compare 0.000000987654321 1E-4 -> -1 comx592 compare 0.000000987654321 1E-3 -> -1 comx593 compare 0.000000987654321 1E-2 -> -1 comx594 compare 0.000000987654321 1E-1 -> -1 comx595 compare 0.000000987654321 1E-0 -> -1 comx596 compare 0.000000987654321 1E+1 -> -1 comx597 compare 0.000000987654321 1E+2 -> -1 comx598 compare 0.000000987654321 1E+3 -> -1 comx599 compare 0.000000987654321 1E+4 -> -1 -- check some unit-y traps precision: 20 comx600 compare 12 12.2345 -> -1 comx601 compare 12.0 12.2345 -> -1 comx602 compare 12.00 12.2345 -> -1 comx603 compare 12.000 12.2345 -> -1 comx604 compare 12.0000 12.2345 -> -1 comx605 compare 12.00000 12.2345 -> -1 comx606 compare 12.000000 12.2345 -> -1 comx607 compare 12.0000000 12.2345 -> -1 comx608 compare 12.00000000 12.2345 -> -1 comx609 compare 12.000000000 12.2345 -> -1 comx610 compare 12.1234 12 -> 1 comx611 compare 12.1234 12.0 -> 1 comx612 compare 12.1234 12.00 -> 1 comx613 compare 12.1234 12.000 -> 1 comx614 compare 12.1234 12.0000 -> 1 comx615 compare 12.1234 12.00000 -> 1 comx616 compare 12.1234 12.000000 -> 1 comx617 compare 12.1234 12.0000000 -> 1 comx618 compare 12.1234 12.00000000 -> 1 comx619 compare 12.1234 12.000000000 -> 1 comx620 compare -12 -12.2345 -> 1 comx621 compare -12.0 -12.2345 -> 1 comx622 compare -12.00 -12.2345 -> 1 comx623 compare -12.000 -12.2345 -> 1 comx624 compare -12.0000 -12.2345 -> 1 comx625 compare -12.00000 -12.2345 -> 1 comx626 compare -12.000000 -12.2345 -> 1 comx627 compare -12.0000000 -12.2345 -> 1 comx628 compare -12.00000000 -12.2345 -> 1 comx629 compare -12.000000000 -12.2345 -> 1 comx630 compare -12.1234 -12 -> -1 comx631 compare -12.1234 -12.0 -> -1 comx632 compare -12.1234 -12.00 -> -1 comx633 compare -12.1234 -12.000 -> -1 comx634 compare -12.1234 -12.0000 -> -1 comx635 compare -12.1234 -12.00000 -> -1 comx636 compare -12.1234 -12.000000 -> -1 comx637 compare -12.1234 -12.0000000 -> -1 comx638 compare -12.1234 -12.00000000 -> -1 comx639 compare -12.1234 -12.000000000 -> -1 precision: 9 -- extended zeros comx640 compare 0 0 -> 0 comx641 compare 0 -0 -> 0 comx642 compare 0 -0.0 -> 0 comx643 compare 0 0.0 -> 0 comx644 compare -0 0 -> 0 comx645 compare -0 -0 -> 0 comx646 compare -0 -0.0 -> 0 comx647 compare -0 0.0 -> 0 comx648 compare 0.0 0 -> 0 comx649 compare 0.0 -0 -> 0 comx650 compare 0.0 -0.0 -> 0 comx651 compare 0.0 0.0 -> 0 comx652 compare -0.0 0 -> 0 comx653 compare -0.0 -0 -> 0 comx654 compare -0.0 -0.0 -> 0 comx655 compare -0.0 0.0 -> 0 comx656 compare -0E1 0.0 -> 0 comx657 compare -0E2 0.0 -> 0 comx658 compare 0E1 0.0 -> 0 comx659 compare 0E2 0.0 -> 0 comx660 compare -0E1 0 -> 0 comx661 compare -0E2 0 -> 0 comx662 compare 0E1 0 -> 0 comx663 compare 0E2 0 -> 0 comx664 compare -0E1 -0E1 -> 0 comx665 compare -0E2 -0E1 -> 0 comx666 compare 0E1 -0E1 -> 0 comx667 compare 0E2 -0E1 -> 0 comx668 compare -0E1 -0E2 -> 0 comx669 compare -0E2 -0E2 -> 0 comx670 compare 0E1 -0E2 -> 0 comx671 compare 0E2 -0E2 -> 0 comx672 compare -0E1 0E1 -> 0 comx673 compare -0E2 0E1 -> 0 comx674 compare 0E1 0E1 -> 0 comx675 compare 0E2 0E1 -> 0 comx676 compare -0E1 0E2 -> 0 comx677 compare -0E2 0E2 -> 0 comx678 compare 0E1 0E2 -> 0 comx679 compare 0E2 0E2 -> 0 -- trailing zeros; unit-y precision: 20 comx680 compare 12 12 -> 0 comx681 compare 12 12.0 -> 0 comx682 compare 12 12.00 -> 0 comx683 compare 12 12.000 -> 0 comx684 compare 12 12.0000 -> 0 comx685 compare 12 12.00000 -> 0 comx686 compare 12 12.000000 -> 0 comx687 compare 12 12.0000000 -> 0 comx688 compare 12 12.00000000 -> 0 comx689 compare 12 12.000000000 -> 0 comx690 compare 12 12 -> 0 comx691 compare 12.0 12 -> 0 comx692 compare 12.00 12 -> 0 comx693 compare 12.000 12 -> 0 comx694 compare 12.0000 12 -> 0 comx695 compare 12.00000 12 -> 0 comx696 compare 12.000000 12 -> 0 comx697 compare 12.0000000 12 -> 0 comx698 compare 12.00000000 12 -> 0 comx699 compare 12.000000000 12 -> 0 -- long operand checks maxexponent: 999 minexponent: -999 precision: 9 comx701 compare 12345678000 1 -> 1 comx702 compare 1 12345678000 -> -1 comx703 compare 1234567800 1 -> 1 comx704 compare 1 1234567800 -> -1 comx705 compare 1234567890 1 -> 1 comx706 compare 1 1234567890 -> -1 comx707 compare 1234567891 1 -> 1 comx708 compare 1 1234567891 -> -1 comx709 compare 12345678901 1 -> 1 comx710 compare 1 12345678901 -> -1 comx711 compare 1234567896 1 -> 1 comx712 compare 1 1234567896 -> -1 comx713 compare -1234567891 1 -> -1 comx714 compare 1 -1234567891 -> 1 comx715 compare -12345678901 1 -> -1 comx716 compare 1 -12345678901 -> 1 comx717 compare -1234567896 1 -> -1 comx718 compare 1 -1234567896 -> 1 precision: 15 -- same with plenty of precision comx721 compare 12345678000 1 -> 1 comx722 compare 1 12345678000 -> -1 comx723 compare 1234567800 1 -> 1 comx724 compare 1 1234567800 -> -1 comx725 compare 1234567890 1 -> 1 comx726 compare 1 1234567890 -> -1 comx727 compare 1234567891 1 -> 1 comx728 compare 1 1234567891 -> -1 comx729 compare 12345678901 1 -> 1 comx730 compare 1 12345678901 -> -1 comx731 compare 1234567896 1 -> 1 comx732 compare 1 1234567896 -> -1 -- residue cases precision: 5 comx740 compare 1 0.9999999 -> 1 comx741 compare 1 0.999999 -> 1 comx742 compare 1 0.99999 -> 1 comx743 compare 1 1.0000 -> 0 comx744 compare 1 1.00001 -> -1 comx745 compare 1 1.000001 -> -1 comx746 compare 1 1.0000001 -> -1 comx750 compare 0.9999999 1 -> -1 comx751 compare 0.999999 1 -> -1 comx752 compare 0.99999 1 -> -1 comx753 compare 1.0000 1 -> 0 comx754 compare 1.00001 1 -> 1 comx755 compare 1.000001 1 -> 1 comx756 compare 1.0000001 1 -> 1 -- a selection of longies comx760 compare -36852134.84194296250843579428931 -5830629.8347085025808756560357940 -> -1 comx761 compare -36852134.84194296250843579428931 -36852134.84194296250843579428931 -> 0 comx762 compare -36852134.94194296250843579428931 -36852134.84194296250843579428931 -> -1 comx763 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 -- precisions above or below the difference should have no effect precision: 11 comx764 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 precision: 10 comx765 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 precision: 9 comx766 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 precision: 8 comx767 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 precision: 7 comx768 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 precision: 6 comx769 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 precision: 5 comx770 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 precision: 4 comx771 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 precision: 3 comx772 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 precision: 2 comx773 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 precision: 1 comx774 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1 -- Specials precision: 9 comx780 compare Inf -Inf -> 1 comx781 compare Inf -1000 -> 1 comx782 compare Inf -1 -> 1 comx783 compare Inf -0 -> 1 comx784 compare Inf 0 -> 1 comx785 compare Inf 1 -> 1 comx786 compare Inf 1000 -> 1 comx787 compare Inf Inf -> 0 comx788 compare -1000 Inf -> -1 comx789 compare -Inf Inf -> -1 comx790 compare -1 Inf -> -1 comx791 compare -0 Inf -> -1 comx792 compare 0 Inf -> -1 comx793 compare 1 Inf -> -1 comx794 compare 1000 Inf -> -1 comx795 compare Inf Inf -> 0 comx800 compare -Inf -Inf -> 0 comx801 compare -Inf -1000 -> -1 comx802 compare -Inf -1 -> -1 comx803 compare -Inf -0 -> -1 comx804 compare -Inf 0 -> -1 comx805 compare -Inf 1 -> -1 comx806 compare -Inf 1000 -> -1 comx807 compare -Inf Inf -> -1 comx808 compare -Inf -Inf -> 0 comx809 compare -1000 -Inf -> 1 comx810 compare -1 -Inf -> 1 comx811 compare -0 -Inf -> 1 comx812 compare 0 -Inf -> 1 comx813 compare 1 -Inf -> 1 comx814 compare 1000 -Inf -> 1 comx815 compare Inf -Inf -> 1 comx821 compare NaN -Inf -> NaN comx822 compare NaN -1000 -> NaN comx823 compare NaN -1 -> NaN comx824 compare NaN -0 -> NaN comx825 compare NaN 0 -> NaN comx826 compare NaN 1 -> NaN comx827 compare NaN 1000 -> NaN comx828 compare NaN Inf -> NaN comx829 compare NaN NaN -> NaN comx830 compare -Inf NaN -> NaN comx831 compare -1000 NaN -> NaN comx832 compare -1 NaN -> NaN comx833 compare -0 NaN -> NaN comx834 compare 0 NaN -> NaN comx835 compare 1 NaN -> NaN comx836 compare 1000 NaN -> NaN comx837 compare Inf NaN -> NaN comx838 compare -NaN -NaN -> -NaN comx839 compare +NaN -NaN -> NaN comx840 compare -NaN +NaN -> -NaN comx841 compare sNaN -Inf -> NaN Invalid_operation comx842 compare sNaN -1000 -> NaN Invalid_operation comx843 compare sNaN -1 -> NaN Invalid_operation comx844 compare sNaN -0 -> NaN Invalid_operation comx845 compare sNaN 0 -> NaN Invalid_operation comx846 compare sNaN 1 -> NaN Invalid_operation comx847 compare sNaN 1000 -> NaN Invalid_operation comx848 compare sNaN NaN -> NaN Invalid_operation comx849 compare sNaN sNaN -> NaN Invalid_operation comx850 compare NaN sNaN -> NaN Invalid_operation comx851 compare -Inf sNaN -> NaN Invalid_operation comx852 compare -1000 sNaN -> NaN Invalid_operation comx853 compare -1 sNaN -> NaN Invalid_operation comx854 compare -0 sNaN -> NaN Invalid_operation comx855 compare 0 sNaN -> NaN Invalid_operation comx856 compare 1 sNaN -> NaN Invalid_operation comx857 compare 1000 sNaN -> NaN Invalid_operation comx858 compare Inf sNaN -> NaN Invalid_operation comx859 compare NaN sNaN -> NaN Invalid_operation -- propagating NaNs comx860 compare NaN9 -Inf -> NaN9 comx861 compare NaN8 999 -> NaN8 comx862 compare NaN77 Inf -> NaN77 comx863 compare -NaN67 NaN5 -> -NaN67 comx864 compare -Inf -NaN4 -> -NaN4 comx865 compare -999 -NaN33 -> -NaN33 comx866 compare Inf NaN2 -> NaN2 comx867 compare -NaN41 -NaN42 -> -NaN41 comx868 compare +NaN41 -NaN42 -> NaN41 comx869 compare -NaN41 +NaN42 -> -NaN41 comx870 compare +NaN41 +NaN42 -> NaN41 comx871 compare -sNaN99 -Inf -> -NaN99 Invalid_operation comx872 compare sNaN98 -11 -> NaN98 Invalid_operation comx873 compare sNaN97 NaN -> NaN97 Invalid_operation comx874 compare sNaN16 sNaN94 -> NaN16 Invalid_operation comx875 compare NaN85 sNaN83 -> NaN83 Invalid_operation comx876 compare -Inf sNaN92 -> NaN92 Invalid_operation comx877 compare 088 sNaN81 -> NaN81 Invalid_operation comx878 compare Inf sNaN90 -> NaN90 Invalid_operation comx879 compare NaN -sNaN89 -> -NaN89 Invalid_operation -- overflow and underflow tests .. subnormal results now allowed maxExponent: 999999999 minexponent: -999999999 comx880 compare +1.23456789012345E-0 9E+999999999 -> -1 comx881 compare 9E+999999999 +1.23456789012345E-0 -> 1 comx882 compare +0.100 9E-999999999 -> 1 comx883 compare 9E-999999999 +0.100 -> -1 comx885 compare -1.23456789012345E-0 9E+999999999 -> -1 comx886 compare 9E+999999999 -1.23456789012345E-0 -> 1 comx887 compare -0.100 9E-999999999 -> -1 comx888 compare 9E-999999999 -0.100 -> 1 comx889 compare 1e-599999999 1e-400000001 -> -1 comx890 compare 1e-599999999 1e-400000000 -> -1 comx891 compare 1e-600000000 1e-400000000 -> -1 comx892 compare 9e-999999998 0.01 -> -1 comx893 compare 9e-999999998 0.1 -> -1 comx894 compare 0.01 9e-999999998 -> 1 comx895 compare 1e599999999 1e400000001 -> 1 comx896 compare 1e599999999 1e400000000 -> 1 comx897 compare 1e600000000 1e400000000 -> 1 comx898 compare 9e999999998 100 -> 1 comx899 compare 9e999999998 10 -> 1 comx900 compare 100 9e999999998 -> -1 -- signs comx901 compare 1e+777777777 1e+411111111 -> 1 comx902 compare 1e+777777777 -1e+411111111 -> 1 comx903 compare -1e+777777777 1e+411111111 -> -1 comx904 compare -1e+777777777 -1e+411111111 -> -1 comx905 compare 1e-777777777 1e-411111111 -> -1 comx906 compare 1e-777777777 -1e-411111111 -> 1 comx907 compare -1e-777777777 1e-411111111 -> -1 comx908 compare -1e-777777777 -1e-411111111 -> 1 -- Null tests comx990 compare 10 # -> NaN Invalid_operation comx991 compare # 10 -> NaN Invalid_operation --- NEW FILE: decimal64.decTest --- ------------------------------------------------------------------------ -- decimal64.decTest -- decimal eight-byte format testcases -- -- Copyright (c) IBM Corporation, 2000, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.28 -- This set of tests is for the eight-byte concrete representation. -- Its characteristics are: -- -- 1 bit sign -- 5 bits combination field -- 8 bits exponent continuation -- 50 bits coefficient continuation -- -- Total exponent length 10 bits -- Total coefficient length 54 bits (16 digits) -- -- Elimit = 767 (maximum encoded exponent) -- Emax = 384 (largest exponent value) -- Emin = -383 (smallest exponent value) -- bias = 398 (subtracted from encoded exponent) = -Etiny extended: 1 precision: 16 rounding: half_up maxExponent: 384 minExponent: -383 -- General testcases -- (mostly derived from the Strawman 4 document and examples) dece001 apply #A2300000000003D0 -> -7.50 dece002 apply -7.50 -> #A2300000000003D0 -- Normality dece010 apply 1234567890123456 -> #263934b9c1e28e56 dece011 apply 1234567890123456.0 -> #263934b9c1e28e56 Rounded dece012 apply 1234567890123456.1 -> #263934b9c1e28e56 Rounded Inexact dece013 apply -1234567890123456 -> #a63934b9c1e28e56 dece014 apply -1234567890123456.0 -> #a63934b9c1e28e56 Rounded dece015 apply -1234567890123456.1 -> #a63934b9c1e28e56 Rounded Inexact -- Nmax and similar dece022 apply 9.999999999999999E+384 -> #77fcff3fcff3fcff dece023 apply #77fcff3fcff3fcff -> 9.999999999999999E+384 dece024 apply 1.234567890123456E+384 -> #47fd34b9c1e28e56 dece025 apply #47fd34b9c1e28e56 -> 1.234567890123456E+384 -- fold-downs (more below) dece030 apply 1.23E+384 -> #47fd300000000000 Clamped dece031 apply #47fd300000000000 -> 1.230000000000000E+384 dece032 apply 1E+384 -> #47fc000000000000 Clamped dece033 apply #47fc000000000000 -> 1.000000000000000E+384 -- overflows maxExponent: 999 -- set high so conversion causes the overflow minExponent: -999 dece040 apply 10E+384 -> #7800000000000000 Overflow Rounded Inexact dece041 apply 1.000000000000000E+385 -> #7800000000000000 Overflow Rounded Inexact maxExponent: 384 minExponent: -383 dece051 apply 12345 -> #22380000000049c5 dece052 apply #22380000000049c5 -> 12345 dece053 apply 1234 -> #2238000000000534 dece054 apply #2238000000000534 -> 1234 dece055 apply 123 -> #22380000000000a3 dece056 apply #22380000000000a3 -> 123 dece057 apply 12 -> #2238000000000012 dece058 apply #2238000000000012 -> 12 dece059 apply 1 -> #2238000000000001 dece060 apply #2238000000000001 -> 1 dece061 apply 1.23 -> #22300000000000a3 dece062 apply #22300000000000a3 -> 1.23 dece063 apply 123.45 -> #22300000000049c5 dece064 apply #22300000000049c5 -> 123.45 -- Nmin and below dece071 apply 1E-383 -> #003c000000000001 dece072 apply #003c000000000001 -> 1E-383 dece073 apply 1.000000000000000E-383 -> #0400000000000000 dece074 apply #0400000000000000 -> 1.000000000000000E-383 dece075 apply 1.000000000000001E-383 -> #0400000000000001 dece076 apply #0400000000000001 -> 1.000000000000001E-383 dece077 apply 0.100000000000000E-383 -> #0000800000000000 Subnormal dece078 apply #0000800000000000 -> 1.00000000000000E-384 Subnormal dece079 apply 0.000000000000010E-383 -> #0000000000000010 Subnormal dece080 apply #0000000000000010 -> 1.0E-397 Subnormal dece081 apply 0.00000000000001E-383 -> #0004000000000001 Subnormal dece082 apply #0004000000000001 -> 1E-397 Subnormal dece083 apply 0.000000000000001E-383 -> #0000000000000001 Subnormal dece084 apply #0000000000000001 -> 1E-398 Subnormal -- underflows dece090 apply 1e-398 -> #0000000000000001 Subnormal dece091 apply 1.9e-398 -> #0000000000000002 Subnormal Underflow Inexact Rounded dece092 apply 1.1e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded dece093 apply 1.00000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded dece094 apply 1.00000000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded dece095 apply 1.000000000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded dece096 apply 0.1e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded dece097 apply 0.00000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded dece098 apply 0.00000000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded dece099 apply 0.000000000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded -- Same again, negatives -- Nmax and similar dece122 apply -9.999999999999999E+384 -> #f7fcff3fcff3fcff dece123 apply #f7fcff3fcff3fcff -> -9.999999999999999E+384 dece124 apply -1.234567890123456E+384 -> #c7fd34b9c1e28e56 dece125 apply #c7fd34b9c1e28e56 -> -1.234567890123456E+384 -- fold-downs (more below) dece130 apply -1.23E+384 -> #c7fd300000000000 Clamped dece131 apply #c7fd300000000000 -> -1.230000000000000E+384 dece132 apply -1E+384 -> #c7fc000000000000 Clamped dece133 apply #c7fc000000000000 -> -1.000000000000000E+384 -- overflows maxExponent: 999 -- set high so conversion causes the overflow minExponent: -999 dece140 apply -10E+384 -> #f800000000000000 Overflow Rounded Inexact dece141 apply -1.000000000000000E+385 -> #f800000000000000 Overflow Rounded Inexact maxExponent: 384 minExponent: -383 dece151 apply -12345 -> #a2380000000049c5 dece152 apply #a2380000000049c5 -> -12345 dece153 apply -1234 -> #a238000000000534 dece154 apply #a238000000000534 -> -1234 dece155 apply -123 -> #a2380000000000a3 dece156 apply #a2380000000000a3 -> -123 dece157 apply -12 -> #a238000000000012 dece158 apply #a238000000000012 -> -12 dece159 apply -1 -> #a238000000000001 dece160 apply #a238000000000001 -> -1 dece161 apply -1.23 -> #a2300000000000a3 dece162 apply #a2300000000000a3 -> -1.23 dece163 apply -123.45 -> #a2300000000049c5 dece164 apply #a2300000000049c5 -> -123.45 -- Nmin and below dece171 apply -1E-383 -> #803c000000000001 dece172 apply #803c000000000001 -> -1E-383 dece173 apply -1.000000000000000E-383 -> #8400000000000000 dece174 apply #8400000000000000 -> -1.000000000000000E-383 dece175 apply -1.000000000000001E-383 -> #8400000000000001 dece176 apply #8400000000000001 -> -1.000000000000001E-383 dece177 apply -0.100000000000000E-383 -> #8000800000000000 Subnormal dece178 apply #8000800000000000 -> -1.00000000000000E-384 Subnormal dece179 apply -0.000000000000010E-383 -> #8000000000000010 Subnormal dece180 apply #8000000000000010 -> -1.0E-397 Subnormal dece181 apply -0.00000000000001E-383 -> #8004000000000001 Subnormal dece182 apply #8004000000000001 -> -1E-397 Subnormal dece183 apply -0.000000000000001E-383 -> #8000000000000001 Subnormal dece184 apply #8000000000000001 -> -1E-398 Subnormal -- underflows dece189 apply -1e-398 -> #8000000000000001 Subnormal dece190 apply -1.0e-398 -> #8000000000000001 Subnormal Rounded dece191 apply -1.9e-398 -> #8000000000000002 Subnormal Underflow Inexact Rounded dece192 apply -1.1e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded dece193 apply -1.00000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded dece194 apply -1.00000000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded dece195 apply -1.000000000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded dece196 apply -0.1e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded dece197 apply -0.00000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded dece198 apply -0.00000000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded dece199 apply -0.000000000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded -- zeros dece401 apply 0E-500 -> #0000000000000000 Clamped dece402 apply 0E-400 -> #0000000000000000 Clamped dece403 apply 0E-398 -> #0000000000000000 dece404 apply #0000000000000000 -> 0E-398 dece405 apply 0.000000000000000E-383 -> #0000000000000000 dece406 apply #0000000000000000 -> 0E-398 dece407 apply 0E-2 -> #2230000000000000 dece408 apply #2230000000000000 -> 0.00 dece409 apply 0 -> #2238000000000000 dece410 apply #2238000000000000 -> 0 dece411 apply 0E+3 -> #2244000000000000 dece412 apply #2244000000000000 -> 0E+3 dece413 apply 0E+369 -> #43fc000000000000 dece414 apply #43fc000000000000 -> 0E+369 -- clamped zeros... dece415 apply 0E+370 -> #43fc000000000000 Clamped dece416 apply #43fc000000000000 -> 0E+369 dece417 apply 0E+384 -> #43fc000000000000 Clamped dece418 apply #43fc000000000000 -> 0E+369 dece419 apply 0E+400 -> #43fc000000000000 Clamped dece420 apply #43fc000000000000 -> 0E+369 dece421 apply 0E+500 -> #43fc000000000000 Clamped dece422 apply #43fc000000000000 -> 0E+369 -- negative zeros dece431 apply -0E-400 -> #8000000000000000 Clamped dece432 apply -0E-400 -> #8000000000000000 Clamped dece433 apply -0E-398 -> #8000000000000000 dece434 apply #8000000000000000 -> -0E-398 dece435 apply -0.000000000000000E-383 -> #8000000000000000 dece436 apply #8000000000000000 -> -0E-398 dece437 apply -0E-2 -> #a230000000000000 dece438 apply #a230000000000000 -> -0.00 dece439 apply -0 -> #a238000000000000 dece440 apply #a238000000000000 -> -0 dece441 apply -0E+3 -> #a244000000000000 dece442 apply #a244000000000000 -> -0E+3 dece443 apply -0E+369 -> #c3fc000000000000 dece444 apply #c3fc000000000000 -> -0E+369 -- clamped zeros... dece445 apply -0E+370 -> #c3fc000000000000 Clamped dece446 apply #c3fc000000000000 -> -0E+369 dece447 apply -0E+384 -> #c3fc000000000000 Clamped dece448 apply #c3fc000000000000 -> -0E+369 dece449 apply -0E+400 -> #c3fc000000000000 Clamped dece450 apply #c3fc000000000000 -> -0E+369 dece451 apply -0E+500 -> #c3fc000000000000 Clamped dece452 apply #c3fc000000000000 -> -0E+369 -- Specials dece501 apply #7878787878787878 -> #7800000000000000 dece502 apply #7800000000000000 -> Infinity dece503 apply #7979797979797979 -> #7800000000000000 dece504 apply #7900000000000000 -> Infinity dece505 apply #7a7a7a7a7a7a7a7a -> #7800000000000000 dece506 apply #7a00000000000000 -> Infinity dece507 apply #7b7b7b7b7b7b7b7b -> #7800000000000000 dece508 apply #7b00000000000000 -> Infinity dece509 apply #7c7c7c7c7c7c7c7c -> #7dffffffffffffff dece510 apply #7c00000000000000 -> NaN dece511 apply #7d7d7d7d7d7d7d7d -> #7dffffffffffffff dece512 apply #7d00000000000000 -> NaN dece513 apply #7e7e7e7e7e7e7e7e -> #7fffffffffffffff dece514 apply #7e00000000000000 -> sNaN dece515 apply #7f7f7f7f7f7f7f7f -> #7fffffffffffffff dece516 apply #7f00000000000000 -> sNaN dece521 apply #f878787878787878 -> #f800000000000000 dece522 apply #f800000000000000 -> -Infinity dece523 apply #f979797979797979 -> #f800000000000000 dece524 apply #f900000000000000 -> -Infinity dece525 apply #fa7a7a7a7a7a7a7a -> #f800000000000000 dece526 apply #fa00000000000000 -> -Infinity dece527 apply #fb7b7b7b7b7b7b7b -> #f800000000000000 dece528 apply #fb00000000000000 -> -Infinity dece529 apply #fc7c7c7c7c7c7c7c -> #7dffffffffffffff dece530 apply #fc00000000000000 -> NaN dece531 apply #fd7d7d7d7d7d7d7d -> #7dffffffffffffff dece532 apply #fd00000000000000 -> NaN dece533 apply #fe7e7e7e7e7e7e7e -> #7fffffffffffffff dece534 apply #fe00000000000000 -> sNaN dece535 apply #ff7f7f7f7f7f7f7f -> #7fffffffffffffff dece536 apply #ff00000000000000 -> sNaN -- fold-down full sequence dece601 apply 1E+384 -> #47fc000000000000 Clamped dece602 apply #47fc000000000000 -> 1.000000000000000E+384 dece603 apply 1E+383 -> #43fc800000000000 Clamped dece604 apply #43fc800000000000 -> 1.00000000000000E+383 dece605 apply 1E+382 -> #43fc100000000000 Clamped dece606 apply #43fc100000000000 -> 1.0000000000000E+382 dece607 apply 1E+381 -> #43fc010000000000 Clamped dece608 apply #43fc010000000000 -> 1.000000000000E+381 dece609 apply 1E+380 -> #43fc002000000000 Clamped dece610 apply #43fc002000000000 -> 1.00000000000E+380 dece611 apply 1E+379 -> #43fc000400000000 Clamped dece612 apply #43fc000400000000 -> 1.0000000000E+379 dece613 apply 1E+378 -> #43fc000040000000 Clamped dece614 apply #43fc000040000000 -> 1.000000000E+378 dece615 apply 1E+377 -> #43fc000008000000 Clamped dece616 apply #43fc000008000000 -> 1.00000000E+377 dece617 apply 1E+376 -> #43fc000001000000 Clamped dece618 apply #43fc000001000000 -> 1.0000000E+376 dece619 apply 1E+375 -> #43fc000000100000 Clamped dece620 apply #43fc000000100000 -> 1.000000E+375 dece621 apply 1E+374 -> #43fc000000020000 Clamped dece622 apply #43fc000000020000 -> 1.00000E+374 dece623 apply 1E+373 -> #43fc000000004000 Clamped dece624 apply #43fc000000004000 -> 1.0000E+373 dece625 apply 1E+372 -> #43fc000000000400 Clamped dece626 apply #43fc000000000400 -> 1.000E+372 dece627 apply 1E+371 -> #43fc000000000080 Clamped dece628 apply #43fc000000000080 -> 1.00E+371 dece629 apply 1E+370 -> #43fc000000000010 Clamped dece630 apply #43fc000000000010 -> 1.0E+370 dece631 apply 1E+369 -> #43fc000000000001 dece632 apply #43fc000000000001 -> 1E+369 dece633 apply 1E+368 -> #43f8000000000001 dece634 apply #43f8000000000001 -> 1E+368 -- same with 9s dece641 apply 9E+384 -> #77fc000000000000 Clamped dece642 apply #77fc000000000000 -> 9.000000000000000E+384 dece643 apply 9E+383 -> #43fc8c0000000000 Clamped dece644 apply #43fc8c0000000000 -> 9.00000000000000E+383 dece645 apply 9E+382 -> #43fc1a0000000000 Clamped dece646 apply #43fc1a0000000000 -> 9.0000000000000E+382 dece647 apply 9E+381 -> #43fc090000000000 Clamped dece648 apply #43fc090000000000 -> 9.000000000000E+381 dece649 apply 9E+380 -> #43fc002300000000 Clamped dece650 apply #43fc002300000000 -> 9.00000000000E+380 dece651 apply 9E+379 -> #43fc000680000000 Clamped dece652 apply #43fc000680000000 -> 9.0000000000E+379 dece653 apply 9E+378 -> #43fc000240000000 Clamped dece654 apply #43fc000240000000 -> 9.000000000E+378 dece655 apply 9E+377 -> #43fc000008c00000 Clamped dece656 apply #43fc000008c00000 -> 9.00000000E+377 dece657 apply 9E+376 -> #43fc000001a00000 Clamped dece658 apply #43fc000001a00000 -> 9.0000000E+376 dece659 apply 9E+375 -> #43fc000000900000 Clamped dece660 apply #43fc000000900000 -> 9.000000E+375 dece661 apply 9E+374 -> #43fc000000023000 Clamped dece662 apply #43fc000000023000 -> 9.00000E+374 dece663 apply 9E+373 -> #43fc000000006800 Clamped dece664 apply #43fc000000006800 -> 9.0000E+373 dece665 apply 9E+372 -> #43fc000000002400 Clamped dece666 apply #43fc000000002400 -> 9.000E+372 dece667 apply 9E+371 -> #43fc00000000008c Clamped dece668 apply #43fc00000000008c -> 9.00E+371 dece669 apply 9E+370 -> #43fc00000000001a Clamped dece670 apply #43fc00000000001a -> 9.0E+370 dece671 apply 9E+369 -> #43fc000000000009 dece672 apply #43fc000000000009 -> 9E+369 dece673 apply 9E+368 -> #43f8000000000009 dece674 apply #43f8000000000009 -> 9E+368 -- Selected DPD codes dece700 apply #2238000000000000 -> 0 dece701 apply #2238000000000009 -> 9 dece702 apply #2238000000000010 -> 10 dece703 apply #2238000000000019 -> 19 dece704 apply #2238000000000020 -> 20 dece705 apply #2238000000000029 -> 29 dece706 apply #2238000000000030 -> 30 dece707 apply #2238000000000039 -> 39 dece708 apply #2238000000000040 -> 40 dece709 apply #2238000000000049 -> 49 dece710 apply #2238000000000050 -> 50 dece711 apply #2238000000000059 -> 59 dece712 apply #2238000000000060 -> 60 dece713 apply #2238000000000069 -> 69 dece714 apply #2238000000000070 -> 70 dece715 apply #2238000000000071 -> 71 dece716 apply #2238000000000072 -> 72 dece717 apply #2238000000000073 -> 73 dece718 apply #2238000000000074 -> 74 dece719 apply #2238000000000075 -> 75 dece720 apply #2238000000000076 -> 76 dece721 apply #2238000000000077 -> 77 dece722 apply #2238000000000078 -> 78 dece723 apply #2238000000000079 -> 79 dece730 apply #223800000000029e -> 994 dece731 apply #223800000000029f -> 995 dece732 apply #22380000000002a0 -> 520 dece733 apply #22380000000002a1 -> 521 -- DPD: one of each of the huffman groups dece740 apply #22380000000003f7 -> 777 dece741 apply #22380000000003f8 -> 778 dece742 apply #22380000000003eb -> 787 dece743 apply #223800000000037d -> 877 dece744 apply #223800000000039f -> 997 dece745 apply #22380000000003bf -> 979 dece746 apply #22380000000003df -> 799 dece747 apply #223800000000006e -> 888 -- DPD all-highs cases (includes the 24 redundant codes) dece750 apply #223800000000006e -> 888 dece751 apply #223800000000016e -> 888 dece752 apply #223800000000026e -> 888 dece753 apply #223800000000036e -> 888 dece754 apply #223800000000006f -> 889 dece755 apply #223800000000016f -> 889 dece756 apply #223800000000026f -> 889 dece757 apply #223800000000036f -> 889 dece760 apply #223800000000007e -> 898 dece761 apply #223800000000017e -> 898 dece762 apply #223800000000027e -> 898 dece763 apply #223800000000037e -> 898 dece764 apply #223800000000007f -> 899 dece765 apply #223800000000017f -> 899 dece766 apply #223800000000027f -> 899 dece767 apply #223800000000037f -> 899 dece770 apply #22380000000000ee -> 988 dece771 apply #22380000000001ee -> 988 dece772 apply #22380000000002ee -> 988 dece773 apply #22380000000003ee -> 988 dece774 apply #22380000000000ef -> 989 dece775 apply #22380000000001ef -> 989 dece776 apply #22380000000002ef -> 989 dece777 apply #22380000000003ef -> 989 dece780 apply #22380000000000fe -> 998 dece781 apply #22380000000001fe -> 998 dece782 apply #22380000000002fe -> 998 dece783 apply #22380000000003fe -> 998 dece784 apply #22380000000000ff -> 999 dece785 apply #22380000000001ff -> 999 dece786 apply #22380000000002ff -> 999 dece787 apply #22380000000003ff -> 999 --- NEW FILE: divide.decTest --- ------------------------------------------------------------------------ -- divide.decTest -- decimal division -- -- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 extended: 1 precision: 9 rounding: half_up maxExponent: 384 minexponent: -383 -- sanity checks divx001 divide 1 1 -> 1 divx002 divide 2 1 -> 2 divx003 divide 1 2 -> 0.5 divx004 divide 2 2 -> 1 divx005 divide 0 1 -> 0 divx006 divide 0 2 -> 0 divx007 divide 1 3 -> 0.333333333 Inexact Rounded divx008 divide 2 3 -> 0.666666667 Inexact Rounded divx009 divide 3 3 -> 1 divx010 divide 2.4 1 -> 2.4 divx011 divide 2.4 -1 -> -2.4 divx012 divide -2.4 1 -> -2.4 divx013 divide -2.4 -1 -> 2.4 divx014 divide 2.40 1 -> 2.40 divx015 divide 2.400 1 -> 2.400 divx016 divide 2.4 2 -> 1.2 divx017 divide 2.400 2 -> 1.200 divx018 divide 2. 2 -> 1 divx019 divide 20 20 -> 1 divx020 divide 187 187 -> 1 divx021 divide 5 2 -> 2.5 divx022 divide 5 2.0 -> 2.5 divx023 divide 5 2.000 -> 2.5 divx024 divide 5 0.20 -> 25 divx025 divide 5 0.200 -> 25 divx026 divide 10 1 -> 10 divx027 divide 100 1 -> 100 divx028 divide 1000 1 -> 1000 divx029 divide 1000 100 -> 10 divx030 divide 1 2 -> 0.5 divx031 divide 1 4 -> 0.25 divx032 divide 1 8 -> 0.125 divx033 divide 1 16 -> 0.0625 divx034 divide 1 32 -> 0.03125 divx035 divide 1 64 -> 0.015625 divx040 divide 1 -2 -> -0.5 divx041 divide 1 -4 -> -0.25 divx042 divide 1 -8 -> -0.125 divx043 divide 1 -16 -> -0.0625 divx044 divide 1 -32 -> -0.03125 divx045 divide 1 -64 -> -0.015625 divx050 divide -1 2 -> -0.5 divx051 divide -1 4 -> -0.25 divx052 divide -1 8 -> -0.125 divx053 divide -1 16 -> -0.0625 divx054 divide -1 32 -> -0.03125 divx055 divide -1 64 -> -0.015625 divx060 divide -1 -2 -> 0.5 divx061 divide -1 -4 -> 0.25 divx062 divide -1 -8 -> 0.125 divx063 divide -1 -16 -> 0.0625 divx064 divide -1 -32 -> 0.03125 divx065 divide -1 -64 -> 0.015625 divx070 divide 999999999 1 -> 999999999 divx071 divide 999999999.4 1 -> 999999999 Inexact Rounded divx072 divide 999999999.5 1 -> 1.00000000E+9 Inexact Rounded divx073 divide 999999999.9 1 -> 1.00000000E+9 Inexact Rounded divx074 divide 999999999.999 1 -> 1.00000000E+9 Inexact Rounded precision: 6 divx080 divide 999999999 1 -> 1.00000E+9 Inexact Rounded divx081 divide 99999999 1 -> 1.00000E+8 Inexact Rounded divx082 divide 9999999 1 -> 1.00000E+7 Inexact Rounded divx083 divide 999999 1 -> 999999 divx084 divide 99999 1 -> 99999 divx085 divide 9999 1 -> 9999 divx086 divide 999 1 -> 999 divx087 divide 99 1 -> 99 divx088 divide 9 1 -> 9 precision: 9 divx090 divide 0. 1 -> 0 divx091 divide .0 1 -> 0.0 divx092 divide 0.00 1 -> 0.00 divx093 divide 0.00E+9 1 -> 0E+7 divx094 divide 0.0000E-50 1 -> 0E-54 divx095 divide 1 1E-8 -> 1E+8 divx096 divide 1 1E-9 -> 1E+9 divx097 divide 1 1E-10 -> 1E+10 divx098 divide 1 1E-11 -> 1E+11 divx099 divide 1 1E-12 -> 1E+12 divx100 divide 1 1 -> 1 divx101 divide 1 2 -> 0.5 divx102 divide 1 3 -> 0.333333333 Inexact Rounded divx103 divide 1 4 -> 0.25 divx104 divide 1 5 -> 0.2 divx105 divide 1 6 -> 0.166666667 Inexact Rounded divx106 divide 1 7 -> 0.142857143 Inexact Rounded divx107 divide 1 8 -> 0.125 divx108 divide 1 9 -> 0.111111111 Inexact Rounded divx109 divide 1 10 -> 0.1 divx110 divide 1 1 -> 1 divx111 divide 2 1 -> 2 divx112 divide 3 1 -> 3 divx113 divide 4 1 -> 4 divx114 divide 5 1 -> 5 divx115 divide 6 1 -> 6 divx116 divide 7 1 -> 7 divx117 divide 8 1 -> 8 divx118 divide 9 1 -> 9 divx119 divide 10 1 -> 10 divx120 divide 3E+1 0.001 -> 3E+4 divx121 divide 2.200 2 -> 1.100 divx130 divide 12345 4.999 -> 2469.49390 Inexact Rounded divx131 divide 12345 4.99 -> 2473.94790 Inexact Rounded divx132 divide 12345 4.9 -> 2519.38776 Inexact Rounded divx133 divide 12345 5 -> 2469 divx134 divide 12345 5.1 -> 2420.58824 Inexact Rounded divx135 divide 12345 5.01 -> 2464.07186 Inexact Rounded divx136 divide 12345 5.001 -> 2468.50630 Inexact Rounded precision: 9 maxexponent: 999999999 minexponent: -999999999 -- test possibly imprecise results divx220 divide 391 597 -> 0.654941374 Inexact Rounded divx221 divide 391 -597 -> -0.654941374 Inexact Rounded divx222 divide -391 597 -> -0.654941374 Inexact Rounded divx223 divide -391 -597 -> 0.654941374 Inexact Rounded -- test some cases that are close to exponent overflow maxexponent: 999999999 minexponent: -999999999 divx270 divide 1 1e999999999 -> 1E-999999999 divx271 divide 1 0.9e999999999 -> 1.11111111E-999999999 Inexact Rounded divx272 divide 1 0.99e999999999 -> 1.01010101E-999999999 Inexact Rounded divx273 divide 1 0.999999999e999999999 -> 1.00000000E-999999999 Inexact Rounded divx274 divide 9e999999999 1 -> 9E+999999999 divx275 divide 9.9e999999999 1 -> 9.9E+999999999 divx276 divide 9.99e999999999 1 -> 9.99E+999999999 divx277 divide 9.99999999e999999999 1 -> 9.99999999E+999999999 divx280 divide 0.1 9e-999999999 -> 1.11111111E+999999997 Inexact Rounded divx281 divide 0.1 99e-999999999 -> 1.01010101E+999999996 Inexact Rounded divx282 divide 0.1 999e-999999999 -> 1.00100100E+999999995 Inexact Rounded divx283 divide 0.1 9e-999999998 -> 1.11111111E+999999996 Inexact Rounded divx284 divide 0.1 99e-999999998 -> 1.01010101E+999999995 Inexact Rounded divx285 divide 0.1 999e-999999998 -> 1.00100100E+999999994 Inexact Rounded divx286 divide 0.1 999e-999999997 -> 1.00100100E+999999993 Inexact Rounded divx287 divide 0.1 9999e-999999997 -> 1.00010001E+999999992 Inexact Rounded divx288 divide 0.1 99999e-999999997 -> 1.00001000E+999999991 Inexact Rounded -- Divide into 0 tests divx301 divide 0 7 -> 0 divx302 divide 0 7E-5 -> 0E+5 divx303 divide 0 7E-1 -> 0E+1 divx304 divide 0 7E+1 -> 0.0 divx305 divide 0 7E+5 -> 0.00000 divx306 divide 0 7E+6 -> 0.000000 divx307 divide 0 7E+7 -> 0E-7 divx308 divide 0 70E-5 -> 0E+5 divx309 divide 0 70E-1 -> 0E+1 divx310 divide 0 70E+0 -> 0 divx311 divide 0 70E+1 -> 0.0 divx312 divide 0 70E+5 -> 0.00000 divx313 divide 0 70E+6 -> 0.000000 divx314 divide 0 70E+7 -> 0E-7 divx315 divide 0 700E-5 -> 0E+5 divx316 divide 0 700E-1 -> 0E+1 divx317 divide 0 700E+0 -> 0 divx318 divide 0 700E+1 -> 0.0 divx319 divide 0 700E+5 -> 0.00000 divx320 divide 0 700E+6 -> 0.000000 divx321 divide 0 700E+7 -> 0E-7 divx322 divide 0 700E+77 -> 0E-77 divx331 divide 0E-3 7E-5 -> 0E+2 divx332 divide 0E-3 7E-1 -> 0.00 divx333 divide 0E-3 7E+1 -> 0.0000 divx334 divide 0E-3 7E+5 -> 0E-8 divx335 divide 0E-1 7E-5 -> 0E+4 divx336 divide 0E-1 7E-1 -> 0 divx337 divide 0E-1 7E+1 -> 0.00 divx338 divide 0E-1 7E+5 -> 0.000000 divx339 divide 0E+1 7E-5 -> 0E+6 divx340 divide 0E+1 7E-1 -> 0E+2 divx341 divide 0E+1 7E+1 -> 0 divx342 divide 0E+1 7E+5 -> 0.0000 divx343 divide 0E+3 7E-5 -> 0E+8 divx344 divide 0E+3 7E-1 -> 0E+4 divx345 divide 0E+3 7E+1 -> 0E+2 divx346 divide 0E+3 7E+5 -> 0.00 maxexponent: 92 minexponent: -92 precision: 7 divx351 divide 0E-92 7E-1 -> 0E-91 divx352 divide 0E-92 7E+1 -> 0E-93 divx353 divide 0E-92 7E+5 -> 0E-97 divx354 divide 0E-92 7E+6 -> 0E-98 divx355 divide 0E-92 7E+7 -> 0E-98 Clamped divx356 divide 0E-92 777E-1 -> 0E-91 divx357 divide 0E-92 777E+1 -> 0E-93 divx358 divide 0E-92 777E+3 -> 0E-95 divx359 divide 0E-92 777E+4 -> 0E-96 divx360 divide 0E-92 777E+5 -> 0E-97 divx361 divide 0E-92 777E+6 -> 0E-98 divx362 divide 0E-92 777E+7 -> 0E-98 Clamped divx363 divide 0E-92 7E+92 -> 0E-98 Clamped divx371 divide 0E-92 700E-1 -> 0E-91 divx372 divide 0E-92 700E+1 -> 0E-93 divx373 divide 0E-92 700E+3 -> 0E-95 divx374 divide 0E-92 700E+4 -> 0E-96 divx375 divide 0E-92 700E+5 -> 0E-97 divx376 divide 0E-92 700E+6 -> 0E-98 divx377 divide 0E-92 700E+7 -> 0E-98 Clamped divx381 divide 0E+92 7E+1 -> 0E+91 divx382 divide 0E+92 7E+0 -> 0E+92 divx383 divide 0E+92 7E-1 -> 0E+92 Clamped divx384 divide 0E+90 777E+1 -> 0E+89 divx385 divide 0E+90 777E-1 -> 0E+91 divx386 divide 0E+90 777E-2 -> 0E+92 divx387 divide 0E+90 777E-3 -> 0E+92 Clamped divx388 divide 0E+90 777E-4 -> 0E+92 Clamped divx391 divide 0E+90 700E+1 -> 0E+89 divx392 divide 0E+90 700E-1 -> 0E+91 divx393 divide 0E+90 700E-2 -> 0E+92 divx394 divide 0E+90 700E-3 -> 0E+92 Clamped divx395 divide 0E+90 700E-4 -> 0E+92 Clamped -- input rounding checks maxexponent: 999 minexponent: -999 precision: 9 divx401 divide 12345678000 1 -> 1.23456780E+10 Rounded divx402 divide 1 12345678000 -> 8.10000066E-11 Inexact Rounded divx403 divide 1234567800 1 -> 1.23456780E+9 Rounded divx404 divide 1 1234567800 -> 8.10000066E-10 Inexact Rounded divx405 divide 1234567890 1 -> 1.23456789E+9 Rounded divx406 divide 1 1234567890 -> 8.10000007E-10 Inexact Rounded divx407 divide 1234567891 1 -> 1.23456789E+9 Inexact Rounded divx408 divide 1 1234567891 -> 8.10000007E-10 Inexact Rounded divx409 divide 12345678901 1 -> 1.23456789E+10 Inexact Rounded divx410 divide 1 12345678901 -> 8.10000007E-11 Inexact Rounded divx411 divide 1234567896 1 -> 1.23456790E+9 Inexact Rounded divx412 divide 1 1234567896 -> 8.10000003E-10 Inexact Rounded divx413 divide 1 1234567897 -> 8.10000003E-10 Inexact Rounded divx414 divide 1 1234567898 -> 8.10000002E-10 Inexact Rounded divx415 divide 1 1234567899 -> 8.10000001E-10 Inexact Rounded divx416 divide 1 1234567900 -> 8.10000001E-10 Inexact Rounded divx417 divide 1 1234567901 -> 8.10000000E-10 Inexact Rounded divx418 divide 1 1234567902 -> 8.09999999E-10 Inexact Rounded -- some longies divx421 divide 1234567896.000000000000 1 -> 1.23456790E+9 Inexact Rounded divx422 divide 1 1234567896.000000000000 -> 8.10000003E-10 Inexact Rounded divx423 divide 1234567896.000000000001 1 -> 1.23456790E+9 Inexact Rounded divx424 divide 1 1234567896.000000000001 -> 8.10000003E-10 Inexact Rounded divx425 divide 1234567896.000000000000000000000000000000000000000009 1 -> 1.23456790E+9 Inexact Rounded divx426 divide 1 1234567896.000000000000000000000000000000000000000009 -> 8.10000003E-10 Inexact Rounded divx427 divide 1234567897.900010000000000000000000000000000000000009 1 -> 1.23456790E+9 Inexact Rounded divx428 divide 1 1234567897.900010000000000000000000000000000000000009 -> 8.10000002E-10 Inexact Rounded precision: 15 -- still checking... divx441 divide 12345678000 1 -> 12345678000 divx442 divide 1 12345678000 -> 8.10000066420005E-11 Inexact Rounded divx443 divide 1234567800 1 -> 1234567800 divx444 divide 1 1234567800 -> 8.10000066420005E-10 Inexact Rounded divx445 divide 1234567890 1 -> 1234567890 divx446 divide 1 1234567890 -> 8.10000007371000E-10 Inexact Rounded divx447 divide 1234567891 1 -> 1234567891 divx448 divide 1 1234567891 -> 8.10000006714900E-10 Inexact Rounded divx449 divide 12345678901 1 -> 12345678901 divx450 divide 1 12345678901 -> 8.10000007305390E-11 Inexact Rounded divx451 divide 1234567896 1 -> 1234567896 divx452 divide 1 1234567896 -> 8.10000003434400E-10 Inexact Rounded -- high-lows divx453 divide 1e+1 1 -> 1E+1 divx454 divide 1e+1 1.0 -> 1E+1 divx455 divide 1e+1 1.00 -> 1E+1 divx456 divide 1e+2 2 -> 5E+1 divx457 divide 1e+2 2.0 -> 5E+1 divx458 divide 1e+2 2.00 -> 5E+1 -- some from IEEE discussions divx460 divide 3e0 2e0 -> 1.5 divx461 divide 30e-1 2e0 -> 1.5 divx462 divide 300e-2 2e0 -> 1.50 divx464 divide 3000e-3 2e0 -> 1.500 divx465 divide 3e0 20e-1 -> 1.5 divx466 divide 30e-1 20e-1 -> 1.5 divx467 divide 300e-2 20e-1 -> 1.5 divx468 divide 3000e-3 20e-1 -> 1.50 divx469 divide 3e0 200e-2 -> 1.5 divx470 divide 30e-1 200e-2 -> 1.5 divx471 divide 300e-2 200e-2 -> 1.5 divx472 divide 3000e-3 200e-2 -> 1.5 divx473 divide 3e0 2000e-3 -> 1.5 divx474 divide 30e-1 2000e-3 -> 1.5 divx475 divide 300e-2 2000e-3 -> 1.5 divx476 divide 3000e-3 2000e-3 -> 1.5 -- some reciprocals divx480 divide 1 1.0E+33 -> 1E-33 divx481 divide 1 10E+33 -> 1E-34 divx482 divide 1 1.0E-33 -> 1E+33 divx483 divide 1 10E-33 -> 1E+32 -- RMS discussion table maxexponent: 96 minexponent: -95 precision: 7 divx484 divide 0e5 1e3 -> 0E+2 divx485 divide 0e5 2e3 -> 0E+2 divx486 divide 0e5 10e2 -> 0E+3 divx487 divide 0e5 20e2 -> 0E+3 divx488 divide 0e5 100e1 -> 0E+4 divx489 divide 0e5 200e1 -> 0E+4 divx491 divide 1e5 1e3 -> 1E+2 divx492 divide 1e5 2e3 -> 5E+1 divx493 divide 1e5 10e2 -> 1E+2 divx494 divide 1e5 20e2 -> 5E+1 divx495 divide 1e5 100e1 -> 1E+2 divx496 divide 1e5 200e1 -> 5E+1 -- tryzeros cases precision: 7 rounding: half_up maxExponent: 92 minexponent: -92 divx497 divide 0E+86 1000E-13 -> 0E+92 Clamped divx498 divide 0E-98 1000E+13 -> 0E-98 Clamped precision: 9 rounding: half_up maxExponent: 999 minexponent: -999 -- focus on trailing zeros issues precision: 9 divx500 divide 1 9.9 -> 0.101010101 Inexact Rounded precision: 8 divx501 divide 1 9.9 -> 0.10101010 Inexact Rounded precision: 7 divx502 divide 1 9.9 -> 0.1010101 Inexact Rounded precision: 6 divx503 divide 1 9.9 -> 0.101010 Inexact Rounded precision: 9 divx511 divide 1 2 -> 0.5 divx512 divide 1.0 2 -> 0.5 divx513 divide 1.00 2 -> 0.50 divx514 divide 1.000 2 -> 0.500 divx515 divide 1.0000 2 -> 0.5000 divx516 divide 1.00000 2 -> 0.50000 divx517 divide 1.000000 2 -> 0.500000 divx518 divide 1.0000000 2 -> 0.5000000 divx519 divide 1.00 2.00 -> 0.5 divx521 divide 2 1 -> 2 divx522 divide 2 1.0 -> 2 divx523 divide 2 1.00 -> 2 divx524 divide 2 1.000 -> 2 divx525 divide 2 1.0000 -> 2 divx526 divide 2 1.00000 -> 2 divx527 divide 2 1.000000 -> 2 divx528 divide 2 1.0000000 -> 2 divx529 divide 2.00 1.00 -> 2 divx530 divide 2.40 2 -> 1.20 divx531 divide 2.40 4 -> 0.60 divx532 divide 2.40 10 -> 0.24 divx533 divide 2.40 2.0 -> 1.2 divx534 divide 2.40 4.0 -> 0.6 divx535 divide 2.40 10.0 -> 0.24 divx536 divide 2.40 2.00 -> 1.2 divx537 divide 2.40 4.00 -> 0.6 divx538 divide 2.40 10.00 -> 0.24 divx539 divide 0.9 0.1 -> 9 divx540 divide 0.9 0.01 -> 9E+1 divx541 divide 0.9 0.001 -> 9E+2 divx542 divide 5 2 -> 2.5 divx543 divide 5 2.0 -> 2.5 divx544 divide 5 2.00 -> 2.5 divx545 divide 5 20 -> 0.25 divx546 divide 5 20.0 -> 0.25 divx547 divide 2.400 2 -> 1.200 divx548 divide 2.400 2.0 -> 1.20 divx549 divide 2.400 2.400 -> 1 divx550 divide 240 1 -> 240 divx551 divide 240 10 -> 24 divx552 divide 240 100 -> 2.4 divx553 divide 240 1000 -> 0.24 divx554 divide 2400 1 -> 2400 divx555 divide 2400 10 -> 240 divx556 divide 2400 100 -> 24 divx557 divide 2400 1000 -> 2.4 -- +ve exponent precision: 5 divx570 divide 2.4E+6 2 -> 1.2E+6 divx571 divide 2.40E+6 2 -> 1.20E+6 divx572 divide 2.400E+6 2 -> 1.200E+6 divx573 divide 2.4000E+6 2 -> 1.2000E+6 divx574 divide 24E+5 2 -> 1.2E+6 divx575 divide 240E+4 2 -> 1.20E+6 divx576 divide 2400E+3 2 -> 1.200E+6 divx577 divide 24000E+2 2 -> 1.2000E+6 precision: 6 divx580 divide 2.4E+6 2 -> 1.2E+6 divx581 divide 2.40E+6 2 -> 1.20E+6 divx582 divide 2.400E+6 2 -> 1.200E+6 divx583 divide 2.4000E+6 2 -> 1.2000E+6 divx584 divide 24E+5 2 -> 1.2E+6 divx585 divide 240E+4 2 -> 1.20E+6 divx586 divide 2400E+3 2 -> 1.200E+6 divx587 divide 24000E+2 2 -> 1.2000E+6 precision: 7 divx590 divide 2.4E+6 2 -> 1.2E+6 divx591 divide 2.40E+6 2 -> 1.20E+6 divx592 divide 2.400E+6 2 -> 1.200E+6 divx593 divide 2.4000E+6 2 -> 1.2000E+6 divx594 divide 24E+5 2 -> 1.2E+6 divx595 divide 240E+4 2 -> 1.20E+6 divx596 divide 2400E+3 2 -> 1.200E+6 divx597 divide 24000E+2 2 -> 1.2000E+6 precision: 9 divx600 divide 2.4E+9 2 -> 1.2E+9 divx601 divide 2.40E+9 2 -> 1.20E+9 divx602 divide 2.400E+9 2 -> 1.200E+9 divx603 divide 2.4000E+9 2 -> 1.2000E+9 divx604 divide 24E+8 2 -> 1.2E+9 divx605 divide 240E+7 2 -> 1.20E+9 divx606 divide 2400E+6 2 -> 1.200E+9 divx607 divide 24000E+5 2 -> 1.2000E+9 -- long operand triangle precision: 33 divx610 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.8131097703792 Inexact Rounded precision: 32 divx611 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.813109770379 Inexact Rounded precision: 31 divx612 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.81310977038 Inexact Rounded precision: 30 divx613 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.8131097704 Inexact Rounded precision: 29 divx614 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.813109770 Inexact Rounded precision: 28 divx615 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.81310977 Inexact Rounded precision: 27 divx616 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.8131098 Inexact Rounded precision: 26 divx617 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.813110 Inexact Rounded precision: 25 divx618 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.81311 Inexact Rounded precision: 24 divx619 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.8131 Inexact Rounded precision: 23 divx620 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.813 Inexact Rounded precision: 22 divx621 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.81 Inexact Rounded precision: 21 divx622 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817797.8 Inexact Rounded precision: 20 divx623 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -41011408883796817798 Inexact Rounded precision: 19 divx624 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.101140888379681780E+19 Inexact Rounded precision: 18 divx625 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.10114088837968178E+19 Inexact Rounded precision: 17 divx626 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.1011408883796818E+19 Inexact Rounded precision: 16 divx627 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.101140888379682E+19 Inexact Rounded precision: 15 divx628 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.10114088837968E+19 Inexact Rounded precision: 14 divx629 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.1011408883797E+19 Inexact Rounded precision: 13 divx630 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.101140888380E+19 Inexact Rounded precision: 12 divx631 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.10114088838E+19 Inexact Rounded precision: 11 divx632 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.1011408884E+19 Inexact Rounded precision: 10 divx633 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.101140888E+19 Inexact Rounded precision: 9 divx634 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.10114089E+19 Inexact Rounded precision: 8 divx635 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.1011409E+19 Inexact Rounded precision: 7 divx636 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.101141E+19 Inexact Rounded precision: 6 divx637 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.10114E+19 Inexact Rounded precision: 5 divx638 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.1011E+19 Inexact Rounded precision: 4 divx639 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.101E+19 Inexact Rounded precision: 3 divx640 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.10E+19 Inexact Rounded precision: 2 divx641 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4.1E+19 Inexact Rounded precision: 1 divx642 divide -3374988581607586061255542201048 82293895124.90045271504836568681 -> -4E+19 Inexact Rounded -- more zeros, etc. precision: 16 rounding: half_up maxExponent: 384 minExponent: -383 divx731 divide 5.00 1E-3 -> 5.00E+3 divx732 divide 00.00 0.000 -> NaN Division_undefined divx733 divide 00.00 0E-3 -> NaN Division_undefined divx734 divide 0 -0 -> NaN Division_undefined divx735 divide -0 0 -> NaN Division_undefined divx736 divide -0 -0 -> NaN Division_undefined divx741 divide 0 -1 -> -0 divx742 divide -0 -1 -> 0 divx743 divide 0 1 -> 0 divx744 divide -0 1 -> -0 divx745 divide -1 0 -> -Infinity Division_by_zero divx746 divide -1 -0 -> Infinity Division_by_zero divx747 divide 1 0 -> Infinity Division_by_zero divx748 divide 1 -0 -> -Infinity Division_by_zero divx751 divide 0.0 -1 -> -0.0 divx752 divide -0.0 -1 -> 0.0 divx753 divide 0.0 1 -> 0.0 divx754 divide -0.0 1 -> -0.0 divx755 divide -1.0 0 -> -Infinity Division_by_zero divx756 divide -1.0 -0 -> Infinity Division_by_zero divx757 divide 1.0 0 -> Infinity Division_by_zero divx758 divide 1.0 -0 -> -Infinity Division_by_zero divx761 divide 0 -1.0 -> -0E+1 divx762 divide -0 -1.0 -> 0E+1 divx763 divide 0 1.0 -> 0E+1 divx764 divide -0 1.0 -> -0E+1 divx765 divide -1 0.0 -> -Infinity Division_by_zero divx766 divide -1 -0.0 -> Infinity Division_by_zero divx767 divide 1 0.0 -> Infinity Division_by_zero divx768 divide 1 -0.0 -> -Infinity Division_by_zero divx771 divide 0.0 -1.0 -> -0 divx772 divide -0.0 -1.0 -> 0 divx773 divide 0.0 1.0 -> 0 divx774 divide -0.0 1.0 -> -0 divx775 divide -1.0 0.0 -> -Infinity Division_by_zero divx776 divide -1.0 -0.0 -> Infinity Division_by_zero divx777 divide 1.0 0.0 -> Infinity Division_by_zero divx778 divide 1.0 -0.0 -> -Infinity Division_by_zero -- Specials divx780 divide Inf -Inf -> NaN Invalid_operation divx781 divide Inf -1000 -> -Infinity divx782 divide Inf -1 -> -Infinity divx783 divide Inf -0 -> -Infinity divx784 divide Inf 0 -> Infinity divx785 divide Inf 1 -> Infinity divx786 divide Inf 1000 -> Infinity divx787 divide Inf Inf -> NaN Invalid_operation divx788 divide -1000 Inf -> -0E-398 Clamped divx789 divide -Inf Inf -> NaN Invalid_operation divx790 divide -1 Inf -> -0E-398 Clamped divx791 divide -0 Inf -> -0E-398 Clamped divx792 divide 0 Inf -> 0E-398 Clamped divx793 divide 1 Inf -> 0E-398 Clamped divx794 divide 1000 Inf -> 0E-398 Clamped divx795 divide Inf Inf -> NaN Invalid_operation divx800 divide -Inf -Inf -> NaN Invalid_operation divx801 divide -Inf -1000 -> Infinity divx802 divide -Inf -1 -> Infinity divx803 divide -Inf -0 -> Infinity divx804 divide -Inf 0 -> -Infinity divx805 divide -Inf 1 -> -Infinity divx806 divide -Inf 1000 -> -Infinity divx807 divide -Inf Inf -> NaN Invalid_operation divx808 divide -1000 Inf -> -0E-398 Clamped divx809 divide -Inf -Inf -> NaN Invalid_operation divx810 divide -1 -Inf -> 0E-398 Clamped divx811 divide -0 -Inf -> 0E-398 Clamped divx812 divide 0 -Inf -> -0E-398 Clamped divx813 divide 1 -Inf -> -0E-398 Clamped divx814 divide 1000 -Inf -> -0E-398 Clamped divx815 divide Inf -Inf -> NaN Invalid_operation divx821 divide NaN -Inf -> NaN divx822 divide NaN -1000 -> NaN divx823 divide NaN -1 -> NaN divx824 divide NaN -0 -> NaN divx825 divide NaN 0 -> NaN divx826 divide NaN 1 -> NaN divx827 divide NaN 1000 -> NaN divx828 divide NaN Inf -> NaN divx829 divide NaN NaN -> NaN divx830 divide -Inf NaN -> NaN divx831 divide -1000 NaN -> NaN divx832 divide -1 NaN -> NaN divx833 divide -0 NaN -> NaN divx834 divide 0 NaN -> NaN divx835 divide 1 NaN -> NaN divx836 divide 1000 NaN -> NaN divx837 divide Inf NaN -> NaN divx841 divide sNaN -Inf -> NaN Invalid_operation divx842 divide sNaN -1000 -> NaN Invalid_operation divx843 divide sNaN -1 -> NaN Invalid_operation divx844 divide sNaN -0 -> NaN Invalid_operation divx845 divide sNaN 0 -> NaN Invalid_operation divx846 divide sNaN 1 -> NaN Invalid_operation divx847 divide sNaN 1000 -> NaN Invalid_operation divx848 divide sNaN NaN -> NaN Invalid_operation divx849 divide sNaN sNaN -> NaN Invalid_operation divx850 divide NaN sNaN -> NaN Invalid_operation divx851 divide -Inf sNaN -> NaN Invalid_operation divx852 divide -1000 sNaN -> NaN Invalid_operation divx853 divide -1 sNaN -> NaN Invalid_operation divx854 divide -0 sNaN -> NaN Invalid_operation divx855 divide 0 sNaN -> NaN Invalid_operation divx856 divide 1 sNaN -> NaN Invalid_operation divx857 divide 1000 sNaN -> NaN Invalid_operation divx858 divide Inf sNaN -> NaN Invalid_operation divx859 divide NaN sNaN -> NaN Invalid_operation -- propagating NaNs divx861 divide NaN9 -Inf -> NaN9 divx862 divide NaN8 1000 -> NaN8 divx863 divide NaN7 Inf -> NaN7 divx864 divide NaN6 NaN5 -> NaN6 divx865 divide -Inf NaN4 -> NaN4 divx866 divide -1000 NaN3 -> NaN3 divx867 divide Inf NaN2 -> NaN2 divx871 divide sNaN99 -Inf -> NaN99 Invalid_operation divx872 divide sNaN98 -1 -> NaN98 Invalid_operation divx873 divide sNaN97 NaN -> NaN97 Invalid_operation divx874 divide sNaN96 sNaN94 -> NaN96 Invalid_operation divx875 divide NaN95 sNaN93 -> NaN93 Invalid_operation divx876 divide -Inf sNaN92 -> NaN92 Invalid_operation divx877 divide 0 sNaN91 -> NaN91 Invalid_operation divx878 divide Inf sNaN90 -> NaN90 Invalid_operation divx879 divide NaN sNaN89 -> NaN89 Invalid_operation divx881 divide -NaN9 -Inf -> -NaN9 divx882 divide -NaN8 1000 -> -NaN8 divx883 divide -NaN7 Inf -> -NaN7 divx884 divide -NaN6 -NaN5 -> -NaN6 divx885 divide -Inf -NaN4 -> -NaN4 divx886 divide -1000 -NaN3 -> -NaN3 divx887 divide Inf -NaN2 -> -NaN2 divx891 divide -sNaN99 -Inf -> -NaN99 Invalid_operation divx892 divide -sNaN98 -1 -> -NaN98 Invalid_operation divx893 divide -sNaN97 NaN -> -NaN97 Invalid_operation divx894 divide -sNaN96 -sNaN94 -> -NaN96 Invalid_operation divx895 divide -NaN95 -sNaN93 -> -NaN93 Invalid_operation divx896 divide -Inf -sNaN92 -> -NaN92 Invalid_operation divx897 divide 0 -sNaN91 -> -NaN91 Invalid_operation divx898 divide Inf -sNaN90 -> -NaN90 Invalid_operation divx899 divide -NaN -sNaN89 -> -NaN89 Invalid_operation maxexponent: 999999999 minexponent: -999999999 -- Various flavours of divide by 0 divx901 divide 0 0 -> NaN Division_undefined divx902 divide 0.0E5 0 -> NaN Division_undefined divx903 divide 0.000 0 -> NaN Division_undefined divx904 divide 0.0001 0 -> Infinity Division_by_zero divx905 divide 0.01 0 -> Infinity Division_by_zero divx906 divide 0.1 0 -> Infinity Division_by_zero divx907 divide 1 0 -> Infinity Division_by_zero divx908 divide 1 0.0 -> Infinity Division_by_zero divx909 divide 10 0.0 -> Infinity Division_by_zero divx910 divide 1E+100 0.0 -> Infinity Division_by_zero divx911 divide 1E+1000 0 -> Infinity Division_by_zero divx921 divide -0.0001 0 -> -Infinity Division_by_zero divx922 divide -0.01 0 -> -Infinity Division_by_zero divx923 divide -0.1 0 -> -Infinity Division_by_zero divx924 divide -1 0 -> -Infinity Division_by_zero divx925 divide -1 0.0 -> -Infinity Division_by_zero divx926 divide -10 0.0 -> -Infinity Division_by_zero divx927 divide -1E+100 0.0 -> -Infinity Division_by_zero divx928 divide -1E+1000 0 -> -Infinity Division_by_zero divx931 divide 0.0001 -0 -> -Infinity Division_by_zero divx932 divide 0.01 -0 -> -Infinity Division_by_zero divx933 divide 0.1 -0 -> -Infinity Division_by_zero divx934 divide 1 -0 -> -Infinity Division_by_zero divx935 divide 1 -0.0 -> -Infinity Division_by_zero divx936 divide 10 -0.0 -> -Infinity Division_by_zero divx937 divide 1E+100 -0.0 -> -Infinity Division_by_zero divx938 divide 1E+1000 -0 -> -Infinity Division_by_zero divx941 divide -0.0001 -0 -> Infinity Division_by_zero divx942 divide -0.01 -0 -> Infinity Division_by_zero divx943 divide -0.1 -0 -> Infinity Division_by_zero divx944 divide -1 -0 -> Infinity Division_by_zero divx945 divide -1 -0.0 -> Infinity Division_by_zero divx946 divide -10 -0.0 -> Infinity Division_by_zero divx947 divide -1E+100 -0.0 -> Infinity Division_by_zero divx948 divide -1E+1000 -0 -> Infinity Division_by_zero -- overflow and underflow tests precision: 9 maxexponent: 999999999 minexponent: -999999999 divx951 divide 9E+999999999 +0.23456789012345E-0 -> Infinity Inexact Overflow Rounded divx952 divide +0.100 9E+999999999 -> 1.111111E-1000000001 Inexact Rounded Underflow Subnormal divx953 divide 9E-999999999 +9.100 -> 9.8901099E-1000000000 Inexact Rounded Underflow Subnormal divx954 divide -1.23456789 9E+999999999 -> -1.3717421E-1000000000 Subnormal divx955 divide -1.23456789012345E-0 9E+999999999 -> -1.3717421E-1000000000 Underflow Subnormal Rounded Inexact divx956 divide -1.23456789012345E-0 7E+999999999 -> -1.7636684E-1000000000 Inexact Rounded Underflow Subnormal divx957 divide 9E+999999999 -0.83456789012345E-0 -> -Infinity Inexact Overflow Rounded divx958 divide -0.100 9E+999999999 -> -1.111111E-1000000001 Subnormal Inexact Rounded Underflow divx959 divide 9E-999999999 -9.100 -> -9.8901099E-1000000000 Inexact Rounded Underflow Subnormal -- overflow and underflow (additional edge tests in multiply.decTest) -- 'subnormal' results now possible (all hard underflow or overflow in -- base arithemtic) divx960 divide 1e-600000000 1e+400000001 -> 1E-1000000001 Subnormal divx961 divide 1e-600000000 1e+400000002 -> 1E-1000000002 Subnormal divx962 divide 1e-600000000 1e+400000003 -> 1E-1000000003 Subnormal divx963 divide 1e-600000000 1e+400000004 -> 1E-1000000004 Subnormal divx964 divide 1e-600000000 1e+400000005 -> 1E-1000000005 Subnormal divx965 divide 1e-600000000 1e+400000006 -> 1E-1000000006 Subnormal divx966 divide 1e-600000000 1e+400000007 -> 1E-1000000007 Subnormal divx967 divide 1e-600000000 1e+400000008 -> 0E-1000000007 Underflow Subnormal Inexact Rounded divx968 divide 1e-600000000 1e+400000009 -> 0E-1000000007 Underflow Subnormal Inexact Rounded divx969 divide 1e-600000000 1e+400000010 -> 0E-1000000007 Underflow Subnormal Inexact Rounded -- [no equivalent of 'subnormal' for overflow] divx970 divide 1e+600000000 1e-400000001 -> Infinity Overflow Inexact Rounded divx971 divide 1e+600000000 1e-400000002 -> Infinity Overflow Inexact Rounded divx972 divide 1e+600000000 1e-400000003 -> Infinity Overflow Inexact Rounded divx973 divide 1e+600000000 1e-400000004 -> Infinity Overflow Inexact Rounded divx974 divide 1e+600000000 1e-400000005 -> Infinity Overflow Inexact Rounded divx975 divide 1e+600000000 1e-400000006 -> Infinity Overflow Inexact Rounded divx976 divide 1e+600000000 1e-400000007 -> Infinity Overflow Inexact Rounded divx977 divide 1e+600000000 1e-400000008 -> Infinity Overflow Inexact Rounded divx978 divide 1e+600000000 1e-400000009 -> Infinity Overflow Inexact Rounded divx979 divide 1e+600000000 1e-400000010 -> Infinity Overflow Inexact Rounded -- Sign after overflow and underflow divx980 divide 1e-600000000 1e+400000009 -> 0E-1000000007 Underflow Subnormal Inexact Rounded divx981 divide 1e-600000000 -1e+400000009 -> -0E-1000000007 Underflow Subnormal Inexact Rounded divx982 divide -1e-600000000 1e+400000009 -> -0E-1000000007 Underflow Subnormal Inexact Rounded divx983 divide -1e-600000000 -1e+400000009 -> 0E-1000000007 Underflow Subnormal Inexact Rounded divx984 divide 1e+600000000 1e-400000009 -> Infinity Overflow Inexact Rounded divx985 divide 1e+600000000 -1e-400000009 -> -Infinity Overflow Inexact Rounded divx986 divide -1e+600000000 1e-400000009 -> -Infinity Overflow Inexact Rounded divx987 divide -1e+600000000 -1e-400000009 -> Infinity Overflow Inexact Rounded -- Long operand overflow may be a different path precision: 3 divx990 divide 1000 9.999E-999999999 -> Infinity Inexact Overflow Rounded divx991 divide 1000 -9.999E-999999999 -> -Infinity Inexact Overflow Rounded divx992 divide 9.999E+999999999 0.01 -> Infinity Inexact Overflow Rounded divx993 divide -9.999E+999999999 0.01 -> -Infinity Inexact Overflow Rounded -- check for double-rounded subnormals precision: 5 maxexponent: 79 minexponent: -79 divx1001 divide 1.52444E-80 1 -> 1.524E-80 Inexact Rounded Subnormal Underflow divx1002 divide 1.52445E-80 1 -> 1.524E-80 Inexact Rounded Subnormal Underflow divx1003 divide 1.52446E-80 1 -> 1.524E-80 Inexact Rounded Subnormal Underflow -- a rounding problem in one implementation precision: 34 rounding: half_up maxExponent: 6144 minExponent: -6143 -- Unbounded answer to 40 digits: -- 1.465811965811965811965811965811965811966E+7000 divx1010 divide 343E6000 234E-1000 -> Infinity Overflow Inexact Rounded -- Null tests divx9998 divide 10 # -> NaN Invalid_operation divx9999 divide # 10 -> NaN Invalid_operation --- NEW FILE: divideint.decTest --- ------------------------------------------------------------------------ -- divideint.decTest -- decimal integer division -- -- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 extended: 1 precision: 9 rounding: half_up maxExponent: 384 minexponent: -383 dvix001 divideint 1 1 -> 1 dvix002 divideint 2 1 -> 2 dvix003 divideint 1 2 -> 0 dvix004 divideint 2 2 -> 1 dvix005 divideint 0 1 -> 0 dvix006 divideint 0 2 -> 0 dvix007 divideint 1 3 -> 0 dvix008 divideint 2 3 -> 0 dvix009 divideint 3 3 -> 1 dvix010 divideint 2.4 1 -> 2 dvix011 divideint 2.4 -1 -> -2 dvix012 divideint -2.4 1 -> -2 dvix013 divideint -2.4 -1 -> 2 dvix014 divideint 2.40 1 -> 2 dvix015 divideint 2.400 1 -> 2 dvix016 divideint 2.4 2 -> 1 dvix017 divideint 2.400 2 -> 1 dvix018 divideint 2. 2 -> 1 dvix019 divideint 20 20 -> 1 dvix020 divideint 187 187 -> 1 dvix021 divideint 5 2 -> 2 dvix022 divideint 5 2.0 -> 2 dvix023 divideint 5 2.000 -> 2 dvix024 divideint 5 0.200 -> 25 dvix025 divideint 5 0.200 -> 25 dvix030 divideint 1 2 -> 0 dvix031 divideint 1 4 -> 0 dvix032 divideint 1 8 -> 0 dvix033 divideint 1 16 -> 0 dvix034 divideint 1 32 -> 0 dvix035 divideint 1 64 -> 0 dvix040 divideint 1 -2 -> -0 dvix041 divideint 1 -4 -> -0 dvix042 divideint 1 -8 -> -0 dvix043 divideint 1 -16 -> -0 dvix044 divideint 1 -32 -> -0 dvix045 divideint 1 -64 -> -0 dvix050 divideint -1 2 -> -0 dvix051 divideint -1 4 -> -0 dvix052 divideint -1 8 -> -0 dvix053 divideint -1 16 -> -0 dvix054 divideint -1 32 -> -0 dvix055 divideint -1 64 -> -0 dvix060 divideint -1 -2 -> 0 dvix061 divideint -1 -4 -> 0 dvix062 divideint -1 -8 -> 0 dvix063 divideint -1 -16 -> 0 dvix064 divideint -1 -32 -> 0 dvix065 divideint -1 -64 -> 0 -- similar with powers of ten dvix160 divideint 1 1 -> 1 dvix161 divideint 1 10 -> 0 dvix162 divideint 1 100 -> 0 dvix163 divideint 1 1000 -> 0 dvix164 divideint 1 10000 -> 0 dvix165 divideint 1 100000 -> 0 dvix166 divideint 1 1000000 -> 0 dvix167 divideint 1 10000000 -> 0 dvix168 divideint 1 100000000 -> 0 dvix170 divideint 1 -1 -> -1 dvix171 divideint 1 -10 -> -0 dvix172 divideint 1 -100 -> -0 dvix173 divideint 1 -1000 -> -0 dvix174 divideint 1 -10000 -> -0 dvix175 divideint 1 -100000 -> -0 dvix176 divideint 1 -1000000 -> -0 dvix177 divideint 1 -10000000 -> -0 dvix178 divideint 1 -100000000 -> -0 dvix180 divideint -1 1 -> -1 dvix181 divideint -1 10 -> -0 dvix182 divideint -1 100 -> -0 dvix183 divideint -1 1000 -> -0 dvix184 divideint -1 10000 -> -0 dvix185 divideint -1 100000 -> -0 dvix186 divideint -1 1000000 -> -0 dvix187 divideint -1 10000000 -> -0 dvix188 divideint -1 100000000 -> -0 dvix190 divideint -1 -1 -> 1 dvix191 divideint -1 -10 -> 0 dvix192 divideint -1 -100 -> 0 dvix193 divideint -1 -1000 -> 0 dvix194 divideint -1 -10000 -> 0 dvix195 divideint -1 -100000 -> 0 dvix196 divideint -1 -1000000 -> 0 dvix197 divideint -1 -10000000 -> 0 dvix198 divideint -1 -100000000 -> 0 -- some long operand cases here dvix070 divideint 999999999 1 -> 999999999 dvix071 divideint 999999999.4 1 -> 999999999 dvix072 divideint 999999999.5 1 -> 999999999 dvix073 divideint 999999999.9 1 -> 999999999 dvix074 divideint 999999999.999 1 -> 999999999 precision: 6 dvix080 divideint 999999999 1 -> NaN Division_impossible dvix081 divideint 99999999 1 -> NaN Division_impossible dvix082 divideint 9999999 1 -> NaN Division_impossible dvix083 divideint 999999 1 -> 999999 dvix084 divideint 99999 1 -> 99999 dvix085 divideint 9999 1 -> 9999 dvix086 divideint 999 1 -> 999 dvix087 divideint 99 1 -> 99 dvix088 divideint 9 1 -> 9 precision: 9 dvix090 divideint 0. 1 -> 0 dvix091 divideint .0 1 -> 0 dvix092 divideint 0.00 1 -> 0 dvix093 divideint 0.00E+9 1 -> 0 dvix094 divideint 0.0000E-50 1 -> 0 dvix100 divideint 1 1 -> 1 dvix101 divideint 1 2 -> 0 dvix102 divideint 1 3 -> 0 dvix103 divideint 1 4 -> 0 dvix104 divideint 1 5 -> 0 dvix105 divideint 1 6 -> 0 dvix106 divideint 1 7 -> 0 dvix107 divideint 1 8 -> 0 dvix108 divideint 1 9 -> 0 dvix109 divideint 1 10 -> 0 dvix110 divideint 1 1 -> 1 dvix111 divideint 2 1 -> 2 dvix112 divideint 3 1 -> 3 dvix113 divideint 4 1 -> 4 dvix114 divideint 5 1 -> 5 dvix115 divideint 6 1 -> 6 dvix116 divideint 7 1 -> 7 dvix117 divideint 8 1 -> 8 dvix118 divideint 9 1 -> 9 dvix119 divideint 10 1 -> 10 -- from DiagBigDecimal dvix131 divideint 101.3 1 -> 101 dvix132 divideint 101.0 1 -> 101 dvix133 divideint 101.3 3 -> 33 dvix134 divideint 101.0 3 -> 33 dvix135 divideint 2.4 1 -> 2 dvix136 divideint 2.400 1 -> 2 dvix137 divideint 18 18 -> 1 dvix138 divideint 1120 1000 -> 1 dvix139 divideint 2.4 2 -> 1 dvix140 divideint 2.400 2 -> 1 dvix141 divideint 0.5 2.000 -> 0 dvix142 divideint 8.005 7 -> 1 dvix143 divideint 5 2 -> 2 dvix144 divideint 0 2 -> 0 dvix145 divideint 0.00 2 -> 0 -- Others dvix150 divideint 12345 4.999 -> 2469 dvix151 divideint 12345 4.99 -> 2473 dvix152 divideint 12345 4.9 -> 2519 dvix153 divideint 12345 5 -> 2469 dvix154 divideint 12345 5.1 -> 2420 dvix155 divideint 12345 5.01 -> 2464 dvix156 divideint 12345 5.001 -> 2468 dvix157 divideint 101 7.6 -> 13 -- Various flavours of divideint by 0 maxexponent: 999999999 minexponent: -999999999 dvix201 divideint 0 0 -> NaN Division_undefined dvix202 divideint 0.0E5 0 -> NaN Division_undefined dvix203 divideint 0.000 0 -> NaN Division_undefined dvix204 divideint 0.0001 0 -> Infinity Division_by_zero dvix205 divideint 0.01 0 -> Infinity Division_by_zero dvix206 divideint 0.1 0 -> Infinity Division_by_zero dvix207 divideint 1 0 -> Infinity Division_by_zero dvix208 divideint 1 0.0 -> Infinity Division_by_zero dvix209 divideint 10 0.0 -> Infinity Division_by_zero dvix210 divideint 1E+100 0.0 -> Infinity Division_by_zero dvix211 divideint 1E+1000 0 -> Infinity Division_by_zero dvix214 divideint -0.0001 0 -> -Infinity Division_by_zero dvix215 divideint -0.01 0 -> -Infinity Division_by_zero dvix216 divideint -0.1 0 -> -Infinity Division_by_zero dvix217 divideint -1 0 -> -Infinity Division_by_zero dvix218 divideint -1 0.0 -> -Infinity Division_by_zero dvix219 divideint -10 0.0 -> -Infinity Division_by_zero dvix220 divideint -1E+100 0.0 -> -Infinity Division_by_zero dvix221 divideint -1E+1000 0 -> -Infinity Division_by_zero -- test some cases that are close to exponent overflow maxexponent: 999999999 minexponent: -999999999 dvix270 divideint 1 1e999999999 -> 0 dvix271 divideint 1 0.9e999999999 -> 0 dvix272 divideint 1 0.99e999999999 -> 0 dvix273 divideint 1 0.999999999e999999999 -> 0 dvix274 divideint 9e999999999 1 -> NaN Division_impossible dvix275 divideint 9.9e999999999 1 -> NaN Division_impossible dvix276 divideint 9.99e999999999 1 -> NaN Division_impossible dvix277 divideint 9.99999999e999999999 1 -> NaN Division_impossible dvix280 divideint 0.1 9e-999999999 -> NaN Division_impossible dvix281 divideint 0.1 99e-999999999 -> NaN Division_impossible dvix282 divideint 0.1 999e-999999999 -> NaN Division_impossible dvix283 divideint 0.1 9e-999999998 -> NaN Division_impossible dvix284 divideint 0.1 99e-999999998 -> NaN Division_impossible dvix285 divideint 0.1 999e-999999998 -> NaN Division_impossible dvix286 divideint 0.1 999e-999999997 -> NaN Division_impossible dvix287 divideint 0.1 9999e-999999997 -> NaN Division_impossible dvix288 divideint 0.1 99999e-999999997 -> NaN Division_impossible -- overflow and underflow tests [from divide] maxexponent: 999999999 minexponent: -999999999 dvix330 divideint +1.23456789012345E-0 9E+999999999 -> 0 dvix331 divideint 9E+999999999 +0.23456789012345E-0 -> NaN Division_impossible dvix332 divideint +0.100 9E+999999999 -> 0 dvix333 divideint 9E-999999999 +9.100 -> 0 dvix335 divideint -1.23456789012345E-0 9E+999999999 -> -0 dvix336 divideint 9E+999999999 -0.83456789012345E-0 -> NaN Division_impossible dvix337 divideint -0.100 9E+999999999 -> -0 dvix338 divideint 9E-999999999 -9.100 -> -0 -- long operand checks maxexponent: 999 minexponent: -999 precision: 9 dvix401 divideint 12345678000 100 -> 123456780 dvix402 divideint 1 12345678000 -> 0 dvix403 divideint 1234567800 10 -> 123456780 dvix404 divideint 1 1234567800 -> 0 dvix405 divideint 1234567890 10 -> 123456789 dvix406 divideint 1 1234567890 -> 0 dvix407 divideint 1234567891 10 -> 123456789 dvix408 divideint 1 1234567891 -> 0 dvix409 divideint 12345678901 100 -> 123456789 dvix410 divideint 1 12345678901 -> 0 dvix411 divideint 1234567896 10 -> 123456789 dvix412 divideint 1 1234567896 -> 0 dvix413 divideint 12345678948 100 -> 123456789 dvix414 divideint 12345678949 100 -> 123456789 dvix415 divideint 12345678950 100 -> 123456789 dvix416 divideint 12345678951 100 -> 123456789 dvix417 divideint 12345678999 100 -> 123456789 precision: 15 dvix441 divideint 12345678000 1 -> 12345678000 dvix442 divideint 1 12345678000 -> 0 dvix443 divideint 1234567800 1 -> 1234567800 dvix444 divideint 1 1234567800 -> 0 dvix445 divideint 1234567890 1 -> 1234567890 dvix446 divideint 1 1234567890 -> 0 dvix447 divideint 1234567891 1 -> 1234567891 dvix448 divideint 1 1234567891 -> 0 dvix449 divideint 12345678901 1 -> 12345678901 dvix450 divideint 1 12345678901 -> 0 dvix451 divideint 1234567896 1 -> 1234567896 dvix452 divideint 1 1234567896 -> 0 precision: 9 rounding: half_up maxExponent: 999 minexponent: -999 -- more zeros, etc. dvix531 divideint 5.00 1E-3 -> 5000 dvix532 divideint 00.00 0.000 -> NaN Division_undefined dvix533 divideint 00.00 0E-3 -> NaN Division_undefined dvix534 divideint 0 -0 -> NaN Division_undefined dvix535 divideint -0 0 -> NaN Division_undefined dvix536 divideint -0 -0 -> NaN Division_undefined dvix541 divideint 0 -1 -> -0 dvix542 divideint -0 -1 -> 0 dvix543 divideint 0 1 -> 0 dvix544 divideint -0 1 -> -0 dvix545 divideint -1 0 -> -Infinity Division_by_zero dvix546 divideint -1 -0 -> Infinity Division_by_zero dvix547 divideint 1 0 -> Infinity Division_by_zero dvix548 divideint 1 -0 -> -Infinity Division_by_zero dvix551 divideint 0.0 -1 -> -0 dvix552 divideint -0.0 -1 -> 0 dvix553 divideint 0.0 1 -> 0 dvix554 divideint -0.0 1 -> -0 dvix555 divideint -1.0 0 -> -Infinity Division_by_zero dvix556 divideint -1.0 -0 -> Infinity Division_by_zero dvix557 divideint 1.0 0 -> Infinity Division_by_zero dvix558 divideint 1.0 -0 -> -Infinity Division_by_zero dvix561 divideint 0 -1.0 -> -0 dvix562 divideint -0 -1.0 -> 0 dvix563 divideint 0 1.0 -> 0 dvix564 divideint -0 1.0 -> -0 dvix565 divideint -1 0.0 -> -Infinity Division_by_zero dvix566 divideint -1 -0.0 -> Infinity Division_by_zero dvix567 divideint 1 0.0 -> Infinity Division_by_zero dvix568 divideint 1 -0.0 -> -Infinity Division_by_zero dvix571 divideint 0.0 -1.0 -> -0 dvix572 divideint -0.0 -1.0 -> 0 dvix573 divideint 0.0 1.0 -> 0 dvix574 divideint -0.0 1.0 -> -0 dvix575 divideint -1.0 0.0 -> -Infinity Division_by_zero dvix576 divideint -1.0 -0.0 -> Infinity Division_by_zero dvix577 divideint 1.0 0.0 -> Infinity Division_by_zero dvix578 divideint 1.0 -0.0 -> -Infinity Division_by_zero -- Specials dvix580 divideint Inf -Inf -> NaN Invalid_operation dvix581 divideint Inf -1000 -> -Infinity dvix582 divideint Inf -1 -> -Infinity dvix583 divideint Inf -0 -> -Infinity dvix584 divideint Inf 0 -> Infinity dvix585 divideint Inf 1 -> Infinity dvix586 divideint Inf 1000 -> Infinity dvix587 divideint Inf Inf -> NaN Invalid_operation dvix588 divideint -1000 Inf -> -0 dvix589 divideint -Inf Inf -> NaN Invalid_operation dvix590 divideint -1 Inf -> -0 dvix591 divideint -0 Inf -> -0 dvix592 divideint 0 Inf -> 0 dvix593 divideint 1 Inf -> 0 dvix594 divideint 1000 Inf -> 0 dvix595 divideint Inf Inf -> NaN Invalid_operation dvix600 divideint -Inf -Inf -> NaN Invalid_operation dvix601 divideint -Inf -1000 -> Infinity dvix602 divideint -Inf -1 -> Infinity dvix603 divideint -Inf -0 -> Infinity dvix604 divideint -Inf 0 -> -Infinity dvix605 divideint -Inf 1 -> -Infinity dvix606 divideint -Inf 1000 -> -Infinity dvix607 divideint -Inf Inf -> NaN Invalid_operation dvix608 divideint -1000 Inf -> -0 dvix609 divideint -Inf -Inf -> NaN Invalid_operation dvix610 divideint -1 -Inf -> 0 dvix611 divideint -0 -Inf -> 0 dvix612 divideint 0 -Inf -> -0 dvix613 divideint 1 -Inf -> -0 dvix614 divideint 1000 -Inf -> -0 dvix615 divideint Inf -Inf -> NaN Invalid_operation dvix621 divideint NaN -Inf -> NaN dvix622 divideint NaN -1000 -> NaN dvix623 divideint NaN -1 -> NaN dvix624 divideint NaN -0 -> NaN dvix625 divideint NaN 0 -> NaN dvix626 divideint NaN 1 -> NaN dvix627 divideint NaN 1000 -> NaN dvix628 divideint NaN Inf -> NaN dvix629 divideint NaN NaN -> NaN dvix630 divideint -Inf NaN -> NaN dvix631 divideint -1000 NaN -> NaN dvix632 divideint -1 NaN -> NaN dvix633 divideint -0 NaN -> NaN dvix634 divideint 0 NaN -> NaN dvix635 divideint 1 NaN -> NaN dvix636 divideint 1000 NaN -> NaN dvix637 divideint Inf NaN -> NaN dvix641 divideint sNaN -Inf -> NaN Invalid_operation dvix642 divideint sNaN -1000 -> NaN Invalid_operation dvix643 divideint sNaN -1 -> NaN Invalid_operation dvix644 divideint sNaN -0 -> NaN Invalid_operation dvix645 divideint sNaN 0 -> NaN Invalid_operation dvix646 divideint sNaN 1 -> NaN Invalid_operation dvix647 divideint sNaN 1000 -> NaN Invalid_operation dvix648 divideint sNaN NaN -> NaN Invalid_operation dvix649 divideint sNaN sNaN -> NaN Invalid_operation dvix650 divideint NaN sNaN -> NaN Invalid_operation dvix651 divideint -Inf sNaN -> NaN Invalid_operation dvix652 divideint -1000 sNaN -> NaN Invalid_operation dvix653 divideint -1 sNaN -> NaN Invalid_operation dvix654 divideint -0 sNaN -> NaN Invalid_operation dvix655 divideint 0 sNaN -> NaN Invalid_operation dvix656 divideint 1 sNaN -> NaN Invalid_operation dvix657 divideint 1000 sNaN -> NaN Invalid_operation dvix658 divideint Inf sNaN -> NaN Invalid_operation dvix659 divideint NaN sNaN -> NaN Invalid_operation -- propagating NaNs dvix661 divideint NaN9 -Inf -> NaN9 dvix662 divideint NaN8 1000 -> NaN8 dvix663 divideint NaN7 Inf -> NaN7 dvix664 divideint -NaN6 NaN5 -> -NaN6 dvix665 divideint -Inf NaN4 -> NaN4 dvix666 divideint -1000 NaN3 -> NaN3 dvix667 divideint Inf -NaN2 -> -NaN2 dvix671 divideint -sNaN99 -Inf -> -NaN99 Invalid_operation dvix672 divideint sNaN98 -1 -> NaN98 Invalid_operation dvix673 divideint sNaN97 NaN -> NaN97 Invalid_operation dvix674 divideint sNaN96 sNaN94 -> NaN96 Invalid_operation dvix675 divideint NaN95 sNaN93 -> NaN93 Invalid_operation dvix676 divideint -Inf sNaN92 -> NaN92 Invalid_operation dvix677 divideint 0 sNaN91 -> NaN91 Invalid_operation dvix678 divideint Inf -sNaN90 -> -NaN90 Invalid_operation dvix679 divideint NaN sNaN89 -> NaN89 Invalid_operation -- some long operand cases again precision: 8 dvix710 divideint 100000001 1 -> NaN Division_impossible dvix711 divideint 100000000.4 1 -> NaN Division_impossible dvix712 divideint 100000000.5 1 -> NaN Division_impossible dvix713 divideint 100000000.9 1 -> NaN Division_impossible dvix714 divideint 100000000.999 1 -> NaN Division_impossible precision: 6 dvix720 divideint 100000000 1 -> NaN Division_impossible dvix721 divideint 10000000 1 -> NaN Division_impossible dvix722 divideint 1000000 1 -> NaN Division_impossible dvix723 divideint 100000 1 -> 100000 dvix724 divideint 10000 1 -> 10000 dvix725 divideint 1000 1 -> 1000 dvix726 divideint 100 1 -> 100 dvix727 divideint 10 1 -> 10 dvix728 divideint 1 1 -> 1 dvix729 divideint 1 10 -> 0 precision: 9 maxexponent: 999999999 minexponent: -999999999 dvix732 divideint 1 0.99e999999999 -> 0 dvix733 divideint 1 0.999999999e999999999 -> 0 dvix734 divideint 9e999999999 1 -> NaN Division_impossible dvix735 divideint 9.9e999999999 1 -> NaN Division_impossible dvix736 divideint 9.99e999999999 1 -> NaN Division_impossible dvix737 divideint 9.99999999e999999999 1 -> NaN Division_impossible dvix740 divideint 0.1 9e-999999999 -> NaN Division_impossible dvix741 divideint 0.1 99e-999999999 -> NaN Division_impossible dvix742 divideint 0.1 999e-999999999 -> NaN Division_impossible dvix743 divideint 0.1 9e-999999998 -> NaN Division_impossible dvix744 divideint 0.1 99e-999999998 -> NaN Division_impossible dvix745 divideint 0.1 999e-999999998 -> NaN Division_impossible dvix746 divideint 0.1 999e-999999997 -> NaN Division_impossible dvix747 divideint 0.1 9999e-999999997 -> NaN Division_impossible dvix748 divideint 0.1 99999e-999999997 -> NaN Division_impossible -- Null tests dvix900 divideint 10 # -> NaN Invalid_operation dvix901 divideint # 10 -> NaN Invalid_operation --- NEW FILE: inexact.decTest --- ------------------------------------------------------------------------ -- inexact.decTest -- decimal inexact and rounded edge cases -- -- Copyright (c) IBM Corporation, 1981, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 extended: 1 precision: 9 rounding: half_up maxExponent: 999 minexponent: -999 inx001 add 1 1 -> 2 inx002 add 123456789 0 -> 123456789 inx003 add 123456789 0.0 -> 123456789 Rounded inx004 add 123456789 0.00 -> 123456789 Rounded inx005 add 123456789 1 -> 123456790 inx006 add 123456789 0.1 -> 123456789 Inexact Rounded inx007 add 123456789 0.01 -> 123456789 Inexact Rounded inx008 add 123456789 0.001 -> 123456789 Inexact Rounded inx009 add 123456789 0.000001 -> 123456789 Inexact Rounded inx010 add 123456789 0.000000001 -> 123456789 Inexact Rounded inx011 add 123456789 0.000000000001 -> 123456789 Inexact Rounded inx012 add 123456789 0.9 -> 123456790 Inexact Rounded inx013 add 123456789 0.09 -> 123456789 Inexact Rounded inx014 add 123456789 0.009 -> 123456789 Inexact Rounded inx015 add 123456789 0.000009 -> 123456789 Inexact Rounded inx016 add 123456789 0.000000009 -> 123456789 Inexact Rounded inx017 add 123456789 0.000000000009 -> 123456789 Inexact Rounded inx021 add 1 -1 -> 0 inx022 add 123456789 -0 -> 123456789 inx023 add 123456789 -0.0 -> 123456789 Rounded inx024 add 123456789 -0.00 -> 123456789 Rounded inx025 add 123456789 -1 -> 123456788 inx026 add 123456789 -0.1 -> 123456789 Inexact Rounded inx027 add 123456789 -0.01 -> 123456789 Inexact Rounded inx028 add 123456789 -0.001 -> 123456789 Inexact Rounded inx029 add 123456789 -0.000001 -> 123456789 Inexact Rounded inx030 add 123456789 -0.000000001 -> 123456789 Inexact Rounded inx031 add 123456789 -0.000000000001 -> 123456789 Inexact Rounded inx032 add 123456789 -0.9 -> 123456788 Inexact Rounded inx033 add 123456789 -0.09 -> 123456789 Inexact Rounded inx034 add 123456789 -0.009 -> 123456789 Inexact Rounded inx035 add 123456789 -0.000009 -> 123456789 Inexact Rounded inx036 add 123456789 -0.000000009 -> 123456789 Inexact Rounded inx037 add 123456789 -0.000000000009 -> 123456789 Inexact Rounded inx042 add 0 123456789 -> 123456789 inx043 add 0.0 123456789 -> 123456789 Rounded inx044 add 0.00 123456789 -> 123456789 Rounded inx045 add 1 123456789 -> 123456790 inx046 add 0.1 123456789 -> 123456789 Inexact Rounded inx047 add 0.01 123456789 -> 123456789 Inexact Rounded inx048 add 0.001 123456789 -> 123456789 Inexact Rounded inx049 add 0.000001 123456789 -> 123456789 Inexact Rounded inx050 add 0.000000001 123456789 -> 123456789 Inexact Rounded inx051 add 0.000000000001 123456789 -> 123456789 Inexact Rounded inx052 add 0.9 123456789 -> 123456790 Inexact Rounded inx053 add 0.09 123456789 -> 123456789 Inexact Rounded inx054 add 0.009 123456789 -> 123456789 Inexact Rounded inx055 add 0.000009 123456789 -> 123456789 Inexact Rounded inx056 add 0.000000009 123456789 -> 123456789 Inexact Rounded inx057 add 0.000000000009 123456789 -> 123456789 Inexact Rounded inx062 add -0 123456789 -> 123456789 inx063 add -0.0 123456789 -> 123456789 Rounded inx064 add -0.00 123456789 -> 123456789 Rounded inx065 add -1 123456789 -> 123456788 inx066 add -0.1 123456789 -> 123456789 Inexact Rounded inx067 add -0.01 123456789 -> 123456789 Inexact Rounded inx068 add -0.001 123456789 -> 123456789 Inexact Rounded inx069 add -0.000001 123456789 -> 123456789 Inexact Rounded inx070 add -0.000000001 123456789 -> 123456789 Inexact Rounded inx071 add -0.000000000001 123456789 -> 123456789 Inexact Rounded inx072 add -0.9 123456789 -> 123456788 Inexact Rounded inx073 add -0.09 123456789 -> 123456789 Inexact Rounded inx074 add -0.009 123456789 -> 123456789 Inexact Rounded inx075 add -0.000009 123456789 -> 123456789 Inexact Rounded inx076 add -0.000000009 123456789 -> 123456789 Inexact Rounded inx077 add -0.000000000009 123456789 -> 123456789 Inexact Rounded -- some boundaries inx081 add 999999999 0 -> 999999999 inx082 add 0.999999999 0.000000000 -> 0.999999999 inx083 add 999999999 1 -> 1.00000000E+9 Rounded inx084 add 0.999999999 0.000000001 -> 1.00000000 Rounded inx085 add 999999999 2 -> 1.00000000E+9 Inexact Rounded inx086 add 0.999999999 0.000000002 -> 1.00000000 Inexact Rounded inx087 add 999999999 3 -> 1.00000000E+9 Inexact Rounded inx089 add 0.999999999 0.000000003 -> 1.00000000 Inexact Rounded -- minus, plus, and subtract all assumed to work like add. -- multiply precision: 8 inx101 multiply 1000 1000 -> 1000000 inx102 multiply 9000 9000 -> 81000000 inx103 multiply 9999 9999 -> 99980001 inx104 multiply 1000 10000 -> 10000000 inx105 multiply 10000 10000 -> 1.0000000E+8 Rounded inx106 multiply 10001 10000 -> 1.0001000E+8 Rounded inx107 multiply 10001 10001 -> 1.0002000E+8 Inexact Rounded inx108 multiply 10101 10001 -> 1.0102010E+8 Inexact Rounded inx109 multiply 10001 10101 -> 1.0102010E+8 Inexact Rounded -- divide precision: 4 inx201 divide 1000 1000 -> 1 inx202 divide 1000 1 -> 1000 inx203 divide 1000 2 -> 500 inx204 divide 1000 3 -> 333.3 Inexact Rounded inx205 divide 1000 4 -> 250 inx206 divide 1000 5 -> 200 inx207 divide 1000 6 -> 166.7 Inexact Rounded inx208 divide 1000 7 -> 142.9 Inexact Rounded inx209 divide 1000 8 -> 125 inx210 divide 1000 9 -> 111.1 Inexact Rounded inx211 divide 1000 10 -> 100 inx220 divide 1 1 -> 1 inx221 divide 1 2 -> 0.5 inx222 divide 1 4 -> 0.25 inx223 divide 1 8 -> 0.125 inx224 divide 1 16 -> 0.0625 inx225 divide 1 32 -> 0.03125 inx226 divide 1 64 -> 0.01563 Inexact Rounded inx227 divide 1 128 -> 0.007813 Inexact Rounded precision: 5 inx230 divide 1 1 -> 1 inx231 divide 1 2 -> 0.5 inx232 divide 1 4 -> 0.25 inx233 divide 1 8 -> 0.125 inx234 divide 1 16 -> 0.0625 inx235 divide 1 32 -> 0.03125 inx236 divide 1 64 -> 0.015625 inx237 divide 1 128 -> 0.0078125 precision: 3 inx240 divide 1 1 -> 1 inx241 divide 1 2 -> 0.5 inx242 divide 1 4 -> 0.25 inx243 divide 1 8 -> 0.125 inx244 divide 1 16 -> 0.0625 inx245 divide 1 32 -> 0.0313 Inexact Rounded inx246 divide 1 64 -> 0.0156 Inexact Rounded inx247 divide 1 128 -> 0.00781 Inexact Rounded precision: 2 inx250 divide 1 1 -> 1 inx251 divide 1 2 -> 0.5 inx252 divide 1 4 -> 0.25 inx253 divide 1 8 -> 0.13 Inexact Rounded inx254 divide 1 16 -> 0.063 Inexact Rounded inx255 divide 1 32 -> 0.031 Inexact Rounded inx256 divide 1 64 -> 0.016 Inexact Rounded inx257 divide 1 128 -> 0.0078 Inexact Rounded precision: 1 inx260 divide 1 1 -> 1 inx261 divide 1 2 -> 0.5 inx262 divide 1 4 -> 0.3 Inexact Rounded inx263 divide 1 8 -> 0.1 Inexact Rounded inx264 divide 1 16 -> 0.06 Inexact Rounded inx265 divide 1 32 -> 0.03 Inexact Rounded inx266 divide 1 64 -> 0.02 Inexact Rounded inx267 divide 1 128 -> 0.008 Inexact Rounded -- power precision: 4 inx301 power 0.5 2 -> 0.25 inx302 power 0.5 4 -> 0.0625 inx303 power 0.5 8 -> 0.003906 Inexact Rounded inx304 power 0.5 16 -> 0.00001526 Inexact Rounded inx305 power 0.5 32 -> 2.328E-10 Inexact Rounded -- compare, divideInteger, and remainder are always exact -- rescale precision: 4 inx401 rescale 0 0 -> 0 inx402 rescale 1 0 -> 1 inx403 rescale 0.1 +2 -> 0E+2 Inexact Rounded inx404 rescale 0.1 +1 -> 0E+1 Inexact Rounded inx405 rescale 0.1 0 -> 0 Inexact Rounded inx406 rescale 0.1 -1 -> 0.1 inx407 rescale 0.1 -2 -> 0.10 -- long operands cause rounding too precision: 9 inx801 plus 123456789 -> 123456789 inx802 plus 1234567890 -> 1.23456789E+9 Rounded inx803 plus 1234567891 -> 1.23456789E+9 Inexact Rounded inx804 plus 1234567892 -> 1.23456789E+9 Inexact Rounded inx805 plus 1234567899 -> 1.23456790E+9 Inexact Rounded inx806 plus 1234567900 -> 1.23456790E+9 Rounded --- NEW FILE: integer.decTest --- ------------------------------------------------------------------------ -- integer.decTest -- round decimal to integer -- -- Copyright (c) IBM Corporation, 2001, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.26 -- This set of tests tests the extended specification 'round-to-integer' -- operation (from IEEE 854). All non-zero results are defined as -- being those from either plus or rescale, so those are assumed to have -- been tested. extended: 1 precision: 9 rounding: half_up maxExponent: 999 minExponent: -999 intx001 integer 0 -> 0 intx002 integer 0.0 -> 0 intx003 integer 0.1 -> 0 Rounded Inexact intx004 integer 0.2 -> 0 Rounded Inexact intx005 integer 0.3 -> 0 Rounded Inexact intx006 integer 0.4 -> 0 Rounded Inexact intx007 integer 0.5 -> 1 Rounded Inexact intx008 integer 0.6 -> 1 Rounded Inexact intx009 integer 0.7 -> 1 Rounded Inexact intx010 integer 0.8 -> 1 Rounded Inexact intx011 integer 0.9 -> 1 Rounded Inexact intx012 integer 1 -> 1 intx013 integer 1.0 -> 1 Rounded intx014 integer 1.1 -> 1 Rounded Inexact intx015 integer 1.2 -> 1 Rounded Inexact intx016 integer 1.3 -> 1 Rounded Inexact intx017 integer 1.4 -> 1 Rounded Inexact intx018 integer 1.5 -> 2 Rounded Inexact intx019 integer 1.6 -> 2 Rounded Inexact intx020 integer 1.7 -> 2 Rounded Inexact intx021 integer 1.8 -> 2 Rounded Inexact intx022 integer 1.9 -> 2 Rounded Inexact -- negatives intx031 integer -0 -> -0 intx032 integer -0.0 -> -0 intx033 integer -0.1 -> -0 Rounded Inexact intx034 integer -0.2 -> -0 Rounded Inexact intx035 integer -0.3 -> -0 Rounded Inexact intx036 integer -0.4 -> -0 Rounded Inexact intx037 integer -0.5 -> -1 Rounded Inexact intx038 integer -0.6 -> -1 Rounded Inexact intx039 integer -0.7 -> -1 Rounded Inexact intx040 integer -0.8 -> -1 Rounded Inexact intx041 integer -0.9 -> -1 Rounded Inexact intx042 integer -1 -> -1 intx043 integer -1.0 -> -1 Rounded intx044 integer -1.1 -> -1 Rounded Inexact intx045 integer -1.2 -> -1 Rounded Inexact intx046 integer -1.3 -> -1 Rounded Inexact intx047 integer -1.4 -> -1 Rounded Inexact intx048 integer -1.5 -> -2 Rounded Inexact intx049 integer -1.6 -> -2 Rounded Inexact intx050 integer -1.7 -> -2 Rounded Inexact intx051 integer -1.8 -> -2 Rounded Inexact intx052 integer -1.9 -> -2 Rounded Inexact intx053 integer 10E+30 -> NaN Invalid_operation intx054 integer -10E+30 -> NaN Invalid_operation -- numbers around precision precision: 9 intx060 integer '56267E-10' -> '0' Inexact Rounded intx061 integer '56267E-5' -> '1' Inexact Rounded intx062 integer '56267E-2' -> '563' Inexact Rounded intx063 integer '56267E-1' -> '5627' Inexact Rounded intx065 integer '56267E-0' -> '56267' intx066 integer '56267E+0' -> '56267' intx067 integer '56267E+1' -> '562670' intx068 integer '56267E+2' -> '5626700' intx069 integer '56267E+3' -> '56267000' intx070 integer '56267E+4' -> '562670000' intx071 integer '56267E+5' -> NaN Invalid_operation intx072 integer '56267E+6' -> NaN Invalid_operation intx080 integer '-56267E-10' -> '-0' Inexact Rounded intx081 integer '-56267E-5' -> '-1' Inexact Rounded intx082 integer '-56267E-2' -> '-563' Inexact Rounded intx083 integer '-56267E-1' -> '-5627' Inexact Rounded intx085 integer '-56267E-0' -> '-56267' intx086 integer '-56267E+0' -> '-56267' intx087 integer '-56267E+1' -> '-562670' intx088 integer '-56267E+2' -> '-5626700' intx089 integer '-56267E+3' -> '-56267000' intx090 integer '-56267E+4' -> '-562670000' intx091 integer '-56267E+5' -> NaN Invalid_operation intx092 integer '-56267E+6' -> NaN Invalid_operation -- specials and zeros intx120 integer 'Inf' -> NaN Invalid_operation intx121 integer '-Inf' -> NaN Invalid_operation intx122 integer NaN -> NaN intx123 integer sNaN -> NaN Invalid_operation intx124 integer 0 -> 0 intx125 integer -0 -> -0 intx126 integer 0.000 -> 0 intx127 integer 0.00 -> 0 intx128 integer 0.0 -> 0 intx129 integer 0 -> 0 intx130 integer 0E-3 -> 0 intx131 integer 0E-2 -> 0 intx132 integer 0E-1 -> 0 intx133 integer 0E-0 -> 0 intx134 integer 0E+1 -> 0 intx135 integer 0E+2 -> 0 intx136 integer 0E+3 -> 0 intx137 integer 0E+4 -> 0 intx138 integer 0E+5 -> 0 intx139 integer -0.000 -> -0 intx140 integer -0.00 -> -0 intx141 integer -0.0 -> -0 intx142 integer -0 -> -0 intx143 integer -0E-3 -> -0 intx144 integer -0E-2 -> -0 intx145 integer -0E-1 -> -0 intx146 integer -0E-0 -> -0 intx147 integer -0E+1 -> -0 intx148 integer -0E+2 -> -0 intx149 integer -0E+3 -> -0 intx150 integer -0E+4 -> -0 intx151 integer -0E+5 -> -0 -- examples rounding: half_up precision: 9 intx200 integer 2.1 -> 2 Rounded Inexact intx201 integer 100 -> 100 intx202 integer 100.0 -> 100 Rounded intx203 integer 101.5 -> 102 Rounded Inexact intx204 integer -101.5 -> -102 Rounded Inexact intx205 integer 10E+5 -> 1000000 --- NEW FILE: max.decTest --- ------------------------------------------------------------------------ -- max.decTest -- decimal maximum -- -- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding extended: 1 precision: 9 rounding: half_up maxExponent: 384 minexponent: -383 -- sanity checks maxx001 max -2 -2 -> -2 maxx002 max -2 -1 -> -1 maxx003 max -2 0 -> 0 maxx004 max -2 1 -> 1 maxx005 max -2 2 -> 2 maxx006 max -1 -2 -> -1 maxx007 max -1 -1 -> -1 maxx008 max -1 0 -> 0 maxx009 max -1 1 -> 1 maxx010 max -1 2 -> 2 maxx011 max 0 -2 -> 0 maxx012 max 0 -1 -> 0 maxx013 max 0 0 -> 0 maxx014 max 0 1 -> 1 maxx015 max 0 2 -> 2 maxx016 max 1 -2 -> 1 maxx017 max 1 -1 -> 1 maxx018 max 1 0 -> 1 maxx019 max 1 1 -> 1 maxx020 max 1 2 -> 2 maxx021 max 2 -2 -> 2 maxx022 max 2 -1 -> 2 maxx023 max 2 0 -> 2 maxx025 max 2 1 -> 2 maxx026 max 2 2 -> 2 -- extended zeros maxx030 max 0 0 -> 0 maxx031 max 0 -0 -> 0 maxx032 max 0 -0.0 -> 0 maxx033 max 0 0.0 -> 0 maxx034 max -0 0 -> -0 -- note: -0 = 0 maxx035 max -0 -0 -> -0 maxx036 max -0 -0.0 -> -0 maxx037 max -0 0.0 -> -0 maxx038 max 0.0 0 -> 0.0 maxx039 max 0.0 -0 -> 0.0 maxx040 max 0.0 -0.0 -> 0.0 maxx041 max 0.0 0.0 -> 0.0 maxx042 max -0.0 0 -> -0.0 maxx043 max -0.0 -0 -> -0.0 maxx044 max -0.0 -0.0 -> -0.0 maxx045 max -0.0 0.0 -> -0.0 maxx046 max -0E1 0E2 -> -0E+1 maxx047 max 0E2 0E1 -> 0E+2 maxx048 max 0E1 0E2 -> 0E+1 maxx049 max -0E3 -0E2 -> -0E+3 -- Specials precision: 9 maxx090 max Inf -Inf -> Infinity maxx091 max Inf -1000 -> Infinity maxx092 max Inf -1 -> Infinity maxx093 max Inf -0 -> Infinity maxx094 max Inf 0 -> Infinity maxx095 max Inf 1 -> Infinity maxx096 max Inf 1000 -> Infinity maxx097 max Inf Inf -> Infinity maxx098 max -1000 Inf -> Infinity maxx099 max -Inf Inf -> Infinity maxx100 max -1 Inf -> Infinity maxx101 max -0 Inf -> Infinity maxx102 max 0 Inf -> Infinity maxx103 max 1 Inf -> Infinity maxx104 max 1000 Inf -> Infinity maxx105 max Inf Inf -> Infinity maxx120 max -Inf -Inf -> -Infinity maxx121 max -Inf -1000 -> -1000 maxx122 max -Inf -1 -> -1 maxx123 max -Inf -0 -> -0 maxx124 max -Inf 0 -> 0 maxx125 max -Inf 1 -> 1 maxx126 max -Inf 1000 -> 1000 maxx127 max -Inf Inf -> Infinity maxx128 max -Inf -Inf -> -Infinity maxx129 max -1000 -Inf -> -1000 maxx130 max -1 -Inf -> -1 maxx131 max -0 -Inf -> -0 maxx132 max 0 -Inf -> 0 maxx133 max 1 -Inf -> 1 maxx134 max 1000 -Inf -> 1000 maxx135 max Inf -Inf -> Infinity maxx141 max NaN -Inf -> NaN maxx142 max NaN -1000 -> NaN maxx143 max NaN -1 -> NaN maxx144 max NaN -0 -> NaN maxx145 max NaN 0 -> NaN maxx146 max NaN 1 -> NaN maxx147 max NaN 1000 -> NaN maxx148 max NaN Inf -> NaN maxx149 max NaN NaN -> NaN maxx150 max -Inf NaN -> NaN maxx151 max -1000 NaN -> NaN maxx152 max -1 NaN -> NaN maxx153 max -0 NaN -> NaN maxx154 max 0 NaN -> NaN maxx155 max 1 NaN -> NaN maxx156 max 1000 NaN -> NaN maxx157 max Inf NaN -> NaN maxx161 max sNaN -Inf -> NaN Invalid_operation maxx162 max sNaN -1000 -> NaN Invalid_operation maxx163 max sNaN -1 -> NaN Invalid_operation maxx164 max sNaN -0 -> NaN Invalid_operation maxx165 max sNaN 0 -> NaN Invalid_operation maxx166 max sNaN 1 -> NaN Invalid_operation maxx167 max sNaN 1000 -> NaN Invalid_operation maxx168 max sNaN NaN -> NaN Invalid_operation maxx169 max sNaN sNaN -> NaN Invalid_operation maxx170 max NaN sNaN -> NaN Invalid_operation maxx171 max -Inf sNaN -> NaN Invalid_operation maxx172 max -1000 sNaN -> NaN Invalid_operation maxx173 max -1 sNaN -> NaN Invalid_operation maxx174 max -0 sNaN -> NaN Invalid_operation maxx175 max 0 sNaN -> NaN Invalid_operation maxx176 max 1 sNaN -> NaN Invalid_operation maxx177 max 1000 sNaN -> NaN Invalid_operation maxx178 max Inf sNaN -> NaN Invalid_operation maxx179 max NaN sNaN -> NaN Invalid_operation -- propagating NaNs maxx181 max NaN9 -Inf -> NaN9 maxx182 max NaN8 9 -> NaN8 maxx183 max -NaN7 Inf -> -NaN7 maxx184 max NaN6 NaN5 -> NaN6 maxx185 max -Inf NaN4 -> NaN4 maxx186 max -9 -NaN3 -> -NaN3 maxx187 max Inf NaN2 -> NaN2 maxx191 max sNaN99 -Inf -> NaN99 Invalid_operation maxx192 max sNaN98 -1 -> NaN98 Invalid_operation maxx193 max -sNaN97 NaN -> -NaN97 Invalid_operation maxx194 max sNaN96 sNaN94 -> NaN96 Invalid_operation maxx195 max NaN95 sNaN93 -> NaN93 Invalid_operation maxx196 max -Inf sNaN92 -> NaN92 Invalid_operation maxx197 max 0 sNaN91 -> NaN91 Invalid_operation maxx198 max Inf -sNaN90 -> -NaN90 Invalid_operation maxx199 max NaN sNaN89 -> NaN89 Invalid_operation -- rounding checks maxexponent: 999 minexponent: -999 precision: 9 maxx201 max 12345678000 1 -> 1.23456780E+10 Rounded maxx202 max 1 12345678000 -> 1.23456780E+10 Rounded maxx203 max 1234567800 1 -> 1.23456780E+9 Rounded maxx204 max 1 1234567800 -> 1.23456780E+9 Rounded maxx205 max 1234567890 1 -> 1.23456789E+9 Rounded maxx206 max 1 1234567890 -> 1.23456789E+9 Rounded maxx207 max 1234567891 1 -> 1.23456789E+9 Inexact Rounded maxx208 max 1 1234567891 -> 1.23456789E+9 Inexact Rounded maxx209 max 12345678901 1 -> 1.23456789E+10 Inexact Rounded maxx210 max 1 12345678901 -> 1.23456789E+10 Inexact Rounded maxx211 max 1234567896 1 -> 1.23456790E+9 Inexact Rounded maxx212 max 1 1234567896 -> 1.23456790E+9 Inexact Rounded maxx213 max -1234567891 1 -> 1 maxx214 max 1 -1234567891 -> 1 maxx215 max -12345678901 1 -> 1 maxx216 max 1 -12345678901 -> 1 maxx217 max -1234567896 1 -> 1 maxx218 max 1 -1234567896 -> 1 precision: 15 maxx221 max 12345678000 1 -> 12345678000 maxx222 max 1 12345678000 -> 12345678000 maxx223 max 1234567800 1 -> 1234567800 maxx224 max 1 1234567800 -> 1234567800 maxx225 max 1234567890 1 -> 1234567890 maxx226 max 1 1234567890 -> 1234567890 maxx227 max 1234567891 1 -> 1234567891 maxx228 max 1 1234567891 -> 1234567891 maxx229 max 12345678901 1 -> 12345678901 maxx230 max 1 12345678901 -> 12345678901 maxx231 max 1234567896 1 -> 1234567896 maxx232 max 1 1234567896 -> 1234567896 maxx233 max -1234567891 1 -> 1 maxx234 max 1 -1234567891 -> 1 maxx235 max -12345678901 1 -> 1 maxx236 max 1 -12345678901 -> 1 maxx237 max -1234567896 1 -> 1 maxx238 max 1 -1234567896 -> 1 -- from examples maxx280 max '3' '2' -> '3' maxx281 max '-10' '3' -> '3' maxx282 max '1.0' '1' -> '1.0' maxx283 max '1' '1.0' -> '1' -- overflow and underflow tests ... maxExponent: 999999999 minexponent: -999999999 maxx330 max +1.23456789012345E-0 9E+999999999 -> 9E+999999999 maxx331 max 9E+999999999 +1.23456789012345E-0 -> 9E+999999999 maxx332 max +0.100 9E-999999999 -> 0.100 maxx333 max 9E-999999999 +0.100 -> 0.100 maxx335 max -1.23456789012345E-0 9E+999999999 -> 9E+999999999 maxx336 max 9E+999999999 -1.23456789012345E-0 -> 9E+999999999 maxx337 max -0.100 9E-999999999 -> 9E-999999999 maxx338 max 9E-999999999 -0.100 -> 9E-999999999 maxx339 max 1e-599999999 1e-400000001 -> 1E-400000001 maxx340 max 1e-599999999 1e-400000000 -> 1E-400000000 maxx341 max 1e-600000000 1e-400000000 -> 1E-400000000 maxx342 max 9e-999999998 0.01 -> 0.01 maxx343 max 9e-999999998 0.1 -> 0.1 maxx344 max 0.01 9e-999999998 -> 0.01 maxx345 max 1e599999999 1e400000001 -> 1E+599999999 maxx346 max 1e599999999 1e400000000 -> 1E+599999999 maxx347 max 1e600000000 1e400000000 -> 1E+600000000 maxx348 max 9e999999998 100 -> 9E+999999998 maxx349 max 9e999999998 10 -> 9E+999999998 maxx350 max 100 9e999999998 -> 9E+999999998 -- signs maxx351 max 1e+777777777 1e+411111111 -> 1E+777777777 maxx352 max 1e+777777777 -1e+411111111 -> 1E+777777777 maxx353 max -1e+777777777 1e+411111111 -> 1E+411111111 maxx354 max -1e+777777777 -1e+411111111 -> -1E+411111111 maxx355 max 1e-777777777 1e-411111111 -> 1E-411111111 maxx356 max 1e-777777777 -1e-411111111 -> 1E-777777777 maxx357 max -1e-777777777 1e-411111111 -> 1E-411111111 maxx358 max -1e-777777777 -1e-411111111 -> -1E-777777777 -- overflow tests maxexponent: 999999999 minexponent: -999999999 precision: 3 maxx400 max 9.999E+999999999 0 -> Infinity Inexact Overflow Rounded maxx401 max -9.999E+999999999 0 -> 0 -- subnormals and underflow precision: 3 maxexponent: 999 minexponent: -999 maxx410 max 1.00E-999 0 -> 1.00E-999 maxx411 max 0.1E-999 0 -> 1E-1000 Subnormal maxx412 max 0.10E-999 0 -> 1.0E-1000 Subnormal maxx413 max 0.100E-999 0 -> 1.0E-1000 Subnormal Rounded maxx414 max 0.01E-999 0 -> 1E-1001 Subnormal -- next is rounded to Emin maxx415 max 0.999E-999 0 -> 1.00E-999 Inexact Rounded Subnormal Underflow maxx416 max 0.099E-999 0 -> 1.0E-1000 Inexact Rounded Subnormal Underflow maxx417 max 0.009E-999 0 -> 1E-1001 Inexact Rounded Subnormal Underflow maxx418 max 0.001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow maxx419 max 0.0009E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow maxx420 max 0.0001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow maxx430 max -1.00E-999 0 -> 0 maxx431 max -0.1E-999 0 -> 0 maxx432 max -0.10E-999 0 -> 0 maxx433 max -0.100E-999 0 -> 0 maxx434 max -0.01E-999 0 -> 0 maxx435 max -0.999E-999 0 -> 0 maxx436 max -0.099E-999 0 -> 0 maxx437 max -0.009E-999 0 -> 0 maxx438 max -0.001E-999 0 -> 0 maxx439 max -0.0009E-999 0 -> 0 maxx440 max -0.0001E-999 0 -> 0 -- Null tests maxx900 max 10 # -> NaN Invalid_operation maxx901 max # 10 -> NaN Invalid_operation --- NEW FILE: min.decTest --- ------------------------------------------------------------------------ -- min.decTest -- decimal minimum -- -- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding extended: 1 precision: 9 rounding: half_up maxExponent: 384 minexponent: -383 -- sanity checks mnmx001 min -2 -2 -> -2 mnmx002 min -2 -1 -> -2 mnmx003 min -2 0 -> -2 mnmx004 min -2 1 -> -2 mnmx005 min -2 2 -> -2 mnmx006 min -1 -2 -> -2 mnmx007 min -1 -1 -> -1 mnmx008 min -1 0 -> -1 mnmx009 min -1 1 -> -1 mnmx010 min -1 2 -> -1 mnmx011 min 0 -2 -> -2 mnmx012 min 0 -1 -> -1 mnmx013 min 0 0 -> 0 mnmx014 min 0 1 -> 0 mnmx015 min 0 2 -> 0 mnmx016 min 1 -2 -> -2 mnmx017 min 1 -1 -> -1 mnmx018 min 1 0 -> 0 mnmx019 min 1 1 -> 1 mnmx020 min 1 2 -> 1 mnmx021 min 2 -2 -> -2 mnmx022 min 2 -1 -> -1 mnmx023 min 2 0 -> 0 mnmx025 min 2 1 -> 1 mnmx026 min 2 2 -> 2 -- extended zeros mnmx030 min 0 0 -> 0 mnmx031 min 0 -0 -> 0 mnmx032 min 0 -0.0 -> 0 mnmx033 min 0 0.0 -> 0 mnmx034 min -0 0 -> -0 mnmx035 min -0 -0 -> -0 mnmx036 min -0 -0.0 -> -0 mnmx037 min -0 0.0 -> -0 mnmx038 min 0.0 0 -> 0.0 mnmx039 min 0.0 -0 -> 0.0 mnmx040 min 0.0 -0.0 -> 0.0 mnmx041 min 0.0 0.0 -> 0.0 mnmx042 min -0.0 0 -> -0.0 mnmx043 min -0.0 -0 -> -0.0 mnmx044 min -0.0 -0.0 -> -0.0 mnmx045 min -0.0 0.0 -> -0.0 mnmx046 min -0E1 0E2 -> -0E+1 mnmx047 min 0E2 0E1 -> 0E+2 mnmx048 min 0E1 0E2 -> 0E+1 mnmx049 min -0E3 -0E2 -> -0E+3 -- Specials precision: 9 mnmx090 min Inf -Inf -> -Infinity mnmx091 min Inf -1000 -> -1000 mnmx092 min Inf -1 -> -1 mnmx093 min Inf -0 -> -0 mnmx094 min Inf 0 -> 0 mnmx095 min Inf 1 -> 1 mnmx096 min Inf 1000 -> 1000 mnmx097 min Inf Inf -> Infinity mnmx098 min -1000 Inf -> -1000 mnmx099 min -Inf Inf -> -Infinity mnmx100 min -1 Inf -> -1 mnmx101 min -0 Inf -> -0 mnmx102 min 0 Inf -> 0 mnmx103 min 1 Inf -> 1 mnmx104 min 1000 Inf -> 1000 mnmx105 min Inf Inf -> Infinity mnmx120 min -Inf -Inf -> -Infinity mnmx121 min -Inf -1000 -> -Infinity mnmx122 min -Inf -1 -> -Infinity mnmx123 min -Inf -0 -> -Infinity mnmx124 min -Inf 0 -> -Infinity mnmx125 min -Inf 1 -> -Infinity mnmx126 min -Inf 1000 -> -Infinity mnmx127 min -Inf Inf -> -Infinity mnmx128 min -Inf -Inf -> -Infinity mnmx129 min -1000 -Inf -> -Infinity mnmx130 min -1 -Inf -> -Infinity mnmx131 min -0 -Inf -> -Infinity mnmx132 min 0 -Inf -> -Infinity mnmx133 min 1 -Inf -> -Infinity mnmx134 min 1000 -Inf -> -Infinity mnmx135 min Inf -Inf -> -Infinity mnmx141 min NaN -Inf -> NaN mnmx142 min NaN -1000 -> NaN mnmx143 min NaN -1 -> NaN mnmx144 min NaN -0 -> NaN mnmx145 min NaN 0 -> NaN mnmx146 min NaN 1 -> NaN mnmx147 min NaN 1000 -> NaN mnmx148 min NaN Inf -> NaN mnmx149 min NaN NaN -> NaN mnmx150 min -Inf NaN -> NaN mnmx151 min -1000 NaN -> NaN mnmx152 min -1 -NaN -> -NaN mnmx153 min -0 NaN -> NaN mnmx154 min 0 -NaN -> -NaN mnmx155 min 1 NaN -> NaN mnmx156 min 1000 NaN -> NaN mnmx157 min Inf NaN -> NaN mnmx161 min sNaN -Inf -> NaN Invalid_operation mnmx162 min sNaN -1000 -> NaN Invalid_operation mnmx163 min sNaN -1 -> NaN Invalid_operation mnmx164 min sNaN -0 -> NaN Invalid_operation mnmx165 min -sNaN 0 -> -NaN Invalid_operation mnmx166 min -sNaN 1 -> -NaN Invalid_operation mnmx167 min sNaN 1000 -> NaN Invalid_operation mnmx168 min sNaN NaN -> NaN Invalid_operation mnmx169 min sNaN sNaN -> NaN Invalid_operation mnmx170 min NaN sNaN -> NaN Invalid_operation mnmx171 min -Inf sNaN -> NaN Invalid_operation mnmx172 min -1000 sNaN -> NaN Invalid_operation mnmx173 min -1 sNaN -> NaN Invalid_operation mnmx174 min -0 sNaN -> NaN Invalid_operation mnmx175 min 0 sNaN -> NaN Invalid_operation mnmx176 min 1 sNaN -> NaN Invalid_operation mnmx177 min 1000 sNaN -> NaN Invalid_operation mnmx178 min Inf sNaN -> NaN Invalid_operation mnmx179 min NaN sNaN -> NaN Invalid_operation -- propagating NaNs mnmx181 min NaN9 -Inf -> NaN9 mnmx182 min -NaN8 9990 -> -NaN8 mnmx183 min NaN71 Inf -> NaN71 mnmx184 min NaN6 NaN51 -> NaN6 mnmx185 min -Inf NaN41 -> NaN41 mnmx186 min -9999 -NaN33 -> -NaN33 mnmx187 min Inf NaN2 -> NaN2 mnmx191 min sNaN99 -Inf -> NaN99 Invalid_operation mnmx192 min sNaN98 -11 -> NaN98 Invalid_operation mnmx193 min -sNaN97 NaN -> -NaN97 Invalid_operation mnmx194 min sNaN69 sNaN94 -> NaN69 Invalid_operation mnmx195 min NaN95 sNaN93 -> NaN93 Invalid_operation mnmx196 min -Inf sNaN92 -> NaN92 Invalid_operation mnmx197 min 088 sNaN91 -> NaN91 Invalid_operation mnmx198 min Inf -sNaN90 -> -NaN90 Invalid_operation mnmx199 min NaN sNaN86 -> NaN86 Invalid_operation -- rounding checks -- chosen is rounded, or not maxExponent: 999 minexponent: -999 precision: 9 mnmx201 min -12345678000 1 -> -1.23456780E+10 Rounded mnmx202 min 1 -12345678000 -> -1.23456780E+10 Rounded mnmx203 min -1234567800 1 -> -1.23456780E+9 Rounded mnmx204 min 1 -1234567800 -> -1.23456780E+9 Rounded mnmx205 min -1234567890 1 -> -1.23456789E+9 Rounded mnmx206 min 1 -1234567890 -> -1.23456789E+9 Rounded mnmx207 min -1234567891 1 -> -1.23456789E+9 Inexact Rounded mnmx208 min 1 -1234567891 -> -1.23456789E+9 Inexact Rounded mnmx209 min -12345678901 1 -> -1.23456789E+10 Inexact Rounded mnmx210 min 1 -12345678901 -> -1.23456789E+10 Inexact Rounded mnmx211 min -1234567896 1 -> -1.23456790E+9 Inexact Rounded mnmx212 min 1 -1234567896 -> -1.23456790E+9 Inexact Rounded mnmx213 min 1234567891 1 -> 1 mnmx214 min 1 1234567891 -> 1 mnmx215 min 12345678901 1 -> 1 mnmx216 min 1 12345678901 -> 1 mnmx217 min 1234567896 1 -> 1 mnmx218 min 1 1234567896 -> 1 precision: 15 mnmx221 min -12345678000 1 -> -12345678000 mnmx222 min 1 -12345678000 -> -12345678000 mnmx223 min -1234567800 1 -> -1234567800 mnmx224 min 1 -1234567800 -> -1234567800 mnmx225 min -1234567890 1 -> -1234567890 mnmx226 min 1 -1234567890 -> -1234567890 mnmx227 min -1234567891 1 -> -1234567891 mnmx228 min 1 -1234567891 -> -1234567891 mnmx229 min -12345678901 1 -> -12345678901 mnmx230 min 1 -12345678901 -> -12345678901 mnmx231 min -1234567896 1 -> -1234567896 mnmx232 min 1 -1234567896 -> -1234567896 mnmx233 min 1234567891 1 -> 1 mnmx234 min 1 1234567891 -> 1 mnmx235 min 12345678901 1 -> 1 mnmx236 min 1 12345678901 -> 1 mnmx237 min 1234567896 1 -> 1 mnmx238 min 1 1234567896 -> 1 -- from examples mnmx280 min '3' '2' -> '2' mnmx281 min '-10' '3' -> '-10' mnmx282 min '1.0' '1' -> '1.0' mnmx283 min '1' '1.0' -> '1' -- overflow and underflow tests .. subnormal results [inputs] now allowed maxExponent: 999999999 minexponent: -999999999 mnmx330 min -1.23456789012345E-0 -9E+999999999 -> -9E+999999999 mnmx331 min -9E+999999999 -1.23456789012345E-0 -> -9E+999999999 mnmx332 min -0.100 -9E-999999999 -> -0.100 mnmx333 min -9E-999999999 -0.100 -> -0.100 mnmx335 min +1.23456789012345E-0 -9E+999999999 -> -9E+999999999 mnmx336 min -9E+999999999 1.23456789012345E-0 -> -9E+999999999 mnmx337 min +0.100 -9E-999999999 -> -9E-999999999 mnmx338 min -9E-999999999 0.100 -> -9E-999999999 mnmx339 min -1e-599999999 -1e-400000001 -> -1E-400000001 mnmx340 min -1e-599999999 -1e-400000000 -> -1E-400000000 mnmx341 min -1e-600000000 -1e-400000000 -> -1E-400000000 mnmx342 min -9e-999999998 -0.01 -> -0.01 mnmx343 min -9e-999999998 -0.1 -> -0.1 mnmx344 min -0.01 -9e-999999998 -> -0.01 mnmx345 min -1e599999999 -1e400000001 -> -1E+599999999 mnmx346 min -1e599999999 -1e400000000 -> -1E+599999999 mnmx347 min -1e600000000 -1e400000000 -> -1E+600000000 mnmx348 min -9e999999998 -100 -> -9E+999999998 mnmx349 min -9e999999998 -10 -> -9E+999999998 mnmx350 min -100 -9e999999998 -> -9E+999999998 -- signs mnmx351 min -1e+777777777 -1e+411111111 -> -1E+777777777 mnmx352 min -1e+777777777 +1e+411111111 -> -1E+777777777 mnmx353 min +1e+777777777 -1e+411111111 -> -1E+411111111 mnmx354 min +1e+777777777 +1e+411111111 -> 1E+411111111 mnmx355 min -1e-777777777 -1e-411111111 -> -1E-411111111 mnmx356 min -1e-777777777 +1e-411111111 -> -1E-777777777 mnmx357 min +1e-777777777 -1e-411111111 -> -1E-411111111 mnmx358 min +1e-777777777 +1e-411111111 -> 1E-777777777 -- overflow tests maxexponent: 999999999 minexponent: -999999999 precision: 3 mnmx400 min 9.999E+999999999 0 -> 0 mnmx401 min -9.999E+999999999 0 -> -Infinity Inexact Overflow Rounded -- subnormals and underflow precision: 3 maxexponent: 999 minexponent: -999 mnmx410 min 1.00E-999 0 -> 0 mnmx411 min 0.1E-999 0 -> 0 mnmx412 min 0.10E-999 0 -> 0 mnmx413 min 0.100E-999 0 -> 0 mnmx414 min 0.01E-999 0 -> 0 mnmx415 min 0.999E-999 0 -> 0 mnmx416 min 0.099E-999 0 -> 0 mnmx417 min 0.009E-999 0 -> 0 mnmx418 min 0.001E-999 0 -> 0 mnmx419 min 0.0009E-999 0 -> 0 mnmx420 min 0.0001E-999 0 -> 0 mnmx430 min -1.00E-999 0 -> -1.00E-999 mnmx431 min -0.1E-999 0 -> -1E-1000 Subnormal mnmx432 min -0.10E-999 0 -> -1.0E-1000 Subnormal mnmx433 min -0.100E-999 0 -> -1.0E-1000 Subnormal Rounded mnmx434 min -0.01E-999 0 -> -1E-1001 Subnormal -- next is rounded to Emin mnmx435 min -0.999E-999 0 -> -1.00E-999 Inexact Rounded Subnormal Underflow mnmx436 min -0.099E-999 0 -> -1.0E-1000 Inexact Rounded Subnormal Underflow mnmx437 min -0.009E-999 0 -> -1E-1001 Inexact Rounded Subnormal Underflow mnmx438 min -0.001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow mnmx439 min -0.0009E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow mnmx440 min -0.0001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow -- Null tests mnm900 min 10 # -> NaN Invalid_operation mnm901 min # 10 -> NaN Invalid_operation --- NEW FILE: minus.decTest --- ------------------------------------------------------------------------ -- minus.decTest -- decimal negation -- -- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 -- This set of tests primarily tests the existence of the operator. -- Subtraction, rounding, and more overflows are tested elsewhere. extended: 1 precision: 9 rounding: half_up maxExponent: 384 minexponent: -383 minx001 minus '1' -> '-1' minx002 minus '-1' -> '1' minx003 minus '1.00' -> '-1.00' minx004 minus '-1.00' -> '1.00' minx005 minus '0' -> '0' minx006 minus '0.00' -> '0.00' minx007 minus '00.0' -> '0.0' minx008 minus '00.00' -> '0.00' minx009 minus '00' -> '0' minx010 minus '-2' -> '2' minx011 minus '2' -> '-2' minx012 minus '-2.00' -> '2.00' minx013 minus '2.00' -> '-2.00' minx014 minus '-0' -> '0' minx015 minus '-0.00' -> '0.00' minx016 minus '-00.0' -> '0.0' minx017 minus '-00.00' -> '0.00' minx018 minus '-00' -> '0' -- "lhs" zeros in plus and minus have exponent = operand minx020 minus '-0E3' -> '0E+3' minx021 minus '-0E2' -> '0E+2' minx022 minus '-0E1' -> '0E+1' minx023 minus '-0E0' -> '0' minx024 minus '+0E0' -> '0' minx025 minus '+0E1' -> '0E+1' minx026 minus '+0E2' -> '0E+2' minx027 minus '+0E3' -> '0E+3' minx030 minus '-5E3' -> '5E+3' minx031 minus '-5E8' -> '5E+8' minx032 minus '-5E13' -> '5E+13' minx033 minus '-5E18' -> '5E+18' minx034 minus '+5E3' -> '-5E+3' minx035 minus '+5E8' -> '-5E+8' minx036 minus '+5E13' -> '-5E+13' minx037 minus '+5E18' -> '-5E+18' minx050 minus '-2000000' -> '2000000' minx051 minus '2000000' -> '-2000000' precision: 7 minx052 minus '-2000000' -> '2000000' minx053 minus '2000000' -> '-2000000' precision: 6 minx054 minus '-2000000' -> '2.00000E+6' Rounded minx055 minus '2000000' -> '-2.00000E+6' Rounded precision: 3 minx056 minus '-2000000' -> '2.00E+6' Rounded minx057 minus '2000000' -> '-2.00E+6' Rounded -- more fixed, potential LHS swaps/overlays if done by 0 subtract x precision: 9 minx060 minus '56267E-10' -> '-0.0000056267' minx061 minus '56267E-5' -> '-0.56267' minx062 minus '56267E-2' -> '-562.67' minx063 minus '56267E-1' -> '-5626.7' minx065 minus '56267E-0' -> '-56267' minx066 minus '56267E+0' -> '-56267' minx067 minus '56267E+1' -> '-5.6267E+5' minx068 minus '56267E+2' -> '-5.6267E+6' minx069 minus '56267E+3' -> '-5.6267E+7' minx070 minus '56267E+4' -> '-5.6267E+8' minx071 minus '56267E+5' -> '-5.6267E+9' minx072 minus '56267E+6' -> '-5.6267E+10' minx080 minus '-56267E-10' -> '0.0000056267' minx081 minus '-56267E-5' -> '0.56267' minx082 minus '-56267E-2' -> '562.67' minx083 minus '-56267E-1' -> '5626.7' minx085 minus '-56267E-0' -> '56267' minx086 minus '-56267E+0' -> '56267' minx087 minus '-56267E+1' -> '5.6267E+5' minx088 minus '-56267E+2' -> '5.6267E+6' minx089 minus '-56267E+3' -> '5.6267E+7' minx090 minus '-56267E+4' -> '5.6267E+8' minx091 minus '-56267E+5' -> '5.6267E+9' minx092 minus '-56267E+6' -> '5.6267E+10' -- overflow tests maxexponent: 999999999 minexponent: -999999999 precision: 3 minx100 minus 9.999E+999999999 -> -Infinity Inexact Overflow Rounded minx101 minus -9.999E+999999999 -> Infinity Inexact Overflow Rounded -- subnormals and underflow precision: 3 maxexponent: 999 minexponent: -999 minx110 minus 1.00E-999 -> -1.00E-999 minx111 minus 0.1E-999 -> -1E-1000 Subnormal minx112 minus 0.10E-999 -> -1.0E-1000 Subnormal minx113 minus 0.100E-999 -> -1.0E-1000 Subnormal Rounded minx114 minus 0.01E-999 -> -1E-1001 Subnormal -- next is rounded to Emin minx115 minus 0.999E-999 -> -1.00E-999 Inexact Rounded Subnormal Underflow minx116 minus 0.099E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow minx117 minus 0.009E-999 -> -1E-1001 Inexact Rounded Subnormal Underflow minx118 minus 0.001E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow minx119 minus 0.0009E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow minx120 minus 0.0001E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow minx130 minus -1.00E-999 -> 1.00E-999 minx131 minus -0.1E-999 -> 1E-1000 Subnormal minx132 minus -0.10E-999 -> 1.0E-1000 Subnormal minx133 minus -0.100E-999 -> 1.0E-1000 Subnormal Rounded minx134 minus -0.01E-999 -> 1E-1001 Subnormal -- next is rounded to Emin minx135 minus -0.999E-999 -> 1.00E-999 Inexact Rounded Subnormal Underflow minx136 minus -0.099E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow minx137 minus -0.009E-999 -> 1E-1001 Inexact Rounded Subnormal Underflow minx138 minus -0.001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow minx139 minus -0.0009E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow minx140 minus -0.0001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow -- long operand checks maxexponent: 999 minexponent: -999 precision: 9 minx301 minus 12345678000 -> -1.23456780E+10 Rounded minx302 minus 1234567800 -> -1.23456780E+9 Rounded minx303 minus 1234567890 -> -1.23456789E+9 Rounded minx304 minus 1234567891 -> -1.23456789E+9 Inexact Rounded minx305 minus 12345678901 -> -1.23456789E+10 Inexact Rounded minx306 minus 1234567896 -> -1.23456790E+9 Inexact Rounded precision: 15 -- still checking minx321 minus 12345678000 -> -12345678000 minx322 minus 1234567800 -> -1234567800 minx323 minus 1234567890 -> -1234567890 minx324 minus 1234567891 -> -1234567891 minx325 minus 12345678901 -> -12345678901 minx326 minus 1234567896 -> -1234567896 -- specials minx420 minus 'Inf' -> '-Infinity' minx421 minus '-Inf' -> 'Infinity' minx422 minus NaN -> NaN minx423 minus sNaN -> NaN Invalid_operation minx424 minus NaN255 -> NaN255 minx425 minus sNaN256 -> NaN256 Invalid_operation minx426 minus -NaN -> -NaN minx427 minus -sNaN -> -NaN Invalid_operation minx428 minus -NaN255 -> -NaN255 minx429 minus -sNaN256 -> -NaN256 Invalid_operation -- Null tests minx900 minus # -> NaN Invalid_operation --- NEW FILE: multiply.decTest --- ------------------------------------------------------------------------ -- multiply.decTest -- decimal multiplication -- -- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 extended: 1 precision: 9 rounding: half_up maxExponent: 384 minexponent: -383 -- sanity checks (as base, above) mulx000 multiply 2 2 -> 4 mulx001 multiply 2 3 -> 6 mulx002 multiply 5 1 -> 5 mulx003 multiply 5 2 -> 10 mulx004 multiply 1.20 2 -> 2.40 mulx005 multiply 1.20 0 -> 0.00 mulx006 multiply 1.20 -2 -> -2.40 mulx007 multiply -1.20 2 -> -2.40 mulx008 multiply -1.20 0 -> -0.00 mulx009 multiply -1.20 -2 -> 2.40 mulx010 multiply 5.09 7.1 -> 36.139 mulx011 multiply 2.5 4 -> 10.0 mulx012 multiply 2.50 4 -> 10.00 mulx013 multiply 1.23456789 1.00000000 -> 1.23456789 Rounded mulx014 multiply 9.999999999 9.999999999 -> 100.000000 Inexact Rounded mulx015 multiply 2.50 4 -> 10.00 precision: 6 mulx016 multiply 2.50 4 -> 10.00 mulx017 multiply 9.999999999 9.999999999 -> 100.000 Inexact Rounded -- 1999.12.21: next one is a edge case if intermediate longs are used precision: 15 mulx019 multiply 999999999999 9765625 -> 9.76562499999023E+18 Inexact Rounded precision: 30 mulx160 multiply 999999999999 9765625 -> 9765624999990234375 precision: 9 ----- -- zeros, etc. mulx020 multiply 0 0 -> 0 mulx021 multiply 0 -0 -> -0 mulx022 multiply -0 0 -> -0 mulx023 multiply -0 -0 -> 0 mulx030 multiply 5.00 1E-3 -> 0.00500 mulx031 multiply 00.00 0.000 -> 0.00000 mulx032 multiply 00.00 0E-3 -> 0.00000 -- rhs is 0 mulx033 multiply 0E-3 00.00 -> 0.00000 -- lhs is 0 mulx034 multiply -5.00 1E-3 -> -0.00500 mulx035 multiply -00.00 0.000 -> -0.00000 mulx036 multiply -00.00 0E-3 -> -0.00000 -- rhs is 0 mulx037 multiply -0E-3 00.00 -> -0.00000 -- lhs is 0 mulx038 multiply 5.00 -1E-3 -> -0.00500 mulx039 multiply 00.00 -0.000 -> -0.00000 mulx040 multiply 00.00 -0E-3 -> -0.00000 -- rhs is 0 mulx041 multiply 0E-3 -00.00 -> -0.00000 -- lhs is 0 mulx042 multiply -5.00 -1E-3 -> 0.00500 mulx043 multiply -00.00 -0.000 -> 0.00000 mulx044 multiply -00.00 -0E-3 -> 0.00000 -- rhs is 0 mulx045 multiply -0E-3 -00.00 -> 0.00000 -- lhs is 0 -- examples from decarith mulx050 multiply 1.20 3 -> 3.60 mulx051 multiply 7 3 -> 21 mulx052 multiply 0.9 0.8 -> 0.72 mulx053 multiply 0.9 -0 -> -0.0 mulx054 multiply 654321 654321 -> 4.28135971E+11 Inexact Rounded mulx060 multiply 123.45 1e7 -> 1.2345E+9 mulx061 multiply 123.45 1e8 -> 1.2345E+10 mulx062 multiply 123.45 1e+9 -> 1.2345E+11 mulx063 multiply 123.45 1e10 -> 1.2345E+12 mulx064 multiply 123.45 1e11 -> 1.2345E+13 mulx065 multiply 123.45 1e12 -> 1.2345E+14 mulx066 multiply 123.45 1e13 -> 1.2345E+15 -- test some intermediate lengths precision: 9 mulx080 multiply 0.1 123456789 -> 12345678.9 mulx081 multiply 0.1 1234567891 -> 123456789 Inexact Rounded mulx082 multiply 0.1 12345678912 -> 1.23456789E+9 Inexact Rounded mulx083 multiply 0.1 12345678912345 -> 1.23456789E+12 Inexact Rounded mulx084 multiply 0.1 123456789 -> 12345678.9 precision: 8 mulx085 multiply 0.1 12345678912 -> 1.2345679E+9 Inexact Rounded mulx086 multiply 0.1 12345678912345 -> 1.2345679E+12 Inexact Rounded precision: 7 mulx087 multiply 0.1 12345678912 -> 1.234568E+9 Inexact Rounded mulx088 multiply 0.1 12345678912345 -> 1.234568E+12 Inexact Rounded precision: 9 mulx090 multiply 123456789 0.1 -> 12345678.9 mulx091 multiply 1234567891 0.1 -> 123456789 Inexact Rounded mulx092 multiply 12345678912 0.1 -> 1.23456789E+9 Inexact Rounded mulx093 multiply 12345678912345 0.1 -> 1.23456789E+12 Inexact Rounded mulx094 multiply 123456789 0.1 -> 12345678.9 precision: 8 mulx095 multiply 12345678912 0.1 -> 1.2345679E+9 Inexact Rounded mulx096 multiply 12345678912345 0.1 -> 1.2345679E+12 Inexact Rounded precision: 7 mulx097 multiply 12345678912 0.1 -> 1.234568E+9 Inexact Rounded mulx098 multiply 12345678912345 0.1 -> 1.234568E+12 Inexact Rounded -- test some more edge cases and carries maxexponent: 9999 minexponent: -9999 precision: 33 mulx101 multiply 9 9 -> 81 mulx102 multiply 9 90 -> 810 mulx103 multiply 9 900 -> 8100 mulx104 multiply 9 9000 -> 81000 mulx105 multiply 9 90000 -> 810000 mulx106 multiply 9 900000 -> 8100000 mulx107 multiply 9 9000000 -> 81000000 mulx108 multiply 9 90000000 -> 810000000 mulx109 multiply 9 900000000 -> 8100000000 mulx110 multiply 9 9000000000 -> 81000000000 mulx111 multiply 9 90000000000 -> 810000000000 mulx112 multiply 9 900000000000 -> 8100000000000 mulx113 multiply 9 9000000000000 -> 81000000000000 mulx114 multiply 9 90000000000000 -> 810000000000000 mulx115 multiply 9 900000000000000 -> 8100000000000000 mulx116 multiply 9 9000000000000000 -> 81000000000000000 mulx117 multiply 9 90000000000000000 -> 810000000000000000 mulx118 multiply 9 900000000000000000 -> 8100000000000000000 mulx119 multiply 9 9000000000000000000 -> 81000000000000000000 mulx120 multiply 9 90000000000000000000 -> 810000000000000000000 mulx121 multiply 9 900000000000000000000 -> 8100000000000000000000 mulx122 multiply 9 9000000000000000000000 -> 81000000000000000000000 mulx123 multiply 9 90000000000000000000000 -> 810000000000000000000000 -- test some more edge cases without carries mulx131 multiply 3 3 -> 9 mulx132 multiply 3 30 -> 90 mulx133 multiply 3 300 -> 900 mulx134 multiply 3 3000 -> 9000 mulx135 multiply 3 30000 -> 90000 mulx136 multiply 3 300000 -> 900000 mulx137 multiply 3 3000000 -> 9000000 mulx138 multiply 3 30000000 -> 90000000 mulx139 multiply 3 300000000 -> 900000000 mulx140 multiply 3 3000000000 -> 9000000000 mulx141 multiply 3 30000000000 -> 90000000000 mulx142 multiply 3 300000000000 -> 900000000000 mulx143 multiply 3 3000000000000 -> 9000000000000 mulx144 multiply 3 30000000000000 -> 90000000000000 mulx145 multiply 3 300000000000000 -> 900000000000000 mulx146 multiply 3 3000000000000000 -> 9000000000000000 mulx147 multiply 3 30000000000000000 -> 90000000000000000 mulx148 multiply 3 300000000000000000 -> 900000000000000000 mulx149 multiply 3 3000000000000000000 -> 9000000000000000000 mulx150 multiply 3 30000000000000000000 -> 90000000000000000000 mulx151 multiply 3 300000000000000000000 -> 900000000000000000000 mulx152 multiply 3 3000000000000000000000 -> 9000000000000000000000 mulx153 multiply 3 30000000000000000000000 -> 90000000000000000000000 maxexponent: 999999999 minexponent: -999999999 precision: 9 -- test some cases that are close to exponent overflow/underflow mulx170 multiply 1 9e999999999 -> 9E+999999999 mulx171 multiply 1 9.9e999999999 -> 9.9E+999999999 mulx172 multiply 1 9.99e999999999 -> 9.99E+999999999 mulx173 multiply 9e999999999 1 -> 9E+999999999 mulx174 multiply 9.9e999999999 1 -> 9.9E+999999999 mulx176 multiply 9.99e999999999 1 -> 9.99E+999999999 mulx177 multiply 1 9.99999999e999999999 -> 9.99999999E+999999999 mulx178 multiply 9.99999999e999999999 1 -> 9.99999999E+999999999 mulx180 multiply 0.1 9e-999999998 -> 9E-999999999 mulx181 multiply 0.1 99e-999999998 -> 9.9E-999999998 mulx182 multiply 0.1 999e-999999998 -> 9.99E-999999997 mulx183 multiply 0.1 9e-999999998 -> 9E-999999999 mulx184 multiply 0.1 99e-999999998 -> 9.9E-999999998 mulx185 multiply 0.1 999e-999999998 -> 9.99E-999999997 mulx186 multiply 0.1 999e-999999997 -> 9.99E-999999996 mulx187 multiply 0.1 9999e-999999997 -> 9.999E-999999995 mulx188 multiply 0.1 99999e-999999997 -> 9.9999E-999999994 mulx190 multiply 1 9e-999999998 -> 9E-999999998 mulx191 multiply 1 99e-999999998 -> 9.9E-999999997 mulx192 multiply 1 999e-999999998 -> 9.99E-999999996 mulx193 multiply 9e-999999998 1 -> 9E-999999998 mulx194 multiply 99e-999999998 1 -> 9.9E-999999997 mulx195 multiply 999e-999999998 1 -> 9.99E-999999996 mulx196 multiply 1e-599999999 1e-400000000 -> 1E-999999999 mulx197 multiply 1e-600000000 1e-399999999 -> 1E-999999999 mulx198 multiply 1.2e-599999999 1.2e-400000000 -> 1.44E-999999999 mulx199 multiply 1.2e-600000000 1.2e-399999999 -> 1.44E-999999999 mulx201 multiply 1e599999999 1e400000000 -> 1E+999999999 mulx202 multiply 1e600000000 1e399999999 -> 1E+999999999 mulx203 multiply 1.2e599999999 1.2e400000000 -> 1.44E+999999999 mulx204 multiply 1.2e600000000 1.2e399999999 -> 1.44E+999999999 -- long operand triangle precision: 33 mulx246 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.290801193369671916511992830 Inexact Rounded precision: 32 mulx247 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.29080119336967191651199283 Inexact Rounded precision: 31 mulx248 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908011933696719165119928 Inexact Rounded precision: 30 mulx249 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.290801193369671916511993 Inexact Rounded precision: 29 mulx250 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.29080119336967191651199 Inexact Rounded precision: 28 mulx251 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908011933696719165120 Inexact Rounded precision: 27 mulx252 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.290801193369671916512 Inexact Rounded precision: 26 mulx253 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.29080119336967191651 Inexact Rounded precision: 25 mulx254 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908011933696719165 Inexact Rounded precision: 24 mulx255 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.290801193369671917 Inexact Rounded precision: 23 mulx256 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.29080119336967192 Inexact Rounded precision: 22 mulx257 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908011933696719 Inexact Rounded precision: 21 mulx258 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.290801193369672 Inexact Rounded precision: 20 mulx259 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.29080119336967 Inexact Rounded precision: 19 mulx260 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908011933697 Inexact Rounded precision: 18 mulx261 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.290801193370 Inexact Rounded precision: 17 mulx262 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.29080119337 Inexact Rounded precision: 16 mulx263 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908011934 Inexact Rounded precision: 15 mulx264 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.290801193 Inexact Rounded precision: 14 mulx265 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.29080119 Inexact Rounded precision: 13 mulx266 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908012 Inexact Rounded precision: 12 mulx267 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.290801 Inexact Rounded precision: 11 mulx268 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.29080 Inexact Rounded precision: 10 mulx269 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908 Inexact Rounded precision: 9 mulx270 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.291 Inexact Rounded precision: 8 mulx271 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.29 Inexact Rounded precision: 7 mulx272 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.3 Inexact Rounded precision: 6 mulx273 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433 Inexact Rounded precision: 5 mulx274 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 1.4543E+5 Inexact Rounded precision: 4 mulx275 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 1.454E+5 Inexact Rounded precision: 3 mulx276 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 1.45E+5 Inexact Rounded precision: 2 mulx277 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 1.5E+5 Inexact Rounded precision: 1 mulx278 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 1E+5 Inexact Rounded -- tryzeros cases precision: 7 rounding: half_up maxExponent: 92 minexponent: -92 mulx504 multiply 0E-60 1000E-60 -> 0E-98 Clamped mulx505 multiply 100E+60 0E+60 -> 0E+92 Clamped -- mixed with zeros maxexponent: 999999999 minexponent: -999999999 precision: 9 mulx541 multiply 0 -1 -> -0 mulx542 multiply -0 -1 -> 0 mulx543 multiply 0 1 -> 0 mulx544 multiply -0 1 -> -0 mulx545 multiply -1 0 -> -0 mulx546 multiply -1 -0 -> 0 mulx547 multiply 1 0 -> 0 mulx548 multiply 1 -0 -> -0 mulx551 multiply 0.0 -1 -> -0.0 mulx552 multiply -0.0 -1 -> 0.0 mulx553 multiply 0.0 1 -> 0.0 mulx554 multiply -0.0 1 -> -0.0 mulx555 multiply -1.0 0 -> -0.0 mulx556 multiply -1.0 -0 -> 0.0 mulx557 multiply 1.0 0 -> 0.0 mulx558 multiply 1.0 -0 -> -0.0 mulx561 multiply 0 -1.0 -> -0.0 mulx562 multiply -0 -1.0 -> 0.0 mulx563 multiply 0 1.0 -> 0.0 mulx564 multiply -0 1.0 -> -0.0 mulx565 multiply -1 0.0 -> -0.0 mulx566 multiply -1 -0.0 -> 0.0 mulx567 multiply 1 0.0 -> 0.0 mulx568 multiply 1 -0.0 -> -0.0 mulx571 multiply 0.0 -1.0 -> -0.00 mulx572 multiply -0.0 -1.0 -> 0.00 mulx573 multiply 0.0 1.0 -> 0.00 mulx574 multiply -0.0 1.0 -> -0.00 mulx575 multiply -1.0 0.0 -> -0.00 mulx576 multiply -1.0 -0.0 -> 0.00 mulx577 multiply 1.0 0.0 -> 0.00 mulx578 multiply 1.0 -0.0 -> -0.00 -- Specials mulx580 multiply Inf -Inf -> -Infinity mulx581 multiply Inf -1000 -> -Infinity mulx582 multiply Inf -1 -> -Infinity mulx583 multiply Inf -0 -> NaN Invalid_operation mulx584 multiply Inf 0 -> NaN Invalid_operation mulx585 multiply Inf 1 -> Infinity mulx586 multiply Inf 1000 -> Infinity mulx587 multiply Inf Inf -> Infinity mulx588 multiply -1000 Inf -> -Infinity mulx589 multiply -Inf Inf -> -Infinity mulx590 multiply -1 Inf -> -Infinity mulx591 multiply -0 Inf -> NaN Invalid_operation mulx592 multiply 0 Inf -> NaN Invalid_operation mulx593 multiply 1 Inf -> Infinity mulx594 multiply 1000 Inf -> Infinity mulx595 multiply Inf Inf -> Infinity mulx600 multiply -Inf -Inf -> Infinity mulx601 multiply -Inf -1000 -> Infinity mulx602 multiply -Inf -1 -> Infinity mulx603 multiply -Inf -0 -> NaN Invalid_operation mulx604 multiply -Inf 0 -> NaN Invalid_operation mulx605 multiply -Inf 1 -> -Infinity mulx606 multiply -Inf 1000 -> -Infinity mulx607 multiply -Inf Inf -> -Infinity mulx608 multiply -1000 Inf -> -Infinity mulx609 multiply -Inf -Inf -> Infinity mulx610 multiply -1 -Inf -> Infinity mulx611 multiply -0 -Inf -> NaN Invalid_operation mulx612 multiply 0 -Inf -> NaN Invalid_operation mulx613 multiply 1 -Inf -> -Infinity mulx614 multiply 1000 -Inf -> -Infinity mulx615 multiply Inf -Inf -> -Infinity mulx621 multiply NaN -Inf -> NaN mulx622 multiply NaN -1000 -> NaN mulx623 multiply NaN -1 -> NaN mulx624 multiply NaN -0 -> NaN mulx625 multiply NaN 0 -> NaN mulx626 multiply NaN 1 -> NaN mulx627 multiply NaN 1000 -> NaN mulx628 multiply NaN Inf -> NaN mulx629 multiply NaN NaN -> NaN mulx630 multiply -Inf NaN -> NaN mulx631 multiply -1000 NaN -> NaN mulx632 multiply -1 NaN -> NaN mulx633 multiply -0 NaN -> NaN mulx634 multiply 0 NaN -> NaN mulx635 multiply 1 NaN -> NaN mulx636 multiply 1000 NaN -> NaN mulx637 multiply Inf NaN -> NaN mulx641 multiply sNaN -Inf -> NaN Invalid_operation mulx642 multiply sNaN -1000 -> NaN Invalid_operation mulx643 multiply sNaN -1 -> NaN Invalid_operation mulx644 multiply sNaN -0 -> NaN Invalid_operation mulx645 multiply sNaN 0 -> NaN Invalid_operation mulx646 multiply sNaN 1 -> NaN Invalid_operation mulx647 multiply sNaN 1000 -> NaN Invalid_operation mulx648 multiply sNaN NaN -> NaN Invalid_operation mulx649 multiply sNaN sNaN -> NaN Invalid_operation mulx650 multiply NaN sNaN -> NaN Invalid_operation mulx651 multiply -Inf sNaN -> NaN Invalid_operation mulx652 multiply -1000 sNaN -> NaN Invalid_operation mulx653 multiply -1 sNaN -> NaN Invalid_operation mulx654 multiply -0 sNaN -> NaN Invalid_operation mulx655 multiply 0 sNaN -> NaN Invalid_operation mulx656 multiply 1 sNaN -> NaN Invalid_operation mulx657 multiply 1000 sNaN -> NaN Invalid_operation mulx658 multiply Inf sNaN -> NaN Invalid_operation mulx659 multiply NaN sNaN -> NaN Invalid_operation -- propagating NaNs mulx661 multiply NaN9 -Inf -> NaN9 mulx662 multiply NaN8 999 -> NaN8 mulx663 multiply NaN71 Inf -> NaN71 mulx664 multiply NaN6 NaN5 -> NaN6 mulx665 multiply -Inf NaN4 -> NaN4 mulx666 multiply -999 NaN33 -> NaN33 mulx667 multiply Inf NaN2 -> NaN2 mulx671 multiply sNaN99 -Inf -> NaN99 Invalid_operation mulx672 multiply sNaN98 -11 -> NaN98 Invalid_operation mulx673 multiply sNaN97 NaN -> NaN97 Invalid_operation mulx674 multiply sNaN16 sNaN94 -> NaN16 Invalid_operation mulx675 multiply NaN95 sNaN93 -> NaN93 Invalid_operation mulx676 multiply -Inf sNaN92 -> NaN92 Invalid_operation mulx677 multiply 088 sNaN91 -> NaN91 Invalid_operation mulx678 multiply Inf sNaN90 -> NaN90 Invalid_operation mulx679 multiply NaN sNaN89 -> NaN89 Invalid_operation mulx681 multiply -NaN9 -Inf -> -NaN9 mulx682 multiply -NaN8 999 -> -NaN8 mulx683 multiply -NaN71 Inf -> -NaN71 mulx684 multiply -NaN6 -NaN5 -> -NaN6 mulx685 multiply -Inf -NaN4 -> -NaN4 mulx686 multiply -999 -NaN33 -> -NaN33 mulx687 multiply Inf -NaN2 -> -NaN2 mulx691 multiply -sNaN99 -Inf -> -NaN99 Invalid_operation mulx692 multiply -sNaN98 -11 -> -NaN98 Invalid_operation mulx693 multiply -sNaN97 NaN -> -NaN97 Invalid_operation mulx694 multiply -sNaN16 -sNaN94 -> -NaN16 Invalid_operation mulx695 multiply -NaN95 -sNaN93 -> -NaN93 Invalid_operation mulx696 multiply -Inf -sNaN92 -> -NaN92 Invalid_operation mulx697 multiply 088 -sNaN91 -> -NaN91 Invalid_operation mulx698 multiply Inf -sNaN90 -> -NaN90 Invalid_operation mulx699 multiply -NaN -sNaN89 -> -NaN89 Invalid_operation mulx701 multiply -NaN -Inf -> -NaN mulx702 multiply -NaN 999 -> -NaN mulx703 multiply -NaN Inf -> -NaN mulx704 multiply -NaN -NaN -> -NaN mulx705 multiply -Inf -NaN0 -> -NaN mulx706 multiply -999 -NaN -> -NaN mulx707 multiply Inf -NaN -> -NaN mulx711 multiply -sNaN -Inf -> -NaN Invalid_operation mulx712 multiply -sNaN -11 -> -NaN Invalid_operation mulx713 multiply -sNaN00 NaN -> -NaN Invalid_operation mulx714 multiply -sNaN -sNaN -> -NaN Invalid_operation mulx715 multiply -NaN -sNaN -> -NaN Invalid_operation mulx716 multiply -Inf -sNaN -> -NaN Invalid_operation mulx717 multiply 088 -sNaN -> -NaN Invalid_operation mulx718 multiply Inf -sNaN -> -NaN Invalid_operation mulx719 multiply -NaN -sNaN -> -NaN Invalid_operation -- overflow and underflow tests .. note subnormal results maxexponent: 999999999 minexponent: -999999999 mulx730 multiply +1.23456789012345E-0 9E+999999999 -> Infinity Inexact Overflow Rounded mulx731 multiply 9E+999999999 +1.23456789012345E-0 -> Infinity Inexact Overflow Rounded mulx732 multiply +0.100 9E-999999999 -> 9.00E-1000000000 Subnormal mulx733 multiply 9E-999999999 +0.100 -> 9.00E-1000000000 Subnormal mulx735 multiply -1.23456789012345E-0 9E+999999999 -> -Infinity Inexact Overflow Rounded mulx736 multiply 9E+999999999 -1.23456789012345E-0 -> -Infinity Inexact Overflow Rounded mulx737 multiply -0.100 9E-999999999 -> -9.00E-1000000000 Subnormal mulx738 multiply 9E-999999999 -0.100 -> -9.00E-1000000000 Subnormal mulx739 multiply 1e-599999999 1e-400000001 -> 1E-1000000000 Subnormal mulx740 multiply 1e-599999999 1e-400000000 -> 1E-999999999 mulx741 multiply 1e-600000000 1e-400000000 -> 1E-1000000000 Subnormal mulx742 multiply 9e-999999998 0.01 -> 9E-1000000000 Subnormal mulx743 multiply 9e-999999998 0.1 -> 9E-999999999 mulx744 multiply 0.01 9e-999999998 -> 9E-1000000000 Subnormal mulx745 multiply 1e599999999 1e400000001 -> Infinity Overflow Inexact Rounded mulx746 multiply 1e599999999 1e400000000 -> 1E+999999999 mulx747 multiply 1e600000000 1e400000000 -> Infinity Overflow Inexact Rounded mulx748 multiply 9e999999998 100 -> Infinity Overflow Inexact Rounded mulx749 multiply 9e999999998 10 -> 9.0E+999999999 mulx750 multiply 100 9e999999998 -> Infinity Overflow Inexact Rounded -- signs mulx751 multiply 1e+777777777 1e+411111111 -> Infinity Overflow Inexact Rounded mulx752 multiply 1e+777777777 -1e+411111111 -> -Infinity Overflow Inexact Rounded mulx753 multiply -1e+777777777 1e+411111111 -> -Infinity Overflow Inexact Rounded mulx754 multiply -1e+777777777 -1e+411111111 -> Infinity Overflow Inexact Rounded mulx755 multiply 1e-777777777 1e-411111111 -> 0E-1000000007 Underflow Subnormal Inexact Rounded mulx756 multiply 1e-777777777 -1e-411111111 -> -0E-1000000007 Underflow Subnormal Inexact Rounded mulx757 multiply -1e-777777777 1e-411111111 -> -0E-1000000007 Underflow Subnormal Inexact Rounded mulx758 multiply -1e-777777777 -1e-411111111 -> 0E-1000000007 Underflow Subnormal Inexact Rounded -- 'subnormal' boundary (all hard underflow or overflow in base arithemtic) precision: 9 mulx760 multiply 1e-600000000 1e-400000001 -> 1E-1000000001 Subnormal mulx761 multiply 1e-600000000 1e-400000002 -> 1E-1000000002 Subnormal mulx762 multiply 1e-600000000 1e-400000003 -> 1E-1000000003 Subnormal mulx763 multiply 1e-600000000 1e-400000004 -> 1E-1000000004 Subnormal mulx764 multiply 1e-600000000 1e-400000005 -> 1E-1000000005 Subnormal mulx765 multiply 1e-600000000 1e-400000006 -> 1E-1000000006 Subnormal mulx766 multiply 1e-600000000 1e-400000007 -> 1E-1000000007 Subnormal mulx767 multiply 1e-600000000 1e-400000008 -> 0E-1000000007 Underflow Subnormal Inexact Rounded mulx768 multiply 1e-600000000 1e-400000009 -> 0E-1000000007 Underflow Subnormal Inexact Rounded mulx769 multiply 1e-600000000 1e-400000010 -> 0E-1000000007 Underflow Subnormal Inexact Rounded -- [no equivalent of 'subnormal' for overflow] mulx770 multiply 1e+600000000 1e+400000001 -> Infinity Overflow Inexact Rounded mulx771 multiply 1e+600000000 1e+400000002 -> Infinity Overflow Inexact Rounded mulx772 multiply 1e+600000000 1e+400000003 -> Infinity Overflow Inexact Rounded mulx773 multiply 1e+600000000 1e+400000004 -> Infinity Overflow Inexact Rounded mulx774 multiply 1e+600000000 1e+400000005 -> Infinity Overflow Inexact Rounded mulx775 multiply 1e+600000000 1e+400000006 -> Infinity Overflow Inexact Rounded mulx776 multiply 1e+600000000 1e+400000007 -> Infinity Overflow Inexact Rounded mulx777 multiply 1e+600000000 1e+400000008 -> Infinity Overflow Inexact Rounded mulx778 multiply 1e+600000000 1e+400000009 -> Infinity Overflow Inexact Rounded mulx779 multiply 1e+600000000 1e+400000010 -> Infinity Overflow Inexact Rounded -- 'subnormal' test edge condition at higher precisions precision: 99 mulx780 multiply 1e-600000000 1e-400000007 -> 1E-1000000007 Subnormal mulx781 multiply 1e-600000000 1e-400000008 -> 1E-1000000008 Subnormal mulx782 multiply 1e-600000000 1e-400000097 -> 1E-1000000097 Subnormal mulx783 multiply 1e-600000000 1e-400000098 -> 0E-1000000097 Underflow Subnormal Inexact Rounded precision: 999 mulx784 multiply 1e-600000000 1e-400000997 -> 1E-1000000997 Subnormal mulx785 multiply 1e-600000000 1e-400000998 -> 0E-1000000997 Underflow Subnormal Inexact Rounded -- following testcases [through mulx800] not yet run against code precision: 9999 mulx786 multiply 1e-600000000 1e-400009997 -> 1E-1000009997 Subnormal mulx787 multiply 1e-600000000 1e-400009998 -> 0E-1000009997 Underflow Subnormal Inexact Rounded precision: 99999 mulx788 multiply 1e-600000000 1e-400099997 -> 1E-1000099997 Subnormal mulx789 multiply 1e-600000000 1e-400099998 -> 0E-1000099997 Underflow Subnormal Inexact Rounded precision: 999999 mulx790 multiply 1e-600000000 1e-400999997 -> 1E-1000999997 Subnormal mulx791 multiply 1e-600000000 1e-400999998 -> 0E-1000999997 Underflow Subnormal Inexact Rounded precision: 9999999 mulx792 multiply 1e-600000000 1e-409999997 -> 1E-1009999997 Subnormal mulx793 multiply 1e-600000000 1e-409999998 -> 0E-1009999997 Underflow Subnormal Inexact Rounded precision: 99999999 mulx794 multiply 1e-600000000 1e-499999997 -> 1E-1099999997 Subnormal mulx795 multiply 1e-600000000 1e-499999998 -> 0E-1099999997 Underflow Subnormal Inexact Rounded precision: 999999999 mulx796 multiply 1e-999999999 1e-999999997 -> 1E-1999999996 Subnormal mulx797 multiply 1e-999999999 1e-999999998 -> 1E-1999999997 Subnormal mulx798 multiply 1e-999999999 1e-999999999 -> 0E-1999999997 Underflow Subnormal Inexact Rounded mulx799 multiply 1e-600000000 1e-400000007 -> 1E-1000000007 Subnormal mulx800 multiply 1e-600000000 1e-400000008 -> 1E-1000000008 Subnormal -- test subnormals rounding precision: 5 maxExponent: 999 minexponent: -999 rounding: half_even mulx801 multiply 1.0000E-999 1 -> 1.0000E-999 mulx802 multiply 1.000E-999 1e-1 -> 1.000E-1000 Subnormal mulx803 multiply 1.00E-999 1e-2 -> 1.00E-1001 Subnormal mulx804 multiply 1.0E-999 1e-3 -> 1.0E-1002 Subnormal mulx805 multiply 1.0E-999 1e-4 -> 1E-1003 Subnormal Rounded mulx806 multiply 1.3E-999 1e-4 -> 1E-1003 Underflow Subnormal Inexact Rounded mulx807 multiply 1.5E-999 1e-4 -> 2E-1003 Underflow Subnormal Inexact Rounded mulx808 multiply 1.7E-999 1e-4 -> 2E-1003 Underflow Subnormal Inexact Rounded mulx809 multiply 2.3E-999 1e-4 -> 2E-1003 Underflow Subnormal Inexact Rounded mulx810 multiply 2.5E-999 1e-4 -> 2E-1003 Underflow Subnormal Inexact Rounded mulx811 multiply 2.7E-999 1e-4 -> 3E-1003 Underflow Subnormal Inexact Rounded mulx812 multiply 1.49E-999 1e-4 -> 1E-1003 Underflow Subnormal Inexact Rounded mulx813 multiply 1.50E-999 1e-4 -> 2E-1003 Underflow Subnormal Inexact Rounded mulx814 multiply 1.51E-999 1e-4 -> 2E-1003 Underflow Subnormal Inexact Rounded mulx815 multiply 2.49E-999 1e-4 -> 2E-1003 Underflow Subnormal Inexact Rounded mulx816 multiply 2.50E-999 1e-4 -> 2E-1003 Underflow Subnormal Inexact Rounded mulx817 multiply 2.51E-999 1e-4 -> 3E-1003 Underflow Subnormal Inexact Rounded mulx818 multiply 1E-999 1e-4 -> 1E-1003 Subnormal mulx819 multiply 3E-999 1e-5 -> 0E-1003 Underflow Subnormal Inexact Rounded mulx820 multiply 5E-999 1e-5 -> 0E-1003 Underflow Subnormal Inexact Rounded mulx821 multiply 7E-999 1e-5 -> 1E-1003 Underflow Subnormal Inexact Rounded mulx822 multiply 9E-999 1e-5 -> 1E-1003 Underflow Subnormal Inexact Rounded mulx823 multiply 9.9E-999 1e-5 -> 1E-1003 Underflow Subnormal Inexact Rounded mulx824 multiply 1E-999 -1e-4 -> -1E-1003 Subnormal mulx825 multiply 3E-999 -1e-5 -> -0E-1003 Underflow Subnormal Inexact Rounded mulx826 multiply -5E-999 1e-5 -> -0E-1003 Underflow Subnormal Inexact Rounded mulx827 multiply 7E-999 -1e-5 -> -1E-1003 Underflow Subnormal Inexact Rounded mulx828 multiply -9E-999 1e-5 -> -1E-1003 Underflow Subnormal Inexact Rounded mulx829 multiply 9.9E-999 -1e-5 -> -1E-1003 Underflow Subnormal Inexact Rounded mulx830 multiply 3.0E-999 -1e-5 -> -0E-1003 Underflow Subnormal Inexact Rounded mulx831 multiply 1.0E-501 1e-501 -> 1.0E-1002 Subnormal mulx832 multiply 2.0E-501 2e-501 -> 4.0E-1002 Subnormal mulx833 multiply 4.0E-501 4e-501 -> 1.60E-1001 Subnormal mulx834 multiply 10.0E-501 10e-501 -> 1.000E-1000 Subnormal mulx835 multiply 30.0E-501 30e-501 -> 9.000E-1000 Subnormal mulx836 multiply 40.0E-501 40e-501 -> 1.6000E-999 -- squares mulx840 multiply 1E-502 1e-502 -> 0E-1003 Underflow Subnormal Inexact Rounded mulx841 multiply 1E-501 1e-501 -> 1E-1002 Subnormal mulx842 multiply 2E-501 2e-501 -> 4E-1002 Subnormal mulx843 multiply 4E-501 4e-501 -> 1.6E-1001 Subnormal mulx844 multiply 10E-501 10e-501 -> 1.00E-1000 Subnormal mulx845 multiply 30E-501 30e-501 -> 9.00E-1000 Subnormal mulx846 multiply 40E-501 40e-501 -> 1.600E-999 -- cubes mulx850 multiply 1E-670 1e-335 -> 0E-1003 Underflow Subnormal Inexact Rounded mulx851 multiply 1E-668 1e-334 -> 1E-1002 Subnormal mulx852 multiply 4E-668 2e-334 -> 8E-1002 Subnormal mulx853 multiply 9E-668 3e-334 -> 2.7E-1001 Subnormal mulx854 multiply 16E-668 4e-334 -> 6.4E-1001 Subnormal mulx855 multiply 25E-668 5e-334 -> 1.25E-1000 Subnormal mulx856 multiply 10E-668 100e-334 -> 1.000E-999 -- test from 0.099 ** 999 at 15 digits precision: 19 mulx860 multiply 6636851557994578716E-520 6636851557994578716E-520 -> 4.40477986028551E-1003 Underflow Subnormal Inexact Rounded -- Long operand overflow may be a different path precision: 3 maxExponent: 999999999 minexponent: -999999999 mulx870 multiply 1 9.999E+999999999 -> Infinity Inexact Overflow Rounded mulx871 multiply 1 -9.999E+999999999 -> -Infinity Inexact Overflow Rounded mulx872 multiply 9.999E+999999999 1 -> Infinity Inexact Overflow Rounded mulx873 multiply -9.999E+999999999 1 -> -Infinity Inexact Overflow Rounded -- check for double-rounded subnormals precision: 5 maxexponent: 79 minexponent: -79 mulx881 multiply 1.2347E-40 1.2347E-40 -> 1.524E-80 Inexact Rounded Subnormal Underflow mulx882 multiply 1.234E-40 1.234E-40 -> 1.523E-80 Inexact Rounded Subnormal Underflow mulx883 multiply 1.23E-40 1.23E-40 -> 1.513E-80 Inexact Rounded Subnormal Underflow mulx884 multiply 1.2E-40 1.2E-40 -> 1.44E-80 Subnormal mulx885 multiply 1.2E-40 1.2E-41 -> 1.44E-81 Subnormal mulx886 multiply 1.2E-40 1.2E-42 -> 1.4E-82 Subnormal Inexact Rounded Underflow mulx887 multiply 1.2E-40 1.3E-42 -> 1.6E-82 Subnormal Inexact Rounded Underflow mulx888 multiply 1.3E-40 1.3E-42 -> 1.7E-82 Subnormal Inexact Rounded Underflow mulx891 multiply 1.2345E-39 1.234E-40 -> 1.5234E-79 Inexact Rounded mulx892 multiply 1.23456E-39 1.234E-40 -> 1.5234E-79 Inexact Rounded mulx893 multiply 1.2345E-40 1.234E-40 -> 1.523E-80 Inexact Rounded Subnormal Underflow mulx894 multiply 1.23456E-40 1.234E-40 -> 1.523E-80 Inexact Rounded Subnormal Underflow mulx895 multiply 1.2345E-41 1.234E-40 -> 1.52E-81 Inexact Rounded Subnormal Underflow mulx896 multiply 1.23456E-41 1.234E-40 -> 1.52E-81 Inexact Rounded Subnormal Underflow -- Null tests mulx900 multiply 10 # -> NaN Invalid_operation mulx901 multiply # 10 -> NaN Invalid_operation --- NEW FILE: normalize.decTest --- ------------------------------------------------------------------------ -- normalize.decTest -- remove trailing zeros -- -- Copyright (c) IBM Corporation, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 extended: 1 precision: 9 rounding: half_up maxExponent: 999 minexponent: -999 nrmx001 normalize '1' -> '1' nrmx002 normalize '-1' -> '-1' nrmx003 normalize '1.00' -> '1' nrmx004 normalize '-1.00' -> '-1' nrmx005 normalize '0' -> '0' nrmx006 normalize '0.00' -> '0' nrmx007 normalize '00.0' -> '0' nrmx008 normalize '00.00' -> '0' nrmx009 normalize '00' -> '0' nrmx010 normalize '0E+1' -> '0' nrmx011 normalize '0E+5' -> '0' nrmx012 normalize '-2' -> '-2' nrmx013 normalize '2' -> '2' nrmx014 normalize '-2.00' -> '-2' nrmx015 normalize '2.00' -> '2' nrmx016 normalize '-0' -> '-0' nrmx017 normalize '-0.00' -> '-0' nrmx018 normalize '-00.0' -> '-0' nrmx019 normalize '-00.00' -> '-0' nrmx020 normalize '-00' -> '-0' nrmx021 normalize '-0E+5' -> '-0' nrmx022 normalize '-0E+1' -> '-0' nrmx030 normalize '+0.1' -> '0.1' nrmx031 normalize '-0.1' -> '-0.1' nrmx032 normalize '+0.01' -> '0.01' nrmx033 normalize '-0.01' -> '-0.01' nrmx034 normalize '+0.001' -> '0.001' nrmx035 normalize '-0.001' -> '-0.001' nrmx036 normalize '+0.000001' -> '0.000001' nrmx037 normalize '-0.000001' -> '-0.000001' nrmx038 normalize '+0.000000000001' -> '1E-12' nrmx039 normalize '-0.000000000001' -> '-1E-12' nrmx041 normalize 1.1 -> 1.1 nrmx042 normalize 1.10 -> 1.1 nrmx043 normalize 1.100 -> 1.1 nrmx044 normalize 1.110 -> 1.11 nrmx045 normalize -1.1 -> -1.1 nrmx046 normalize -1.10 -> -1.1 nrmx047 normalize -1.100 -> -1.1 nrmx048 normalize -1.110 -> -1.11 nrmx049 normalize 9.9 -> 9.9 nrmx050 normalize 9.90 -> 9.9 nrmx051 normalize 9.900 -> 9.9 nrmx052 normalize 9.990 -> 9.99 nrmx053 normalize -9.9 -> -9.9 nrmx054 normalize -9.90 -> -9.9 nrmx055 normalize -9.900 -> -9.9 nrmx056 normalize -9.990 -> -9.99 -- some trailing fractional zeros with zeros in units nrmx060 normalize 10.0 -> 1E+1 nrmx061 normalize 10.00 -> 1E+1 nrmx062 normalize 100.0 -> 1E+2 nrmx063 normalize 100.00 -> 1E+2 nrmx064 normalize 1.1000E+3 -> 1.1E+3 nrmx065 normalize 1.10000E+3 -> 1.1E+3 nrmx066 normalize -10.0 -> -1E+1 nrmx067 normalize -10.00 -> -1E+1 nrmx068 normalize -100.0 -> -1E+2 nrmx069 normalize -100.00 -> -1E+2 nrmx070 normalize -1.1000E+3 -> -1.1E+3 nrmx071 normalize -1.10000E+3 -> -1.1E+3 -- some insignificant trailing zeros with positive exponent nrmx080 normalize 10E+1 -> 1E+2 nrmx081 normalize 100E+1 -> 1E+3 nrmx082 normalize 1.0E+2 -> 1E+2 nrmx083 normalize 1.0E+3 -> 1E+3 nrmx084 normalize 1.1E+3 -> 1.1E+3 nrmx085 normalize 1.00E+3 -> 1E+3 nrmx086 normalize 1.10E+3 -> 1.1E+3 nrmx087 normalize -10E+1 -> -1E+2 nrmx088 normalize -100E+1 -> -1E+3 nrmx089 normalize -1.0E+2 -> -1E+2 nrmx090 normalize -1.0E+3 -> -1E+3 nrmx091 normalize -1.1E+3 -> -1.1E+3 nrmx092 normalize -1.00E+3 -> -1E+3 nrmx093 normalize -1.10E+3 -> -1.1E+3 -- some significant trailing zeros, were we to be trimming nrmx100 normalize 11 -> 11 nrmx101 normalize 10 -> 1E+1 nrmx102 normalize 10. -> 1E+1 nrmx103 normalize 1.1E+1 -> 11 nrmx104 normalize 1.0E+1 -> 1E+1 nrmx105 normalize 1.10E+2 -> 1.1E+2 nrmx106 normalize 1.00E+2 -> 1E+2 nrmx107 normalize 1.100E+3 -> 1.1E+3 nrmx108 normalize 1.000E+3 -> 1E+3 nrmx109 normalize 1.000000E+6 -> 1E+6 nrmx110 normalize -11 -> -11 nrmx111 normalize -10 -> -1E+1 nrmx112 normalize -10. -> -1E+1 nrmx113 normalize -1.1E+1 -> -11 nrmx114 normalize -1.0E+1 -> -1E+1 nrmx115 normalize -1.10E+2 -> -1.1E+2 nrmx116 normalize -1.00E+2 -> -1E+2 nrmx117 normalize -1.100E+3 -> -1.1E+3 nrmx118 normalize -1.000E+3 -> -1E+3 nrmx119 normalize -1.00000E+5 -> -1E+5 nrmx120 normalize -1.000000E+6 -> -1E+6 nrmx121 normalize -10.00000E+6 -> -1E+7 nrmx122 normalize -100.0000E+6 -> -1E+8 nrmx123 normalize -1000.000E+6 -> -1E+9 nrmx124 normalize -10000.00E+6 -> -1E+10 nrmx125 normalize -100000.0E+6 -> -1E+11 nrmx126 normalize -1000000.E+6 -> -1E+12 -- examples from decArith nrmx140 normalize '2.1' -> '2.1' nrmx141 normalize '-2.0' -> '-2' nrmx142 normalize '1.200' -> '1.2' nrmx143 normalize '-120' -> '-1.2E+2' nrmx144 normalize '120.00' -> '1.2E+2' nrmx145 normalize '0.00' -> '0' -- overflow tests maxexponent: 999999999 minexponent: -999999999 precision: 3 nrmx160 normalize 9.999E+999999999 -> Infinity Inexact Overflow Rounded nrmx161 normalize -9.999E+999999999 -> -Infinity Inexact Overflow Rounded -- subnormals and underflow precision: 3 maxexponent: 999 minexponent: -999 nrmx210 normalize 1.00E-999 -> 1E-999 nrmx211 normalize 0.1E-999 -> 1E-1000 Subnormal nrmx212 normalize 0.10E-999 -> 1E-1000 Subnormal nrmx213 normalize 0.100E-999 -> 1E-1000 Subnormal Rounded nrmx214 normalize 0.01E-999 -> 1E-1001 Subnormal -- next is rounded to Emin nrmx215 normalize 0.999E-999 -> 1E-999 Inexact Rounded Subnormal Underflow nrmx216 normalize 0.099E-999 -> 1E-1000 Inexact Rounded Subnormal Underflow nrmx217 normalize 0.009E-999 -> 1E-1001 Inexact Rounded Subnormal Underflow nrmx218 normalize 0.001E-999 -> 0 Inexact Rounded Subnormal Underflow nrmx219 normalize 0.0009E-999 -> 0 Inexact Rounded Subnormal Underflow nrmx220 normalize 0.0001E-999 -> 0 Inexact Rounded Subnormal Underflow nrmx230 normalize -1.00E-999 -> -1E-999 nrmx231 normalize -0.1E-999 -> -1E-1000 Subnormal nrmx232 normalize -0.10E-999 -> -1E-1000 Subnormal nrmx233 normalize -0.100E-999 -> -1E-1000 Subnormal Rounded nrmx234 normalize -0.01E-999 -> -1E-1001 Subnormal -- next is rounded to Emin nrmx235 normalize -0.999E-999 -> -1E-999 Inexact Rounded Subnormal Underflow nrmx236 normalize -0.099E-999 -> -1E-1000 Inexact Rounded Subnormal Underflow nrmx237 normalize -0.009E-999 -> -1E-1001 Inexact Rounded Subnormal Underflow nrmx238 normalize -0.001E-999 -> -0 Inexact Rounded Subnormal Underflow nrmx239 normalize -0.0009E-999 -> -0 Inexact Rounded Subnormal Underflow nrmx240 normalize -0.0001E-999 -> -0 Inexact Rounded Subnormal Underflow -- more reshaping precision: 9 nrmx260 normalize '56260E-10' -> '0.000005626' nrmx261 normalize '56260E-5' -> '0.5626' nrmx262 normalize '56260E-2' -> '562.6' nrmx263 normalize '56260E-1' -> '5626' nrmx265 normalize '56260E-0' -> '5.626E+4' nrmx266 normalize '56260E+0' -> '5.626E+4' nrmx267 normalize '56260E+1' -> '5.626E+5' nrmx268 normalize '56260E+2' -> '5.626E+6' nrmx269 normalize '56260E+3' -> '5.626E+7' nrmx270 normalize '56260E+4' -> '5.626E+8' nrmx271 normalize '56260E+5' -> '5.626E+9' nrmx272 normalize '56260E+6' -> '5.626E+10' nrmx280 normalize '-56260E-10' -> '-0.000005626' nrmx281 normalize '-56260E-5' -> '-0.5626' nrmx282 normalize '-56260E-2' -> '-562.6' nrmx283 normalize '-56260E-1' -> '-5626' nrmx285 normalize '-56260E-0' -> '-5.626E+4' nrmx286 normalize '-56260E+0' -> '-5.626E+4' nrmx287 normalize '-56260E+1' -> '-5.626E+5' nrmx288 normalize '-56260E+2' -> '-5.626E+6' nrmx289 normalize '-56260E+3' -> '-5.626E+7' nrmx290 normalize '-56260E+4' -> '-5.626E+8' nrmx291 normalize '-56260E+5' -> '-5.626E+9' nrmx292 normalize '-56260E+6' -> '-5.626E+10' -- specials nrmx820 normalize 'Inf' -> 'Infinity' nrmx821 normalize '-Inf' -> '-Infinity' nrmx822 normalize NaN -> NaN nrmx823 normalize sNaN -> NaN Invalid_operation nrmx824 normalize NaN101 -> NaN101 nrmx825 normalize sNaN010 -> NaN10 Invalid_operation nrmx827 normalize -NaN -> -NaN nrmx828 normalize -sNaN -> -NaN Invalid_operation nrmx829 normalize -NaN101 -> -NaN101 nrmx830 normalize -sNaN010 -> -NaN10 Invalid_operation -- Null test nrmx900 normalize # -> NaN Invalid_operation --- NEW FILE: plus.decTest --- ------------------------------------------------------------------------ -- plus.decTest -- decimal monadic addition -- -- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 -- This set of tests primarily tests the existence of the operator. -- Addition and rounding, and most overflows, are tested elsewhere. extended: 1 precision: 9 rounding: half_up maxExponent: 384 minexponent: -383 plux001 plus '1' -> '1' plux002 plus '-1' -> '-1' plux003 plus '1.00' -> '1.00' plux004 plus '-1.00' -> '-1.00' plux005 plus '0' -> '0' plux006 plus '0.00' -> '0.00' plux007 plus '00.0' -> '0.0' plux008 plus '00.00' -> '0.00' plux009 plus '00' -> '0' plux010 plus '-2' -> '-2' plux011 plus '2' -> '2' plux012 plus '-2.00' -> '-2.00' plux013 plus '2.00' -> '2.00' plux014 plus '-0' -> '0' plux015 plus '-0.00' -> '0.00' plux016 plus '-00.0' -> '0.0' plux017 plus '-00.00' -> '0.00' plux018 plus '-00' -> '0' plux020 plus '-2000000' -> '-2000000' plux021 plus '2000000' -> '2000000' precision: 7 plux022 plus '-2000000' -> '-2000000' plux023 plus '2000000' -> '2000000' precision: 6 plux024 plus '-2000000' -> '-2.00000E+6' Rounded plux025 plus '2000000' -> '2.00000E+6' Rounded precision: 3 plux026 plus '-2000000' -> '-2.00E+6' Rounded plux027 plus '2000000' -> '2.00E+6' Rounded -- more fixed, potential LHS swaps if done by add 0 precision: 9 plux060 plus '56267E-10' -> '0.0000056267' plux061 plus '56267E-5' -> '0.56267' plux062 plus '56267E-2' -> '562.67' plux063 plus '56267E-1' -> '5626.7' plux065 plus '56267E-0' -> '56267' plux066 plus '56267E+0' -> '56267' plux067 plus '56267E+1' -> '5.6267E+5' plux068 plus '56267E+2' -> '5.6267E+6' plux069 plus '56267E+3' -> '5.6267E+7' plux070 plus '56267E+4' -> '5.6267E+8' plux071 plus '56267E+5' -> '5.6267E+9' plux072 plus '56267E+6' -> '5.6267E+10' plux080 plus '-56267E-10' -> '-0.0000056267' plux081 plus '-56267E-5' -> '-0.56267' plux082 plus '-56267E-2' -> '-562.67' plux083 plus '-56267E-1' -> '-5626.7' plux085 plus '-56267E-0' -> '-56267' plux086 plus '-56267E+0' -> '-56267' plux087 plus '-56267E+1' -> '-5.6267E+5' plux088 plus '-56267E+2' -> '-5.6267E+6' plux089 plus '-56267E+3' -> '-5.6267E+7' plux090 plus '-56267E+4' -> '-5.6267E+8' plux091 plus '-56267E+5' -> '-5.6267E+9' plux092 plus '-56267E+6' -> '-5.6267E+10' -- "lhs" zeros in plus and minus have exponent = operand plux120 plus '-0E3' -> '0E+3' plux121 plus '-0E2' -> '0E+2' plux122 plus '-0E1' -> '0E+1' plux123 plus '-0E0' -> '0' plux124 plus '+0E0' -> '0' plux125 plus '+0E1' -> '0E+1' plux126 plus '+0E2' -> '0E+2' plux127 plus '+0E3' -> '0E+3' plux130 plus '-5E3' -> '-5E+3' plux131 plus '-5E8' -> '-5E+8' plux132 plus '-5E13' -> '-5E+13' plux133 plus '-5E18' -> '-5E+18' plux134 plus '+5E3' -> '5E+3' plux135 plus '+5E8' -> '5E+8' plux136 plus '+5E13' -> '5E+13' plux137 plus '+5E18' -> '5E+18' -- specials plux150 plus 'Inf' -> 'Infinity' plux151 plus '-Inf' -> '-Infinity' plux152 plus NaN -> NaN plux153 plus sNaN -> NaN Invalid_operation plux154 plus NaN77 -> NaN77 plux155 plus sNaN88 -> NaN88 Invalid_operation plux156 plus -NaN -> -NaN plux157 plus -sNaN -> -NaN Invalid_operation plux158 plus -NaN77 -> -NaN77 plux159 plus -sNaN88 -> -NaN88 Invalid_operation -- overflow tests maxexponent: 999999999 minexponent: -999999999 precision: 3 plux160 plus 9.999E+999999999 -> Infinity Inexact Overflow Rounded plux161 plus -9.999E+999999999 -> -Infinity Inexact Overflow Rounded -- subnormals and underflow precision: 3 maxexponent: 999 minexponent: -999 plux210 plus 1.00E-999 -> 1.00E-999 plux211 plus 0.1E-999 -> 1E-1000 Subnormal plux212 plus 0.10E-999 -> 1.0E-1000 Subnormal plux213 plus 0.100E-999 -> 1.0E-1000 Subnormal Rounded plux214 plus 0.01E-999 -> 1E-1001 Subnormal -- next is rounded to Emin plux215 plus 0.999E-999 -> 1.00E-999 Inexact Rounded Subnormal Underflow plux216 plus 0.099E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow plux217 plus 0.009E-999 -> 1E-1001 Inexact Rounded Subnormal Underflow plux218 plus 0.001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow plux219 plus 0.0009E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow plux220 plus 0.0001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow plux230 plus -1.00E-999 -> -1.00E-999 plux231 plus -0.1E-999 -> -1E-1000 Subnormal plux232 plus -0.10E-999 -> -1.0E-1000 Subnormal plux233 plus -0.100E-999 -> -1.0E-1000 Subnormal Rounded plux234 plus -0.01E-999 -> -1E-1001 Subnormal -- next is rounded to Emin plux235 plus -0.999E-999 -> -1.00E-999 Inexact Rounded Subnormal Underflow plux236 plus -0.099E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow plux237 plus -0.009E-999 -> -1E-1001 Inexact Rounded Subnormal Underflow plux238 plus -0.001E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow plux239 plus -0.0009E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow plux240 plus -0.0001E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow -- long operand checks maxexponent: 999 minexponent: -999 precision: 9 plux301 plus 12345678000 -> 1.23456780E+10 Rounded plux302 plus 1234567800 -> 1.23456780E+9 Rounded plux303 plus 1234567890 -> 1.23456789E+9 Rounded plux304 plus 1234567891 -> 1.23456789E+9 Inexact Rounded plux305 plus 12345678901 -> 1.23456789E+10 Inexact Rounded plux306 plus 1234567896 -> 1.23456790E+9 Inexact Rounded -- still checking precision: 15 plux321 plus 12345678000 -> 12345678000 plux322 plus 1234567800 -> 1234567800 plux323 plus 1234567890 -> 1234567890 plux324 plus 1234567891 -> 1234567891 plux325 plus 12345678901 -> 12345678901 plux326 plus 1234567896 -> 1234567896 precision: 9 -- Null tests plu900 plus # -> NaN Invalid_operation --- NEW FILE: power.decTest --- ---------------------------------------------------------------------- -- power.decTest -- decimal exponentiation -- -- Copyright (c) IBM Corporation, 1981, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 -- This set of testcases tests raising numbers to an integer power only. -- If arbitrary powers were supported, 1 ulp differences would be -- permitted. extended: 1 precision: 9 rounding: half_up maxExponent: 999 minexponent: -999 -- base checks. Note 0**0 is an error. powx001 power '0' '0' -> NaN Invalid_operation powx002 power '0' '1' -> '0' powx003 power '0' '2' -> '0' powx004 power '1' '0' -> '1' powx005 power '1' '1' -> '1' powx006 power '1' '2' -> '1' powx010 power '2' '0' -> '1' powx011 power '2' '1' -> '2' powx012 power '2' '2' -> '4' powx013 power '2' '3' -> '8' powx014 power '2' '4' -> '16' powx015 power '2' '5' -> '32' powx016 power '2' '6' -> '64' powx017 power '2' '7' -> '128' powx018 power '2' '8' -> '256' powx019 power '2' '9' -> '512' powx020 power '2' '10' -> '1024' powx021 power '2' '11' -> '2048' powx022 power '2' '12' -> '4096' powx023 power '2' '15' -> '32768' powx024 power '2' '16' -> '65536' powx025 power '2' '31' -> '2.14748365E+9' Inexact Rounded -- NB 0 not stripped in next powx026 power '2' '32' -> '4.29496730E+9' Inexact Rounded precision: 10 powx027 power '2' '31' -> '2147483648' powx028 power '2' '32' -> '4294967296' precision: 9 powx030 power '3' '2' -> 9 powx031 power '4' '2' -> 16 powx032 power '5' '2' -> 25 powx033 power '6' '2' -> 36 powx034 power '7' '2' -> 49 powx035 power '8' '2' -> 64 powx036 power '9' '2' -> 81 powx037 power '10' '2' -> 100 powx038 power '11' '2' -> 121 powx039 power '12' '2' -> 144 powx040 power '3' '3' -> 27 powx041 power '4' '3' -> 64 powx042 power '5' '3' -> 125 powx043 power '6' '3' -> 216 powx044 power '7' '3' -> 343 powx050 power '10' '0' -> 1 powx051 power '10' '1' -> 10 powx052 power '10' '2' -> 100 powx053 power '10' '3' -> 1000 powx054 power '10' '4' -> 10000 powx055 power '10' '5' -> 100000 powx056 power '10' '6' -> 1000000 powx057 power '10' '7' -> 10000000 powx058 power '10' '8' -> 100000000 powx059 power '10' '9' -> 1.00000000E+9 Rounded powx060 power '10' '22' -> 1.00000000E+22 Rounded powx061 power '10' '77' -> 1.00000000E+77 Rounded powx062 power '10' '99' -> 1.00000000E+99 Rounded maxexponent: 999999999 minexponent: -999999999 powx063 power '10' '999999999' -> '1.00000000E+999999999' Rounded powx064 power '10' '999999998' -> '1.00000000E+999999998' Rounded powx065 power '10' '999999997' -> '1.00000000E+999999997' Rounded powx066 power '10' '333333333' -> '1.00000000E+333333333' Rounded powx070 power '0.3' '0' -> '1' powx071 power '0.3' '1' -> '0.3' powx072 power '0.3' '1.00' -> '0.3' powx073 power '0.3' '2.00' -> '0.09' powx074 power '0.3' '2.000000000' -> '0.09' powx075 power '6.0' '1' -> '6.0' -- NB zeros not stripped powx076 power '6.0' '2' -> '36.00' -- .. powx077 power '-3' '2' -> '9' -- from NetRexx book powx078 power '4' '3' -> '64' -- .. (sort of) powx080 power 0.1 0 -> 1 powx081 power 0.1 1 -> 0.1 powx082 power 0.1 2 -> 0.01 powx083 power 0.1 3 -> 0.001 powx084 power 0.1 4 -> 0.0001 powx085 power 0.1 5 -> 0.00001 powx086 power 0.1 6 -> 0.000001 powx087 power 0.1 7 -> 1E-7 powx088 power 0.1 8 -> 1E-8 powx089 power 0.1 9 -> 1E-9 powx090 power 101 2 -> 10201 powx091 power 101 3 -> 1030301 powx092 power 101 4 -> 104060401 powx093 power 101 5 -> 1.05101005E+10 Inexact Rounded powx094 power 101 6 -> 1.06152015E+12 Inexact Rounded powx095 power 101 7 -> 1.07213535E+14 Inexact Rounded -- negative powers powx101 power '2' '-1' -> 0.5 powx102 power '2' '-2' -> 0.25 powx103 power '2' '-4' -> 0.0625 powx104 power '2' '-8' -> 0.00390625 powx105 power '2' '-16' -> 0.0000152587891 Inexact Rounded powx106 power '2' '-32' -> 2.32830644E-10 Inexact Rounded powx108 power '2' '-64' -> 5.42101086E-20 Inexact Rounded powx110 power '10' '-8' -> 1E-8 powx111 power '10' '-7' -> 1E-7 powx112 power '10' '-6' -> 0.000001 powx113 power '10' '-5' -> 0.00001 powx114 power '10' '-4' -> 0.0001 powx115 power '10' '-3' -> 0.001 powx116 power '10' '-2' -> 0.01 powx117 power '10' '-1' -> 0.1 powx118 power '10' '-333333333' -> 1E-333333333 powx119 power '10' '-999999998' -> 1E-999999998 powx120 power '10' '-999999999' -> 1E-999999999 powx121 power '10' '-77' -> '1E-77' powx122 power '10' '-22' -> '1E-22' powx123 power '2' '-1' -> '0.5' powx124 power '2' '-2' -> '0.25' powx125 power '2' '-4' -> '0.0625' powx126 power '0' '-1' -> Infinity Division_by_zero powx127 power '0' '-2' -> Infinity Division_by_zero powx128 power -0 '-1' -> -Infinity Division_by_zero powx129 power -0 '-2' -> Infinity Division_by_zero -- out-of-range edge cases powx181 power '7' '999999998' -> 2.10892313E+845098038 Inexact Rounded powx182 power '7' '999999999' -> 1.47624619E+845098039 Inexact Rounded powx183 power '7' '1000000000' -> NaN Invalid_operation powx184 power '7' '1000000001' -> NaN Invalid_operation powx185 power '7' '10000000000' -> NaN Invalid_operation powx186 power '7' '-1000000001' -> NaN Invalid_operation powx187 power '7' '-1000000000' -> NaN Invalid_operation powx189 power '7' '-999999999' -> 6.77393787E-845098040 Inexact Rounded powx190 power '7' '-999999998' -> 4.74175651E-845098039 Inexact Rounded -- some baddies [more below] powx191 power '2' '2.000001' -> NaN Invalid_operation powx192 power '2' '2.00000000' -> 4 powx193 power '2' '2.000000001' -> NaN Invalid_operation powx194 power '2' '2.0000000001' -> NaN Invalid_operation -- "0.5" tests from original Rexx diagnostics [loop unrolled] powx200 power 0.5 0 -> 1 powx201 power 0.5 1 -> 0.5 powx202 power 0.5 2 -> 0.25 powx203 power 0.5 3 -> 0.125 powx204 power 0.5 4 -> 0.0625 powx205 power 0.5 5 -> 0.03125 powx206 power 0.5 6 -> 0.015625 powx207 power 0.5 7 -> 0.0078125 powx208 power 0.5 8 -> 0.00390625 powx209 power 0.5 9 -> 0.001953125 powx210 power 0.5 10 -> 0.0009765625 -- A (rare) case where the last digit is not within 0.5 ULP precision: 9 powx215 power "-21971575.0E+31454441" "-7" -> "-4.04549503E-220181139" Inexact Rounded precision: 20 powx216 power "-21971575.0E+31454441" "-7" -> "-4.0454950249324891788E-220181139" Inexact Rounded -- The Vienna case. Checks both setup and 1/acc working precision -- Modified 1998.12.14 as RHS no longer rounded before use (must fit) -- Modified 1990.02.04 as LHS is now rounded (instead of truncated to guard) -- '123456789E+10' -- lhs .. rounded to 1.23E+18 -- '-1.23000e+2' -- rhs .. [was: -1.23455e+2, rounds to -123] -- Modified 2002.10.06 -- finally, no input rounding -- With input rounding, result would be 8.74E-2226 precision: 3 powx219 power '123456789E+10' '-1.23000e+2' -> '5.54E-2226' Inexact Rounded -- whole number checks precision: 9 powx221 power 1 1234 -> 1 precision: 4 powx222 power 1 1234 -> 1 precision: 3 powx223 power 1 1234 -> 1 powx224 power 1 12.34e+2 -> 1 powx225 power 1 12.3 -> NaN Invalid_operation powx226 power 1 12.0 -> 1 powx227 power 1 1.01 -> NaN Invalid_operation powx228 power 2 1.00 -> 2 powx229 power 2 2.00 -> 4 precision: 9 powx230 power 1 1.0001 -> NaN Invalid_operation powx231 power 1 1.0000001 -> NaN Invalid_operation powx232 power 1 1.0000000001 -> NaN Invalid_operation powx233 power 1 1.0000000000001 -> NaN Invalid_operation precision: 5 powx234 power 1 1.0001 -> NaN Invalid_operation powx235 power 1 1.0000001 -> NaN Invalid_operation powx236 power 1 1.0000000001 -> NaN Invalid_operation powx237 power 1 1.0000000000001 -> NaN Invalid_operation powx238 power 1 1.0000000000001 -> NaN Invalid_operation maxexponent: 999999999 minexponent: -999999999 powx239 power 1 5.67E-987654321 -> NaN Invalid_operation powx240 power 1 100000000 -> 1 powx241 power 1 999999998 -> 1 powx242 power 1 999999999 -> 1 powx243 power 1 1000000000 -> NaN Invalid_operation powx244 power 1 9999999999 -> NaN Invalid_operation -- Checks for 'Too much precision needed' -- For x^12, digits+elength+1 = digits+3 precision: 999999999 powx249 add 1 1 -> 2 -- check basic operation at this precision powx250 power 2 12 -> Infinity Overflow precision: 999999998 powx251 power 2 12 -> Infinity Overflow precision: 999999997 powx252 power 2 12 -> Infinity Overflow precision: 999999996 powx253 power 2 12 -> 4096 precision: 999999995 powx254 power 2 12 -> 4096 -- zeros maxexponent: +96 minexponent: -95 precision: 7 powx260 power 0E-34 3 -> 0E-101 Clamped powx261 power 0E-33 3 -> 0E-99 powx262 power 0E-32 3 -> 0E-96 powx263 power 0E-30 3 -> 0E-90 powx264 power 0E-10 3 -> 0E-30 powx265 power 0E-1 3 -> 0.000 powx266 power 0E+0 3 -> 0 powx267 power 0 3 -> 0 powx268 power 0E+1 3 -> 0E+3 powx269 power 0E+10 3 -> 0E+30 powx270 power 0E+30 3 -> 0E+90 powx271 power 0E+32 3 -> 0E+96 powx272 power 0E+33 3 -> 0E+96 Clamped -- overflow and underflow tests maxexponent: 999999999 minexponent: -999999999 precision: 9 powx280 power 9 999999999 -> 3.05550054E+954242508 Inexact Rounded powx281 power 10 999999999 -> 1.00000000E+999999999 Rounded powx282 power 10.0001 999999999 -> Infinity Overflow Inexact Rounded powx283 power 10.1 999999999 -> Infinity Overflow Inexact Rounded powx284 power 11 999999999 -> Infinity Overflow Inexact Rounded powx285 power 12 999999999 -> Infinity Overflow Inexact Rounded powx286 power 999 999999999 -> Infinity Overflow Inexact Rounded powx287 power 999999 999999999 -> Infinity Overflow Inexact Rounded powx288 power 999999999 999999999 -> Infinity Overflow Inexact Rounded powx289 power 9.9E999999999 999999999 -> Infinity Overflow Inexact Rounded powx290 power 0.5 999999999 -> 4.33559594E-301029996 Inexact Rounded powx291 power 0.1 999999999 -> 1E-999999999 -- unrounded powx292 power 0.09 999999999 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx293 power 0.05 999999999 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx294 power 0.01 999999999 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx295 power 0.0001 999999999 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx297 power 0.0000001 999999999 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx298 power 0.0000000001 999999999 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx299 power 1E-999999999 999999999 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx310 power -9 999999999 -> -3.05550054E+954242508 Inexact Rounded powx311 power -10 999999999 -> -1.00000000E+999999999 Rounded powx312 power -10.0001 999999999 -> -Infinity Overflow Inexact Rounded powx313 power -10.1 999999999 -> -Infinity Overflow Inexact Rounded powx314 power -11 999999999 -> -Infinity Overflow Inexact Rounded powx315 power -12 999999999 -> -Infinity Overflow Inexact Rounded powx316 power -999 999999999 -> -Infinity Overflow Inexact Rounded powx317 power -999999 999999999 -> -Infinity Overflow Inexact Rounded powx318 power -999999999 999999999 -> -Infinity Overflow Inexact Rounded powx319 power -9.9E999999999 999999999 -> -Infinity Overflow Inexact Rounded powx320 power -0.5 999999999 -> -4.33559594E-301029996 Inexact Rounded powx321 power -0.1 999999999 -> -1E-999999999 powx322 power -0.09 999999999 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx323 power -0.05 999999999 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx324 power -0.01 999999999 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx325 power -0.0001 999999999 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx327 power -0.0000001 999999999 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx328 power -0.0000000001 999999999 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx329 power -1E-999999999 999999999 -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped -- note no trim of next result powx330 power -9 999999998 -> 3.39500060E+954242507 Inexact Rounded powx331 power -10 999999998 -> 1.00000000E+999999998 Rounded powx332 power -10.0001 999999998 -> Infinity Overflow Inexact Rounded powx333 power -10.1 999999998 -> Infinity Overflow Inexact Rounded powx334 power -11 999999998 -> Infinity Overflow Inexact Rounded powx335 power -12 999999998 -> Infinity Overflow Inexact Rounded powx336 power -999 999999998 -> Infinity Overflow Inexact Rounded powx337 power -999999 999999998 -> Infinity Overflow Inexact Rounded powx338 power -999999999 999999998 -> Infinity Overflow Inexact Rounded powx339 power -9.9E999999999 999999998 -> Infinity Overflow Inexact Rounded powx340 power -0.5 999999998 -> 8.67119187E-301029996 Inexact Rounded powx341 power -0.1 999999998 -> 1E-999999998 -- NB exact unrounded powx342 power -0.09 999999998 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx343 power -0.05 999999998 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx344 power -0.01 999999998 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx345 power -0.0001 999999998 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx347 power -0.0000001 999999998 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx348 power -0.0000000001 999999998 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx349 power -1E-999999999 999999998 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped -- some subnormals precision: 9 -- [precision is 9, so smallest exponent is -1000000007 powx350 power 1e-1 500000000 -> 1E-500000000 powx351 power 1e-2 999999999 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped powx352 power 1e-2 500000000 -> 1E-1000000000 Subnormal powx353 power 1e-2 500000001 -> 1E-1000000002 Subnormal powx354 power 1e-2 500000002 -> 1E-1000000004 Subnormal powx355 power 1e-2 500000003 -> 1E-1000000006 Subnormal powx356 power 1e-2 500000004 -> 0E-1000000007 Underflow Subnormal Inexact Rounded powx360 power 0.010001 500000000 -> 4.34941988E-999978287 Inexact Rounded powx361 power 0.010000001 500000000 -> 5.18469257E-999999979 Inexact Rounded powx362 power 0.010000001 500000001 -> 5.18469309E-999999981 Inexact Rounded powx363 power 0.0100000009 500000000 -> 3.49342003E-999999981 Inexact Rounded powx364 power 0.0100000001 500000000 -> 1.48413155E-999999998 Inexact Rounded powx365 power 0.01 500000000 -> 1E-1000000000 Subnormal powx366 power 0.0099999999 500000000 -> 6.7379E-1000000003 Underflow Subnormal Inexact Rounded powx367 power 0.0099999998 500000000 -> 4.54E-1000000005 Underflow Subnormal Inexact Rounded powx368 power 0.0099999997 500000000 -> 3E-1000000007 Underflow Subnormal Inexact Rounded powx369 power 0.0099999996 500000000 -> 0E-1000000007 Underflow Subnormal Inexact Rounded powx370 power 0.009 500000000 -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped -- 1/subnormal -> overflow powx371 power 1e-1 -500000000 -> 1E+500000000 powx372 power 1e-2 -999999999 -> Infinity Overflow Inexact Rounded powx373 power 1e-2 -500000000 -> Infinity Overflow Inexact Rounded powx374 power 1e-2 -500000001 -> Infinity Overflow Inexact Rounded powx375 power 1e-2 -500000002 -> Infinity Overflow Inexact Rounded powx376 power 1e-2 -500000003 -> Infinity Overflow Inexact Rounded powx377 power 1e-2 -500000004 -> Infinity Overflow Inexact Rounded powx381 power 0.010001 -500000000 -> 2.29915719E+999978286 Inexact Rounded powx382 power 0.010000001 -500000000 -> 1.92875467E+999999978 Inexact Rounded powx383 power 0.010000001 -500000001 -> 1.92875448E+999999980 Inexact Rounded powx384 power 0.0100000009 -500000000 -> 2.86252438E+999999980 Inexact Rounded powx385 power 0.0100000001 -500000000 -> 6.73794717E+999999997 Inexact Rounded powx386 power 0.01 -500000000 -> Infinity Overflow Inexact Rounded powx387 power 0.009999 -500000000 -> Infinity Overflow Inexact Rounded -- negative power giving subnormal powx388 power 100.000001 -500000000 -> 6.7379E-1000000003 Underflow Subnormal Inexact Rounded -- some more edge cases precision: 15 maxExponent: 999 minexponent: -999 powx391 power 0.1 999 -> 1E-999 powx392 power 0.099 999 -> 4.360732062E-1004 Underflow Subnormal Inexact Rounded powx393 power 0.098 999 -> 1.71731E-1008 Underflow Subnormal Inexact Rounded powx394 power 0.097 999 -> 6E-1013 Underflow Subnormal Inexact Rounded powx395 power 0.096 999 -> 0E-1013 Underflow Subnormal Inexact Rounded powx396 power 0.01 999 -> 0E-1013 Underflow Subnormal Inexact Rounded Clamped -- multiply tests are here to aid checking and test for consistent handling -- of underflow precision: 5 maxexponent: 999 minexponent: -999 -- squares mulx400 multiply 1E-502 1e-502 -> 0E-1003 Subnormal Inexact Underflow Rounded mulx401 multiply 1E-501 1e-501 -> 1E-1002 Subnormal mulx402 multiply 2E-501 2e-501 -> 4E-1002 Subnormal mulx403 multiply 4E-501 4e-501 -> 1.6E-1001 Subnormal mulx404 multiply 10E-501 10e-501 -> 1.00E-1000 Subnormal mulx405 multiply 30E-501 30e-501 -> 9.00E-1000 Subnormal mulx406 multiply 40E-501 40e-501 -> 1.600E-999 powx400 power 1E-502 2 -> 0E-1003 Underflow Subnormal Inexact Rounded powx401 power 1E-501 2 -> 1E-1002 Subnormal powx402 power 2E-501 2 -> 4E-1002 Subnormal powx403 power 4E-501 2 -> 1.6E-1001 Subnormal powx404 power 10E-501 2 -> 1.00E-1000 Subnormal powx405 power 30E-501 2 -> 9.00E-1000 Subnormal powx406 power 40E-501 2 -> 1.600E-999 -- cubes mulx410 multiply 1E-670 1e-335 -> 0E-1003 Underflow Subnormal Inexact Rounded mulx411 multiply 1E-668 1e-334 -> 1E-1002 Subnormal mulx412 multiply 4E-668 2e-334 -> 8E-1002 Subnormal mulx413 multiply 9E-668 3e-334 -> 2.7E-1001 Subnormal mulx414 multiply 16E-668 4e-334 -> 6.4E-1001 Subnormal mulx415 multiply 25E-668 5e-334 -> 1.25E-1000 Subnormal mulx416 multiply 10E-668 100e-334 -> 1.000E-999 powx410 power 1E-335 3 -> 0E-1003 Underflow Subnormal Inexact Rounded powx411 power 1E-334 3 -> 1E-1002 Subnormal powx412 power 2E-334 3 -> 8E-1002 Subnormal powx413 power 3E-334 3 -> 2.7E-1001 Subnormal powx414 power 4E-334 3 -> 6.4E-1001 Subnormal powx415 power 5E-334 3 -> 1.25E-1000 Subnormal powx416 power 10E-334 3 -> 1.000E-999 -- negative powers, testing subnormals precision: 5 maxExponent: 999 minexponent: -999 powx421 power 2.5E-501 -2 -> Infinity Overflow Inexact Rounded powx422 power 2.5E-500 -2 -> 1.6E+999 powx423 power 2.5E+499 -2 -> 1.6E-999 powx424 power 2.5E+500 -2 -> 1.6E-1001 Subnormal powx425 power 2.5E+501 -2 -> 2E-1003 Underflow Subnormal Inexact Rounded powx426 power 2.5E+502 -2 -> 0E-1003 Underflow Subnormal Inexact Rounded powx427 power 0.25E+499 -2 -> 1.6E-997 powx428 power 0.25E+500 -2 -> 1.6E-999 powx429 power 0.25E+501 -2 -> 1.6E-1001 Subnormal powx430 power 0.25E+502 -2 -> 2E-1003 Underflow Subnormal Inexact Rounded powx431 power 0.25E+503 -2 -> 0E-1003 Underflow Subnormal Inexact Rounded powx432 power 0.04E+499 -2 -> 6.25E-996 powx433 power 0.04E+500 -2 -> 6.25E-998 powx434 power 0.04E+501 -2 -> 6.25E-1000 Subnormal powx435 power 0.04E+502 -2 -> 6.3E-1002 Underflow Subnormal Inexact Rounded powx436 power 0.04E+503 -2 -> 1E-1003 Underflow Subnormal Inexact Rounded powx437 power 0.04E+504 -2 -> 0E-1003 Underflow Subnormal Inexact Rounded powx441 power 0.04E+334 -3 -> 1.5625E-998 powx442 power 0.04E+335 -3 -> 1.56E-1001 Underflow Subnormal Inexact Rounded powx443 power 0.04E+336 -3 -> 0E-1003 Underflow Subnormal Inexact Rounded powx444 power 0.25E+333 -3 -> 6.4E-998 powx445 power 0.25E+334 -3 -> 6.4E-1001 Subnormal powx446 power 0.25E+335 -3 -> 1E-1003 Underflow Subnormal Inexact Rounded powx447 power 0.25E+336 -3 -> 0E-1003 Underflow Subnormal Inexact Rounded Clamped -- check sign for cubes and a few squares powx448 power -0.04E+334 -3 -> -1.5625E-998 powx449 power -0.04E+335 -3 -> -1.56E-1001 Underflow Subnormal Inexact Rounded powx450 power -0.04E+336 -3 -> -0E-1003 Underflow Subnormal Inexact Rounded powx451 power -0.25E+333 -3 -> -6.4E-998 powx452 power -0.25E+334 -3 -> -6.4E-1001 Subnormal powx453 power -0.25E+335 -3 -> -1E-1003 Underflow Subnormal Inexact Rounded powx454 power -0.25E+336 -3 -> -0E-1003 Underflow Subnormal Inexact Rounded Clamped powx455 power -0.04E+499 -2 -> 6.25E-996 powx456 power -0.04E+500 -2 -> 6.25E-998 powx457 power -0.04E+501 -2 -> 6.25E-1000 Subnormal powx458 power -0.04E+502 -2 -> 6.3E-1002 Underflow Subnormal Inexact Rounded -- test -0s precision: 9 powx560 power 0 0 -> NaN Invalid_operation powx561 power 0 -0 -> NaN Invalid_operation powx562 power -0 0 -> NaN Invalid_operation powx563 power -0 -0 -> NaN Invalid_operation powx564 power 1 0 -> 1 powx565 power 1 -0 -> 1 powx566 power -1 0 -> 1 powx567 power -1 -0 -> 1 powx568 power 0 1 -> 0 powx569 power 0 -1 -> Infinity Division_by_zero powx570 power -0 1 -> -0 powx571 power -0 -1 -> -Infinity Division_by_zero powx572 power 0 2 -> 0 powx573 power 0 -2 -> Infinity Division_by_zero powx574 power -0 2 -> 0 powx575 power -0 -2 -> Infinity Division_by_zero powx576 power 0 3 -> 0 powx577 power 0 -3 -> Infinity Division_by_zero powx578 power -0 3 -> -0 powx579 power -0 -3 -> -Infinity Division_by_zero -- Specials powx580 power Inf -Inf -> NaN Invalid_operation powx581 power Inf -1000 -> 0 powx582 power Inf -1 -> 0 powx583 power Inf -0 -> 1 powx584 power Inf 0 -> 1 powx585 power Inf 1 -> Infinity powx586 power Inf 1000 -> Infinity powx587 power Inf Inf -> NaN Invalid_operation powx588 power -1000 Inf -> NaN Invalid_operation powx589 power -Inf Inf -> NaN Invalid_operation powx590 power -1 Inf -> NaN Invalid_operation powx591 power -0 Inf -> NaN Invalid_operation powx592 power 0 Inf -> NaN Invalid_operation powx593 power 1 Inf -> NaN Invalid_operation powx594 power 1000 Inf -> NaN Invalid_operation powx595 power Inf Inf -> NaN Invalid_operation powx600 power -Inf -Inf -> NaN Invalid_operation powx601 power -Inf -1000 -> 0 powx602 power -Inf -1 -> -0 powx603 power -Inf -0 -> 1 powx604 power -Inf 0 -> 1 powx605 power -Inf 1 -> -Infinity powx606 power -Inf 1000 -> Infinity powx607 power -Inf Inf -> NaN Invalid_operation powx608 power -1000 Inf -> NaN Invalid_operation powx609 power -Inf -Inf -> NaN Invalid_operation powx610 power -1 -Inf -> NaN Invalid_operation powx611 power -0 -Inf -> NaN Invalid_operation powx612 power 0 -Inf -> NaN Invalid_operation powx613 power 1 -Inf -> NaN Invalid_operation powx614 power 1000 -Inf -> NaN Invalid_operation powx615 power Inf -Inf -> NaN Invalid_operation powx621 power NaN -Inf -> NaN Invalid_operation powx622 power NaN -1000 -> NaN powx623 power NaN -1 -> NaN powx624 power NaN -0 -> NaN powx625 power NaN 0 -> NaN powx626 power NaN 1 -> NaN powx627 power NaN 1000 -> NaN powx628 power NaN Inf -> NaN Invalid_operation powx629 power NaN NaN -> NaN powx630 power -Inf NaN -> NaN powx631 power -1000 NaN -> NaN powx632 power -1 NaN -> NaN powx633 power -0 NaN -> NaN powx634 power 0 NaN -> NaN powx635 power 1 NaN -> NaN powx636 power 1000 NaN -> NaN powx637 power Inf NaN -> NaN powx641 power sNaN -Inf -> NaN Invalid_operation powx642 power sNaN -1000 -> NaN Invalid_operation powx643 power sNaN -1 -> NaN Invalid_operation powx644 power sNaN -0 -> NaN Invalid_operation powx645 power sNaN 0 -> NaN Invalid_operation powx646 power sNaN 1 -> NaN Invalid_operation powx647 power sNaN 1000 -> NaN Invalid_operation powx648 power sNaN NaN -> NaN Invalid_operation powx649 power sNaN sNaN -> NaN Invalid_operation powx650 power NaN sNaN -> NaN Invalid_operation powx651 power -Inf sNaN -> NaN Invalid_operation powx652 power -1000 sNaN -> NaN Invalid_operation powx653 power -1 sNaN -> NaN Invalid_operation powx654 power -0 sNaN -> NaN Invalid_operation powx655 power 0 sNaN -> NaN Invalid_operation powx656 power 1 sNaN -> NaN Invalid_operation powx657 power 1000 sNaN -> NaN Invalid_operation powx658 power Inf sNaN -> NaN Invalid_operation powx659 power NaN sNaN -> NaN Invalid_operation -- NaN propagation powx660 power NaN3 sNaN7 -> NaN7 Invalid_operation powx661 power sNaN8 NaN6 -> NaN8 Invalid_operation powx662 power 1 sNaN7 -> NaN7 Invalid_operation powx663 power sNaN8 1 -> NaN8 Invalid_operation powx664 power Inf sNaN7 -> NaN7 Invalid_operation powx665 power sNaN8 Inf -> NaN Invalid_operation powx666 power Inf NaN9 -> NaN9 powx667 power NaN6 Inf -> NaN Invalid_operation powx668 power 1 NaN5 -> NaN5 powx669 power NaN2 1 -> NaN2 powx670 power NaN2 Nan4 -> NaN2 powx671 power NaN Nan4 -> NaN powx672 power NaN345 Nan -> NaN345 powx673 power Inf -sNaN7 -> -NaN7 Invalid_operation powx674 power -sNaN8 Inf -> NaN Invalid_operation powx675 power Inf -NaN9 -> -NaN9 powx676 power -NaN6 Inf -> NaN Invalid_operation powx677 power -NaN2 -Nan4 -> -NaN2 -- Examples from extended specification powx690 power Inf -2 -> 0 powx691 power Inf -1 -> 0 powx692 power Inf 0 -> 1 powx693 power Inf 1 -> Infinity powx694 power Inf 2 -> Infinity powx695 power -Inf -2 -> 0 powx696 power -Inf -1 -> -0 powx697 power -Inf 0 -> 1 powx698 power -Inf 1 -> -Infinity powx699 power -Inf 2 -> Infinity powx700 power 0 0 -> NaN Invalid_operation -- long operand and RHS range checks maxexponent: 999 minexponent: -999 precision: 9 powx701 power 12345678000 1 -> 1.23456780E+10 Rounded powx702 power 1234567800 1 -> 1.23456780E+9 Rounded powx703 power 1234567890 1 -> 1.23456789E+9 Rounded powx704 power 1234567891 1 -> 1.23456789E+9 Inexact Rounded powx705 power 12345678901 1 -> 1.23456789E+10 Inexact Rounded powx706 power 1234567896 1 -> 1.23456790E+9 Inexact Rounded powx707 power 1 12345678000 -> NaN Invalid_operation powx708 power 1 1234567800 -> NaN Invalid_operation powx709 power 1 1234567890 -> NaN Invalid_operation powx710 power 1 11234567891 -> NaN Invalid_operation powx711 power 1 12345678901 -> NaN Invalid_operation powx712 power 1 1234567896 -> NaN Invalid_operation powx713 power 1 -1234567896 -> NaN Invalid_operation powx714 power 1 1000000000 -> NaN Invalid_operation powx715 power 1 -1000000000 -> NaN Invalid_operation precision: 15 -- still checking powx741 power 12345678000 1 -> 12345678000 powx742 power 1234567800 1 -> 1234567800 powx743 power 1234567890 1 -> 1234567890 powx744 power 1234567891 1 -> 1234567891 powx745 power 12345678901 1 -> 12345678901 powx746 power 1234567896 1 -> 1234567896 powx747 power 1 12345678000 -> NaN Invalid_operation powx748 power 1 -1234567896 -> NaN Invalid_operation powx749 power 1 1000000000 -> NaN Invalid_operation powx740 power 1 -1000000000 -> NaN Invalid_operation -- check for double-rounded subnormals precision: 5 maxexponent: 79 minexponent: -79 powx750 power 1.2347E-40 2 -> 1.524E-80 Inexact Rounded Subnormal Underflow -- Null tests powx900 power 1 # -> NaN Invalid_operation powx901 power # 1 -> NaN Invalid_operation --- NEW FILE: quantize.decTest --- ------------------------------------------------------------------------ -- quantize.decTest -- decimal quantize operation -- -- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 -- Most of the tests here assume a "regular pattern", where the -- sign and coefficient are +1. -- 2004.03.15 Underflow for quantize is suppressed extended: 1 precision: 9 rounding: half_up maxExponent: 999 minexponent: -999 -- sanity checks quax001 quantize 0 1e0 -> 0 quax002 quantize 1 1e0 -> 1 quax003 quantize 0.1 1e+2 -> 0E+2 Inexact Rounded quax005 quantize 0.1 1e+1 -> 0E+1 Inexact Rounded quax006 quantize 0.1 1e0 -> 0 Inexact Rounded quax007 quantize 0.1 1e-1 -> 0.1 quax008 quantize 0.1 1e-2 -> 0.10 quax009 quantize 0.1 1e-3 -> 0.100 quax010 quantize 0.9 1e+2 -> 0E+2 Inexact Rounded quax011 quantize 0.9 1e+1 -> 0E+1 Inexact Rounded quax012 quantize 0.9 1e+0 -> 1 Inexact Rounded quax013 quantize 0.9 1e-1 -> 0.9 quax014 quantize 0.9 1e-2 -> 0.90 quax015 quantize 0.9 1e-3 -> 0.900 -- negatives quax021 quantize -0 1e0 -> -0 quax022 quantize -1 1e0 -> -1 quax023 quantize -0.1 1e+2 -> -0E+2 Inexact Rounded quax025 quantize -0.1 1e+1 -> -0E+1 Inexact Rounded quax026 quantize -0.1 1e0 -> -0 Inexact Rounded quax027 quantize -0.1 1e-1 -> -0.1 quax028 quantize -0.1 1e-2 -> -0.10 quax029 quantize -0.1 1e-3 -> -0.100 quax030 quantize -0.9 1e+2 -> -0E+2 Inexact Rounded quax031 quantize -0.9 1e+1 -> -0E+1 Inexact Rounded quax032 quantize -0.9 1e+0 -> -1 Inexact Rounded quax033 quantize -0.9 1e-1 -> -0.9 quax034 quantize -0.9 1e-2 -> -0.90 quax035 quantize -0.9 1e-3 -> -0.900 quax036 quantize -0.5 1e+2 -> -0E+2 Inexact Rounded quax037 quantize -0.5 1e+1 -> -0E+1 Inexact Rounded quax038 quantize -0.5 1e+0 -> -1 Inexact Rounded quax039 quantize -0.5 1e-1 -> -0.5 quax040 quantize -0.5 1e-2 -> -0.50 quax041 quantize -0.5 1e-3 -> -0.500 quax042 quantize -0.9 1e+2 -> -0E+2 Inexact Rounded quax043 quantize -0.9 1e+1 -> -0E+1 Inexact Rounded quax044 quantize -0.9 1e+0 -> -1 Inexact Rounded quax045 quantize -0.9 1e-1 -> -0.9 quax046 quantize -0.9 1e-2 -> -0.90 quax047 quantize -0.9 1e-3 -> -0.900 -- examples from Specification quax060 quantize 2.17 0.001 -> 2.170 quax061 quantize 2.17 0.01 -> 2.17 quax062 quantize 2.17 0.1 -> 2.2 Inexact Rounded quax063 quantize 2.17 1e+0 -> 2 Inexact Rounded quax064 quantize 2.17 1e+1 -> 0E+1 Inexact Rounded quax065 quantize -Inf Inf -> -Infinity quax066 quantize 2 Inf -> NaN Invalid_operation quax067 quantize -0.1 1 -> -0 Inexact Rounded quax068 quantize -0 1e+5 -> -0E+5 quax069 quantize +35236450.6 1e-2 -> NaN Invalid_operation quax070 quantize -35236450.6 1e-2 -> NaN Invalid_operation quax071 quantize 217 1e-1 -> 217.0 quax072 quantize 217 1e+0 -> 217 quax073 quantize 217 1e+1 -> 2.2E+2 Inexact Rounded quax074 quantize 217 1e+2 -> 2E+2 Inexact Rounded -- general tests .. quax089 quantize 12 1e+4 -> 0E+4 Inexact Rounded quax090 quantize 12 1e+3 -> 0E+3 Inexact Rounded quax091 quantize 12 1e+2 -> 0E+2 Inexact Rounded quax092 quantize 12 1e+1 -> 1E+1 Inexact Rounded quax093 quantize 1.2345 1e-2 -> 1.23 Inexact Rounded quax094 quantize 1.2355 1e-2 -> 1.24 Inexact Rounded quax095 quantize 1.2345 1e-6 -> 1.234500 quax096 quantize 9.9999 1e-2 -> 10.00 Inexact Rounded quax097 quantize 0.0001 1e-2 -> 0.00 Inexact Rounded quax098 quantize 0.001 1e-2 -> 0.00 Inexact Rounded quax099 quantize 0.009 1e-2 -> 0.01 Inexact Rounded quax100 quantize 92 1e+2 -> 1E+2 Inexact Rounded quax101 quantize -1 1e0 -> -1 quax102 quantize -1 1e-1 -> -1.0 quax103 quantize -1 1e-2 -> -1.00 quax104 quantize 0 1e0 -> 0 quax105 quantize 0 1e-1 -> 0.0 quax106 quantize 0 1e-2 -> 0.00 quax107 quantize 0.00 1e0 -> 0 quax108 quantize 0 1e+1 -> 0E+1 quax109 quantize 0 1e+2 -> 0E+2 quax110 quantize +1 1e0 -> 1 quax111 quantize +1 1e-1 -> 1.0 quax112 quantize +1 1e-2 -> 1.00 quax120 quantize 1.04 1e-3 -> 1.040 quax121 quantize 1.04 1e-2 -> 1.04 quax122 quantize 1.04 1e-1 -> 1.0 Inexact Rounded quax123 quantize 1.04 1e0 -> 1 Inexact Rounded quax124 quantize 1.05 1e-3 -> 1.050 quax125 quantize 1.05 1e-2 -> 1.05 quax126 quantize 1.05 1e-1 -> 1.1 Inexact Rounded quax127 quantize 1.05 1e0 -> 1 Inexact Rounded quax128 quantize 1.05 1e-3 -> 1.050 quax129 quantize 1.05 1e-2 -> 1.05 quax130 quantize 1.05 1e-1 -> 1.1 Inexact Rounded quax131 quantize 1.05 1e0 -> 1 Inexact Rounded quax132 quantize 1.06 1e-3 -> 1.060 quax133 quantize 1.06 1e-2 -> 1.06 quax134 quantize 1.06 1e-1 -> 1.1 Inexact Rounded quax135 quantize 1.06 1e0 -> 1 Inexact Rounded quax140 quantize -10 1e-2 -> -10.00 quax141 quantize +1 1e-2 -> 1.00 quax142 quantize +10 1e-2 -> 10.00 quax143 quantize 1E+10 1e-2 -> NaN Invalid_operation quax144 quantize 1E-10 1e-2 -> 0.00 Inexact Rounded quax145 quantize 1E-3 1e-2 -> 0.00 Inexact Rounded quax146 quantize 1E-2 1e-2 -> 0.01 quax147 quantize 1E-1 1e-2 -> 0.10 quax148 quantize 0E-10 1e-2 -> 0.00 quax150 quantize 1.0600 1e-5 -> 1.06000 quax151 quantize 1.0600 1e-4 -> 1.0600 quax152 quantize 1.0600 1e-3 -> 1.060 Rounded quax153 quantize 1.0600 1e-2 -> 1.06 Rounded quax154 quantize 1.0600 1e-1 -> 1.1 Inexact Rounded quax155 quantize 1.0600 1e0 -> 1 Inexact Rounded -- base tests with non-1 coefficients quax161 quantize 0 -9e0 -> 0 quax162 quantize 1 -7e0 -> 1 quax163 quantize 0.1 -1e+2 -> 0E+2 Inexact Rounded quax165 quantize 0.1 0e+1 -> 0E+1 Inexact Rounded quax166 quantize 0.1 2e0 -> 0 Inexact Rounded quax167 quantize 0.1 3e-1 -> 0.1 quax168 quantize 0.1 44e-2 -> 0.10 quax169 quantize 0.1 555e-3 -> 0.100 quax170 quantize 0.9 6666e+2 -> 0E+2 Inexact Rounded quax171 quantize 0.9 -777e+1 -> 0E+1 Inexact Rounded quax172 quantize 0.9 -88e+0 -> 1 Inexact Rounded quax173 quantize 0.9 -9e-1 -> 0.9 quax174 quantize 0.9 0e-2 -> 0.90 quax175 quantize 0.9 1.1e-3 -> 0.9000 -- negatives quax181 quantize -0 1.1e0 -> -0.0 quax182 quantize -1 -1e0 -> -1 quax183 quantize -0.1 11e+2 -> -0E+2 Inexact Rounded quax185 quantize -0.1 111e+1 -> -0E+1 Inexact Rounded quax186 quantize -0.1 71e0 -> -0 Inexact Rounded quax187 quantize -0.1 -91e-1 -> -0.1 quax188 quantize -0.1 -.1e-2 -> -0.100 quax189 quantize -0.1 -1e-3 -> -0.100 quax190 quantize -0.9 0e+2 -> -0E+2 Inexact Rounded quax191 quantize -0.9 -0e+1 -> -0E+1 Inexact Rounded quax192 quantize -0.9 -10e+0 -> -1 Inexact Rounded quax193 quantize -0.9 100e-1 -> -0.9 quax194 quantize -0.9 999e-2 -> -0.90 -- +ve exponents .. quax201 quantize -1 1e+0 -> -1 quax202 quantize -1 1e+1 -> -0E+1 Inexact Rounded quax203 quantize -1 1e+2 -> -0E+2 Inexact Rounded quax204 quantize 0 1e+0 -> 0 quax205 quantize 0 1e+1 -> 0E+1 quax206 quantize 0 1e+2 -> 0E+2 quax207 quantize +1 1e+0 -> 1 quax208 quantize +1 1e+1 -> 0E+1 Inexact Rounded quax209 quantize +1 1e+2 -> 0E+2 Inexact Rounded quax220 quantize 1.04 1e+3 -> 0E+3 Inexact Rounded quax221 quantize 1.04 1e+2 -> 0E+2 Inexact Rounded quax222 quantize 1.04 1e+1 -> 0E+1 Inexact Rounded quax223 quantize 1.04 1e+0 -> 1 Inexact Rounded quax224 quantize 1.05 1e+3 -> 0E+3 Inexact Rounded quax225 quantize 1.05 1e+2 -> 0E+2 Inexact Rounded quax226 quantize 1.05 1e+1 -> 0E+1 Inexact Rounded quax227 quantize 1.05 1e+0 -> 1 Inexact Rounded quax228 quantize 1.05 1e+3 -> 0E+3 Inexact Rounded quax229 quantize 1.05 1e+2 -> 0E+2 Inexact Rounded quax230 quantize 1.05 1e+1 -> 0E+1 Inexact Rounded quax231 quantize 1.05 1e+0 -> 1 Inexact Rounded quax232 quantize 1.06 1e+3 -> 0E+3 Inexact Rounded quax233 quantize 1.06 1e+2 -> 0E+2 Inexact Rounded quax234 quantize 1.06 1e+1 -> 0E+1 Inexact Rounded quax235 quantize 1.06 1e+0 -> 1 Inexact Rounded quax240 quantize -10 1e+1 -> -1E+1 Rounded quax241 quantize +1 1e+1 -> 0E+1 Inexact Rounded quax242 quantize +10 1e+1 -> 1E+1 Rounded quax243 quantize 1E+1 1e+1 -> 1E+1 -- underneath this is E+1 quax244 quantize 1E+2 1e+1 -> 1.0E+2 -- underneath this is E+1 quax245 quantize 1E+3 1e+1 -> 1.00E+3 -- underneath this is E+1 quax246 quantize 1E+4 1e+1 -> 1.000E+4 -- underneath this is E+1 quax247 quantize 1E+5 1e+1 -> 1.0000E+5 -- underneath this is E+1 quax248 quantize 1E+6 1e+1 -> 1.00000E+6 -- underneath this is E+1 quax249 quantize 1E+7 1e+1 -> 1.000000E+7 -- underneath this is E+1 quax250 quantize 1E+8 1e+1 -> 1.0000000E+8 -- underneath this is E+1 quax251 quantize 1E+9 1e+1 -> 1.00000000E+9 -- underneath this is E+1 -- next one tries to add 9 zeros quax252 quantize 1E+10 1e+1 -> NaN Invalid_operation quax253 quantize 1E-10 1e+1 -> 0E+1 Inexact Rounded quax254 quantize 1E-2 1e+1 -> 0E+1 Inexact Rounded quax255 quantize 0E-10 1e+1 -> 0E+1 quax256 quantize -0E-10 1e+1 -> -0E+1 quax257 quantize -0E-1 1e+1 -> -0E+1 quax258 quantize -0 1e+1 -> -0E+1 quax259 quantize -0E+1 1e+1 -> -0E+1 quax260 quantize -10 1e+2 -> -0E+2 Inexact Rounded quax261 quantize +1 1e+2 -> 0E+2 Inexact Rounded quax262 quantize +10 1e+2 -> 0E+2 Inexact Rounded quax263 quantize 1E+1 1e+2 -> 0E+2 Inexact Rounded quax264 quantize 1E+2 1e+2 -> 1E+2 quax265 quantize 1E+3 1e+2 -> 1.0E+3 quax266 quantize 1E+4 1e+2 -> 1.00E+4 quax267 quantize 1E+5 1e+2 -> 1.000E+5 quax268 quantize 1E+6 1e+2 -> 1.0000E+6 quax269 quantize 1E+7 1e+2 -> 1.00000E+7 quax270 quantize 1E+8 1e+2 -> 1.000000E+8 quax271 quantize 1E+9 1e+2 -> 1.0000000E+9 quax272 quantize 1E+10 1e+2 -> 1.00000000E+10 quax273 quantize 1E-10 1e+2 -> 0E+2 Inexact Rounded quax274 quantize 1E-2 1e+2 -> 0E+2 Inexact Rounded quax275 quantize 0E-10 1e+2 -> 0E+2 quax280 quantize -10 1e+3 -> -0E+3 Inexact Rounded quax281 quantize +1 1e+3 -> 0E+3 Inexact Rounded quax282 quantize +10 1e+3 -> 0E+3 Inexact Rounded quax283 quantize 1E+1 1e+3 -> 0E+3 Inexact Rounded quax284 quantize 1E+2 1e+3 -> 0E+3 Inexact Rounded quax285 quantize 1E+3 1e+3 -> 1E+3 quax286 quantize 1E+4 1e+3 -> 1.0E+4 quax287 quantize 1E+5 1e+3 -> 1.00E+5 quax288 quantize 1E+6 1e+3 -> 1.000E+6 quax289 quantize 1E+7 1e+3 -> 1.0000E+7 quax290 quantize 1E+8 1e+3 -> 1.00000E+8 quax291 quantize 1E+9 1e+3 -> 1.000000E+9 quax292 quantize 1E+10 1e+3 -> 1.0000000E+10 quax293 quantize 1E-10 1e+3 -> 0E+3 Inexact Rounded quax294 quantize 1E-2 1e+3 -> 0E+3 Inexact Rounded quax295 quantize 0E-10 1e+3 -> 0E+3 -- round up from below [sign wrong in JIT compiler once] quax300 quantize 0.0078 1e-5 -> 0.00780 quax301 quantize 0.0078 1e-4 -> 0.0078 quax302 quantize 0.0078 1e-3 -> 0.008 Inexact Rounded quax303 quantize 0.0078 1e-2 -> 0.01 Inexact Rounded quax304 quantize 0.0078 1e-1 -> 0.0 Inexact Rounded quax305 quantize 0.0078 1e0 -> 0 Inexact Rounded quax306 quantize 0.0078 1e+1 -> 0E+1 Inexact Rounded quax307 quantize 0.0078 1e+2 -> 0E+2 Inexact Rounded quax310 quantize -0.0078 1e-5 -> -0.00780 quax311 quantize -0.0078 1e-4 -> -0.0078 quax312 quantize -0.0078 1e-3 -> -0.008 Inexact Rounded quax313 quantize -0.0078 1e-2 -> -0.01 Inexact Rounded quax314 quantize -0.0078 1e-1 -> -0.0 Inexact Rounded quax315 quantize -0.0078 1e0 -> -0 Inexact Rounded quax316 quantize -0.0078 1e+1 -> -0E+1 Inexact Rounded quax317 quantize -0.0078 1e+2 -> -0E+2 Inexact Rounded quax320 quantize 0.078 1e-5 -> 0.07800 quax321 quantize 0.078 1e-4 -> 0.0780 quax322 quantize 0.078 1e-3 -> 0.078 quax323 quantize 0.078 1e-2 -> 0.08 Inexact Rounded quax324 quantize 0.078 1e-1 -> 0.1 Inexact Rounded quax325 quantize 0.078 1e0 -> 0 Inexact Rounded quax326 quantize 0.078 1e+1 -> 0E+1 Inexact Rounded quax327 quantize 0.078 1e+2 -> 0E+2 Inexact Rounded quax330 quantize -0.078 1e-5 -> -0.07800 quax331 quantize -0.078 1e-4 -> -0.0780 quax332 quantize -0.078 1e-3 -> -0.078 quax333 quantize -0.078 1e-2 -> -0.08 Inexact Rounded quax334 quantize -0.078 1e-1 -> -0.1 Inexact Rounded quax335 quantize -0.078 1e0 -> -0 Inexact Rounded quax336 quantize -0.078 1e+1 -> -0E+1 Inexact Rounded quax337 quantize -0.078 1e+2 -> -0E+2 Inexact Rounded quax340 quantize 0.78 1e-5 -> 0.78000 quax341 quantize 0.78 1e-4 -> 0.7800 quax342 quantize 0.78 1e-3 -> 0.780 quax343 quantize 0.78 1e-2 -> 0.78 quax344 quantize 0.78 1e-1 -> 0.8 Inexact Rounded quax345 quantize 0.78 1e0 -> 1 Inexact Rounded quax346 quantize 0.78 1e+1 -> 0E+1 Inexact Rounded quax347 quantize 0.78 1e+2 -> 0E+2 Inexact Rounded quax350 quantize -0.78 1e-5 -> -0.78000 quax351 quantize -0.78 1e-4 -> -0.7800 quax352 quantize -0.78 1e-3 -> -0.780 quax353 quantize -0.78 1e-2 -> -0.78 quax354 quantize -0.78 1e-1 -> -0.8 Inexact Rounded quax355 quantize -0.78 1e0 -> -1 Inexact Rounded quax356 quantize -0.78 1e+1 -> -0E+1 Inexact Rounded quax357 quantize -0.78 1e+2 -> -0E+2 Inexact Rounded quax360 quantize 7.8 1e-5 -> 7.80000 quax361 quantize 7.8 1e-4 -> 7.8000 quax362 quantize 7.8 1e-3 -> 7.800 quax363 quantize 7.8 1e-2 -> 7.80 quax364 quantize 7.8 1e-1 -> 7.8 quax365 quantize 7.8 1e0 -> 8 Inexact Rounded quax366 quantize 7.8 1e+1 -> 1E+1 Inexact Rounded quax367 quantize 7.8 1e+2 -> 0E+2 Inexact Rounded quax368 quantize 7.8 1e+3 -> 0E+3 Inexact Rounded quax370 quantize -7.8 1e-5 -> -7.80000 quax371 quantize -7.8 1e-4 -> -7.8000 quax372 quantize -7.8 1e-3 -> -7.800 quax373 quantize -7.8 1e-2 -> -7.80 quax374 quantize -7.8 1e-1 -> -7.8 quax375 quantize -7.8 1e0 -> -8 Inexact Rounded quax376 quantize -7.8 1e+1 -> -1E+1 Inexact Rounded quax377 quantize -7.8 1e+2 -> -0E+2 Inexact Rounded quax378 quantize -7.8 1e+3 -> -0E+3 Inexact Rounded -- some individuals precision: 9 quax380 quantize 352364.506 1e-2 -> 352364.51 Inexact Rounded quax381 quantize 3523645.06 1e-2 -> 3523645.06 quax382 quantize 35236450.6 1e-2 -> NaN Invalid_operation quax383 quantize 352364506 1e-2 -> NaN Invalid_operation quax384 quantize -352364.506 1e-2 -> -352364.51 Inexact Rounded quax385 quantize -3523645.06 1e-2 -> -3523645.06 quax386 quantize -35236450.6 1e-2 -> NaN Invalid_operation quax387 quantize -352364506 1e-2 -> NaN Invalid_operation rounding: down quax389 quantize 35236450.6 1e-2 -> NaN Invalid_operation -- ? should that one instead have been: -- quax389 quantize 35236450.6 1e-2 -> NaN Invalid_operation rounding: half_up -- and a few more from e-mail discussions precision: 7 quax391 quantize 12.34567 1e-3 -> 12.346 Inexact Rounded quax392 quantize 123.4567 1e-3 -> 123.457 Inexact Rounded quax393 quantize 1234.567 1e-3 -> 1234.567 quax394 quantize 12345.67 1e-3 -> NaN Invalid_operation quax395 quantize 123456.7 1e-3 -> NaN Invalid_operation quax396 quantize 1234567. 1e-3 -> NaN Invalid_operation -- some 9999 round-up cases precision: 9 quax400 quantize 9.999 1e-5 -> 9.99900 quax401 quantize 9.999 1e-4 -> 9.9990 quax402 quantize 9.999 1e-3 -> 9.999 quax403 quantize 9.999 1e-2 -> 10.00 Inexact Rounded quax404 quantize 9.999 1e-1 -> 10.0 Inexact Rounded quax405 quantize 9.999 1e0 -> 10 Inexact Rounded quax406 quantize 9.999 1e1 -> 1E+1 Inexact Rounded quax407 quantize 9.999 1e2 -> 0E+2 Inexact Rounded quax410 quantize 0.999 1e-5 -> 0.99900 quax411 quantize 0.999 1e-4 -> 0.9990 quax412 quantize 0.999 1e-3 -> 0.999 quax413 quantize 0.999 1e-2 -> 1.00 Inexact Rounded quax414 quantize 0.999 1e-1 -> 1.0 Inexact Rounded quax415 quantize 0.999 1e0 -> 1 Inexact Rounded quax416 quantize 0.999 1e1 -> 0E+1 Inexact Rounded quax420 quantize 0.0999 1e-5 -> 0.09990 quax421 quantize 0.0999 1e-4 -> 0.0999 quax422 quantize 0.0999 1e-3 -> 0.100 Inexact Rounded quax423 quantize 0.0999 1e-2 -> 0.10 Inexact Rounded quax424 quantize 0.0999 1e-1 -> 0.1 Inexact Rounded quax425 quantize 0.0999 1e0 -> 0 Inexact Rounded quax426 quantize 0.0999 1e1 -> 0E+1 Inexact Rounded quax430 quantize 0.00999 1e-5 -> 0.00999 quax431 quantize 0.00999 1e-4 -> 0.0100 Inexact Rounded quax432 quantize 0.00999 1e-3 -> 0.010 Inexact Rounded quax433 quantize 0.00999 1e-2 -> 0.01 Inexact Rounded quax434 quantize 0.00999 1e-1 -> 0.0 Inexact Rounded quax435 quantize 0.00999 1e0 -> 0 Inexact Rounded quax436 quantize 0.00999 1e1 -> 0E+1 Inexact Rounded quax440 quantize 0.000999 1e-5 -> 0.00100 Inexact Rounded quax441 quantize 0.000999 1e-4 -> 0.0010 Inexact Rounded quax442 quantize 0.000999 1e-3 -> 0.001 Inexact Rounded quax443 quantize 0.000999 1e-2 -> 0.00 Inexact Rounded quax444 quantize 0.000999 1e-1 -> 0.0 Inexact Rounded quax445 quantize 0.000999 1e0 -> 0 Inexact Rounded quax446 quantize 0.000999 1e1 -> 0E+1 Inexact Rounded precision: 8 quax449 quantize 9.999E-15 1e-23 -> NaN Invalid_operation quax450 quantize 9.999E-15 1e-22 -> 9.9990000E-15 quax451 quantize 9.999E-15 1e-21 -> 9.999000E-15 quax452 quantize 9.999E-15 1e-20 -> 9.99900E-15 quax453 quantize 9.999E-15 1e-19 -> 9.9990E-15 quax454 quantize 9.999E-15 1e-18 -> 9.999E-15 quax455 quantize 9.999E-15 1e-17 -> 1.000E-14 Inexact Rounded quax456 quantize 9.999E-15 1e-16 -> 1.00E-14 Inexact Rounded quax457 quantize 9.999E-15 1e-15 -> 1.0E-14 Inexact Rounded quax458 quantize 9.999E-15 1e-14 -> 1E-14 Inexact Rounded quax459 quantize 9.999E-15 1e-13 -> 0E-13 Inexact Rounded quax460 quantize 9.999E-15 1e-12 -> 0E-12 Inexact Rounded quax461 quantize 9.999E-15 1e-11 -> 0E-11 Inexact Rounded quax462 quantize 9.999E-15 1e-10 -> 0E-10 Inexact Rounded quax463 quantize 9.999E-15 1e-9 -> 0E-9 Inexact Rounded quax464 quantize 9.999E-15 1e-8 -> 0E-8 Inexact Rounded quax465 quantize 9.999E-15 1e-7 -> 0E-7 Inexact Rounded quax466 quantize 9.999E-15 1e-6 -> 0.000000 Inexact Rounded quax467 quantize 9.999E-15 1e-5 -> 0.00000 Inexact Rounded quax468 quantize 9.999E-15 1e-4 -> 0.0000 Inexact Rounded quax469 quantize 9.999E-15 1e-3 -> 0.000 Inexact Rounded quax470 quantize 9.999E-15 1e-2 -> 0.00 Inexact Rounded quax471 quantize 9.999E-15 1e-1 -> 0.0 Inexact Rounded quax472 quantize 9.999E-15 1e0 -> 0 Inexact Rounded quax473 quantize 9.999E-15 1e1 -> 0E+1 Inexact Rounded -- long operand checks [rhs checks removed] maxexponent: 999 minexponent: -999 precision: 9 quax481 quantize 12345678000 1e+3 -> 1.2345678E+10 Rounded quax482 quantize 1234567800 1e+1 -> 1.23456780E+9 Rounded quax483 quantize 1234567890 1e+1 -> 1.23456789E+9 Rounded quax484 quantize 1234567891 1e+1 -> 1.23456789E+9 Inexact Rounded quax485 quantize 12345678901 1e+2 -> 1.23456789E+10 Inexact Rounded quax486 quantize 1234567896 1e+1 -> 1.23456790E+9 Inexact Rounded -- a potential double-round quax487 quantize 1234.987643 1e-4 -> 1234.9876 Inexact Rounded quax488 quantize 1234.987647 1e-4 -> 1234.9876 Inexact Rounded precision: 15 quax491 quantize 12345678000 1e+3 -> 1.2345678E+10 Rounded quax492 quantize 1234567800 1e+1 -> 1.23456780E+9 Rounded quax493 quantize 1234567890 1e+1 -> 1.23456789E+9 Rounded quax494 quantize 1234567891 1e+1 -> 1.23456789E+9 Inexact Rounded quax495 quantize 12345678901 1e+2 -> 1.23456789E+10 Inexact Rounded quax496 quantize 1234567896 1e+1 -> 1.23456790E+9 Inexact Rounded quax497 quantize 1234.987643 1e-4 -> 1234.9876 Inexact Rounded quax498 quantize 1234.987647 1e-4 -> 1234.9876 Inexact Rounded -- Zeros quax500 quantize 0 1e1 -> 0E+1 quax501 quantize 0 1e0 -> 0 quax502 quantize 0 1e-1 -> 0.0 quax503 quantize 0.0 1e-1 -> 0.0 quax504 quantize 0.0 1e0 -> 0 quax505 quantize 0.0 1e+1 -> 0E+1 quax506 quantize 0E+1 1e-1 -> 0.0 quax507 quantize 0E+1 1e0 -> 0 quax508 quantize 0E+1 1e+1 -> 0E+1 quax509 quantize -0 1e1 -> -0E+1 quax510 quantize -0 1e0 -> -0 quax511 quantize -0 1e-1 -> -0.0 quax512 quantize -0.0 1e-1 -> -0.0 quax513 quantize -0.0 1e0 -> -0 quax514 quantize -0.0 1e+1 -> -0E+1 quax515 quantize -0E+1 1e-1 -> -0.0 quax516 quantize -0E+1 1e0 -> -0 quax517 quantize -0E+1 1e+1 -> -0E+1 -- Suspicious RHS values maxexponent: 999999999 minexponent: -999999999 precision: 15 quax520 quantize 1.234 1e999999000 -> 0E+999999000 Inexact Rounded quax521 quantize 123.456 1e999999000 -> 0E+999999000 Inexact Rounded quax522 quantize 1.234 1e999999999 -> 0E+999999999 Inexact Rounded quax523 quantize 123.456 1e999999999 -> 0E+999999999 Inexact Rounded quax524 quantize 123.456 1e1000000000 -> NaN Invalid_operation quax525 quantize 123.456 1e12345678903 -> NaN Invalid_operation -- next four are "won't fit" overflows quax526 quantize 1.234 1e-999999000 -> NaN Invalid_operation quax527 quantize 123.456 1e-999999000 -> NaN Invalid_operation quax528 quantize 1.234 1e-999999999 -> NaN Invalid_operation quax529 quantize 123.456 1e-999999999 -> NaN Invalid_operation quax530 quantize 123.456 1e-1000000014 -> NaN Invalid_operation quax531 quantize 123.456 1e-12345678903 -> NaN Invalid_operation maxexponent: 999 minexponent: -999 precision: 15 quax532 quantize 1.234E+999 1e999 -> 1E+999 Inexact Rounded quax533 quantize 1.234E+998 1e999 -> 0E+999 Inexact Rounded quax534 quantize 1.234 1e999 -> 0E+999 Inexact Rounded quax535 quantize 1.234 1e1000 -> NaN Invalid_operation quax536 quantize 1.234 1e5000 -> NaN Invalid_operation quax537 quantize 0 1e-999 -> 0E-999 -- next two are "won't fit" overflows quax538 quantize 1.234 1e-999 -> NaN Invalid_operation quax539 quantize 1.234 1e-1000 -> NaN Invalid_operation quax540 quantize 1.234 1e-5000 -> NaN Invalid_operation -- [more below] -- check bounds (lhs maybe out of range for destination, etc.) precision: 7 quax541 quantize 1E+999 1e+999 -> 1E+999 quax542 quantize 1E+1000 1e+999 -> NaN Invalid_operation quax543 quantize 1E+999 1e+1000 -> NaN Invalid_operation quax544 quantize 1E-999 1e-999 -> 1E-999 quax545 quantize 1E-1000 1e-999 -> 0E-999 Inexact Rounded quax546 quantize 1E-999 1e-1000 -> 1.0E-999 quax547 quantize 1E-1005 1e-999 -> 0E-999 Inexact Rounded quax548 quantize 1E-1006 1e-999 -> 0E-999 Inexact Rounded quax549 quantize 1E-1007 1e-999 -> 0E-999 Inexact Rounded quax550 quantize 1E-998 1e-1005 -> NaN Invalid_operation -- won't fit quax551 quantize 1E-999 1e-1005 -> 1.000000E-999 quax552 quantize 1E-1000 1e-1005 -> 1.00000E-1000 Subnormal quax553 quantize 1E-999 1e-1006 -> NaN Invalid_operation quax554 quantize 1E-999 1e-1007 -> NaN Invalid_operation -- related subnormal rounding quax555 quantize 1.666666E-999 1e-1005 -> 1.666666E-999 quax556 quantize 1.666666E-1000 1e-1005 -> 1.66667E-1000 Subnormal Inexact Rounded quax557 quantize 1.666666E-1001 1e-1005 -> 1.6667E-1001 Subnormal Inexact Rounded quax558 quantize 1.666666E-1002 1e-1005 -> 1.667E-1002 Subnormal Inexact Rounded quax559 quantize 1.666666E-1003 1e-1005 -> 1.67E-1003 Subnormal Inexact Rounded quax560 quantize 1.666666E-1004 1e-1005 -> 1.7E-1004 Subnormal Inexact Rounded quax561 quantize 1.666666E-1005 1e-1005 -> 2E-1005 Subnormal Inexact Rounded quax562 quantize 1.666666E-1006 1e-1005 -> 0E-1005 Inexact Rounded quax563 quantize 1.666666E-1007 1e-1005 -> 0E-1005 Inexact Rounded -- Specials quax580 quantize Inf -Inf -> Infinity quax581 quantize Inf 1e-1000 -> NaN Invalid_operation quax582 quantize Inf 1e-1 -> NaN Invalid_operation quax583 quantize Inf 1e0 -> NaN Invalid_operation quax584 quantize Inf 1e1 -> NaN Invalid_operation quax585 quantize Inf 1e1000 -> NaN Invalid_operation quax586 quantize Inf Inf -> Infinity quax587 quantize -1000 Inf -> NaN Invalid_operation quax588 quantize -Inf Inf -> -Infinity quax589 quantize -1 Inf -> NaN Invalid_operation quax590 quantize 0 Inf -> NaN Invalid_operation quax591 quantize 1 Inf -> NaN Invalid_operation quax592 quantize 1000 Inf -> NaN Invalid_operation quax593 quantize Inf Inf -> Infinity quax594 quantize Inf 1e-0 -> NaN Invalid_operation quax595 quantize -0 Inf -> NaN Invalid_operation quax600 quantize -Inf -Inf -> -Infinity quax601 quantize -Inf 1e-1000 -> NaN Invalid_operation quax602 quantize -Inf 1e-1 -> NaN Invalid_operation quax603 quantize -Inf 1e0 -> NaN Invalid_operation quax604 quantize -Inf 1e1 -> NaN Invalid_operation quax605 quantize -Inf 1e1000 -> NaN Invalid_operation quax606 quantize -Inf Inf -> -Infinity quax607 quantize -1000 Inf -> NaN Invalid_operation quax608 quantize -Inf -Inf -> -Infinity quax609 quantize -1 -Inf -> NaN Invalid_operation quax610 quantize 0 -Inf -> NaN Invalid_operation quax611 quantize 1 -Inf -> NaN Invalid_operation quax612 quantize 1000 -Inf -> NaN Invalid_operation quax613 quantize Inf -Inf -> Infinity quax614 quantize -Inf 1e-0 -> NaN Invalid_operation quax615 quantize -0 -Inf -> NaN Invalid_operation quax621 quantize NaN -Inf -> NaN quax622 quantize NaN 1e-1000 -> NaN quax623 quantize NaN 1e-1 -> NaN quax624 quantize NaN 1e0 -> NaN quax625 quantize NaN 1e1 -> NaN quax626 quantize NaN 1e1000 -> NaN quax627 quantize NaN Inf -> NaN quax628 quantize NaN NaN -> NaN quax629 quantize -Inf NaN -> NaN quax630 quantize -1000 NaN -> NaN quax631 quantize -1 NaN -> NaN quax632 quantize 0 NaN -> NaN quax633 quantize 1 NaN -> NaN quax634 quantize 1000 NaN -> NaN quax635 quantize Inf NaN -> NaN quax636 quantize NaN 1e-0 -> NaN quax637 quantize -0 NaN -> NaN quax641 quantize sNaN -Inf -> NaN Invalid_operation quax642 quantize sNaN 1e-1000 -> NaN Invalid_operation quax643 quantize sNaN 1e-1 -> NaN Invalid_operation quax644 quantize sNaN 1e0 -> NaN Invalid_operation quax645 quantize sNaN 1e1 -> NaN Invalid_operation quax646 quantize sNaN 1e1000 -> NaN Invalid_operation quax647 quantize sNaN NaN -> NaN Invalid_operation quax648 quantize sNaN sNaN -> NaN Invalid_operation quax649 quantize NaN sNaN -> NaN Invalid_operation quax650 quantize -Inf sNaN -> NaN Invalid_operation quax651 quantize -1000 sNaN -> NaN Invalid_operation quax652 quantize -1 sNaN -> NaN Invalid_operation quax653 quantize 0 sNaN -> NaN Invalid_operation quax654 quantize 1 sNaN -> NaN Invalid_operation quax655 quantize 1000 sNaN -> NaN Invalid_operation quax656 quantize Inf sNaN -> NaN Invalid_operation quax657 quantize NaN sNaN -> NaN Invalid_operation quax658 quantize sNaN 1e-0 -> NaN Invalid_operation quax659 quantize -0 sNaN -> NaN Invalid_operation -- propagating NaNs quax661 quantize NaN9 -Inf -> NaN9 quax662 quantize NaN8 919 -> NaN8 quax663 quantize NaN71 Inf -> NaN71 quax664 quantize NaN6 NaN5 -> NaN6 quax665 quantize -Inf NaN4 -> NaN4 quax666 quantize -919 NaN31 -> NaN31 quax667 quantize Inf NaN2 -> NaN2 quax671 quantize sNaN99 -Inf -> NaN99 Invalid_operation quax672 quantize sNaN98 -11 -> NaN98 Invalid_operation quax673 quantize sNaN97 NaN -> NaN97 Invalid_operation quax674 quantize sNaN16 sNaN94 -> NaN16 Invalid_operation quax675 quantize NaN95 sNaN93 -> NaN93 Invalid_operation quax676 quantize -Inf sNaN92 -> NaN92 Invalid_operation quax677 quantize 088 sNaN91 -> NaN91 Invalid_operation quax678 quantize Inf sNaN90 -> NaN90 Invalid_operation quax679 quantize NaN sNaN88 -> NaN88 Invalid_operation quax681 quantize -NaN9 -Inf -> -NaN9 quax682 quantize -NaN8 919 -> -NaN8 quax683 quantize -NaN71 Inf -> -NaN71 quax684 quantize -NaN6 -NaN5 -> -NaN6 quax685 quantize -Inf -NaN4 -> -NaN4 quax686 quantize -919 -NaN31 -> -NaN31 quax687 quantize Inf -NaN2 -> -NaN2 quax691 quantize -sNaN99 -Inf -> -NaN99 Invalid_operation quax692 quantize -sNaN98 -11 -> -NaN98 Invalid_operation quax693 quantize -sNaN97 NaN -> -NaN97 Invalid_operation quax694 quantize -sNaN16 sNaN94 -> -NaN16 Invalid_operation quax695 quantize -NaN95 -sNaN93 -> -NaN93 Invalid_operation quax696 quantize -Inf -sNaN92 -> -NaN92 Invalid_operation quax697 quantize 088 -sNaN91 -> -NaN91 Invalid_operation quax698 quantize Inf -sNaN90 -> -NaN90 Invalid_operation quax699 quantize NaN -sNaN88 -> -NaN88 Invalid_operation -- subnormals and underflow precision: 4 maxexponent: 999 minexponent: -999 quax710 quantize 1.00E-999 1e-999 -> 1E-999 Rounded quax711 quantize 0.1E-999 2e-1000 -> 1E-1000 Subnormal quax712 quantize 0.10E-999 3e-1000 -> 1E-1000 Subnormal Rounded quax713 quantize 0.100E-999 4e-1000 -> 1E-1000 Subnormal Rounded quax714 quantize 0.01E-999 5e-1001 -> 1E-1001 Subnormal -- next is rounded to Emin quax715 quantize 0.999E-999 1e-999 -> 1E-999 Inexact Rounded quax716 quantize 0.099E-999 10e-1000 -> 1E-1000 Inexact Rounded Subnormal quax717 quantize 0.009E-999 1e-1001 -> 1E-1001 Inexact Rounded Subnormal quax718 quantize 0.001E-999 1e-1001 -> 0E-1001 Inexact Rounded quax719 quantize 0.0009E-999 1e-1001 -> 0E-1001 Inexact Rounded quax720 quantize 0.0001E-999 1e-1001 -> 0E-1001 Inexact Rounded quax730 quantize -1.00E-999 1e-999 -> -1E-999 Rounded quax731 quantize -0.1E-999 1e-999 -> -0E-999 Rounded Inexact quax732 quantize -0.10E-999 1e-999 -> -0E-999 Rounded Inexact quax733 quantize -0.100E-999 1e-999 -> -0E-999 Rounded Inexact quax734 quantize -0.01E-999 1e-999 -> -0E-999 Inexact Rounded -- next is rounded to Emin quax735 quantize -0.999E-999 90e-999 -> -1E-999 Inexact Rounded quax736 quantize -0.099E-999 -1e-999 -> -0E-999 Inexact Rounded quax737 quantize -0.009E-999 -1e-999 -> -0E-999 Inexact Rounded quax738 quantize -0.001E-999 -0e-999 -> -0E-999 Inexact Rounded quax739 quantize -0.0001E-999 0e-999 -> -0E-999 Inexact Rounded quax740 quantize -1.00E-999 1e-1000 -> -1.0E-999 Rounded quax741 quantize -0.1E-999 1e-1000 -> -1E-1000 Subnormal quax742 quantize -0.10E-999 1e-1000 -> -1E-1000 Subnormal Rounded quax743 quantize -0.100E-999 1e-1000 -> -1E-1000 Subnormal Rounded quax744 quantize -0.01E-999 1e-1000 -> -0E-1000 Inexact Rounded -- next is rounded to Emin quax745 quantize -0.999E-999 1e-1000 -> -1.0E-999 Inexact Rounded quax746 quantize -0.099E-999 1e-1000 -> -1E-1000 Inexact Rounded Subnormal quax747 quantize -0.009E-999 1e-1000 -> -0E-1000 Inexact Rounded quax748 quantize -0.001E-999 1e-1000 -> -0E-1000 Inexact Rounded quax749 quantize -0.0001E-999 1e-1000 -> -0E-1000 Inexact Rounded quax750 quantize -1.00E-999 1e-1001 -> -1.00E-999 quax751 quantize -0.1E-999 1e-1001 -> -1.0E-1000 Subnormal quax752 quantize -0.10E-999 1e-1001 -> -1.0E-1000 Subnormal quax753 quantize -0.100E-999 1e-1001 -> -1.0E-1000 Subnormal Rounded quax754 quantize -0.01E-999 1e-1001 -> -1E-1001 Subnormal -- next is rounded to Emin quax755 quantize -0.999E-999 1e-1001 -> -1.00E-999 Inexact Rounded quax756 quantize -0.099E-999 1e-1001 -> -1.0E-1000 Inexact Rounded Subnormal quax757 quantize -0.009E-999 1e-1001 -> -1E-1001 Inexact Rounded Subnormal quax758 quantize -0.001E-999 1e-1001 -> -0E-1001 Inexact Rounded quax759 quantize -0.0001E-999 1e-1001 -> -0E-1001 Inexact Rounded quax760 quantize -1.00E-999 1e-1002 -> -1.000E-999 quax761 quantize -0.1E-999 1e-1002 -> -1.00E-1000 Subnormal quax762 quantize -0.10E-999 1e-1002 -> -1.00E-1000 Subnormal quax763 quantize -0.100E-999 1e-1002 -> -1.00E-1000 Subnormal quax764 quantize -0.01E-999 1e-1002 -> -1.0E-1001 Subnormal quax765 quantize -0.999E-999 1e-1002 -> -9.99E-1000 Subnormal quax766 quantize -0.099E-999 1e-1002 -> -9.9E-1001 Subnormal quax767 quantize -0.009E-999 1e-1002 -> -9E-1002 Subnormal quax768 quantize -0.001E-999 1e-1002 -> -1E-1002 Subnormal quax769 quantize -0.0001E-999 1e-1002 -> -0E-1002 Inexact Rounded -- rhs must be no less than Etiny quax770 quantize -1.00E-999 1e-1003 -> NaN Invalid_operation quax771 quantize -0.1E-999 1e-1003 -> NaN Invalid_operation quax772 quantize -0.10E-999 1e-1003 -> NaN Invalid_operation quax773 quantize -0.100E-999 1e-1003 -> NaN Invalid_operation quax774 quantize -0.01E-999 1e-1003 -> NaN Invalid_operation quax775 quantize -0.999E-999 1e-1003 -> NaN Invalid_operation quax776 quantize -0.099E-999 1e-1003 -> NaN Invalid_operation quax777 quantize -0.009E-999 1e-1003 -> NaN Invalid_operation quax778 quantize -0.001E-999 1e-1003 -> NaN Invalid_operation quax779 quantize -0.0001E-999 1e-1003 -> NaN Invalid_operation quax780 quantize -0.0001E-999 1e-1004 -> NaN Invalid_operation precision: 9 maxExponent: 999999999 minexponent: -999999999 -- some extremes derived from Rescale testcases quax801 quantize 0 1e1000000000 -> NaN Invalid_operation quax802 quantize 0 1e-1000000000 -> 0E-1000000000 quax803 quantize 0 1e2000000000 -> NaN Invalid_operation quax804 quantize 0 1e-2000000000 -> NaN Invalid_operation quax805 quantize 0 1e3000000000 -> NaN Invalid_operation quax806 quantize 0 1e-3000000000 -> NaN Invalid_operation quax807 quantize 0 1e4000000000 -> NaN Invalid_operation quax808 quantize 0 1e-4000000000 -> NaN Invalid_operation quax809 quantize 0 1e5000000000 -> NaN Invalid_operation quax810 quantize 0 1e-5000000000 -> NaN Invalid_operation quax811 quantize 0 1e6000000000 -> NaN Invalid_operation quax812 quantize 0 1e-6000000000 -> NaN Invalid_operation quax813 quantize 0 1e7000000000 -> NaN Invalid_operation quax814 quantize 0 1e-7000000000 -> NaN Invalid_operation quax815 quantize 0 1e8000000000 -> NaN Invalid_operation quax816 quantize 0 1e-8000000000 -> NaN Invalid_operation quax817 quantize 0 1e9000000000 -> NaN Invalid_operation quax818 quantize 0 1e-9000000000 -> NaN Invalid_operation quax819 quantize 0 1e9999999999 -> NaN Invalid_operation quax820 quantize 0 1e-9999999999 -> NaN Invalid_operation quax821 quantize 0 1e10000000000 -> NaN Invalid_operation quax822 quantize 0 1e-10000000000 -> NaN Invalid_operation quax843 quantize 0 1e999999999 -> 0E+999999999 quax844 quantize 0 1e1000000000 -> NaN Invalid_operation quax845 quantize 0 1e-999999999 -> 0E-999999999 quax846 quantize 0 1e-1000000000 -> 0E-1000000000 quax847 quantize 0 1e-1000000001 -> 0E-1000000001 quax848 quantize 0 1e-1000000002 -> 0E-1000000002 quax849 quantize 0 1e-1000000003 -> 0E-1000000003 quax850 quantize 0 1e-1000000004 -> 0E-1000000004 quax851 quantize 0 1e-1000000005 -> 0E-1000000005 quax852 quantize 0 1e-1000000006 -> 0E-1000000006 quax853 quantize 0 1e-1000000007 -> 0E-1000000007 quax854 quantize 0 1e-1000000008 -> NaN Invalid_operation quax861 quantize 1 1e+2147483649 -> NaN Invalid_operation quax862 quantize 1 1e+2147483648 -> NaN Invalid_operation quax863 quantize 1 1e+2147483647 -> NaN Invalid_operation quax864 quantize 1 1e-2147483647 -> NaN Invalid_operation quax865 quantize 1 1e-2147483648 -> NaN Invalid_operation quax866 quantize 1 1e-2147483649 -> NaN Invalid_operation -- Null tests quax900 quantize 10 # -> NaN Invalid_operation quax901 quantize # 1e10 -> NaN Invalid_operation --- NEW FILE: randomBound32.decTest --- ------------------------------------------------------------------------ -- randomBound32.decTest -- decimal testcases -- boundaries near 32 -- -- Copyright (c) IBM Corporation, 1981, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ [...2404 lines suppressed...] mulx3498 multiply 91936087917435.5974889495278215874 -67080823344.8903392584327136082486E-757 -> -6.16714847260980448099292763939423E-733 Inexact Rounded powx3498 power 91936087917435.5974889495278215874 -7 -> 1.80134899939035708719659065082630E-98 Inexact Rounded remx3498 remainder 91936087917435.5974889495278215874 -67080823344.8903392584327136082486E-757 -> NaN Division_impossible subx3498 subtract 91936087917435.5974889495278215874 -67080823344.8903392584327136082486E-757 -> 91936087917435.5974889495278215874 Inexact Rounded addx3499 add -07345.6422518528556136521417259811E-600 41188325.7041362608934957584583381E-763 -> -7.34564225185285561365214172598110E-597 Inexact Rounded comx3499 compare -07345.6422518528556136521417259811E-600 41188325.7041362608934957584583381E-763 -> -1 divx3499 divide -07345.6422518528556136521417259811E-600 41188325.7041362608934957584583381E-763 -> -1.78342822299163842247184303878022E+159 Inexact Rounded dvix3499 divideint -07345.6422518528556136521417259811E-600 41188325.7041362608934957584583381E-763 -> NaN Division_impossible mulx3499 multiply -07345.6422518528556136521417259811E-600 41188325.7041362608934957584583381E-763 -> -3.02554705575380338274126867655676E-1352 Inexact Rounded powx3499 power -07345.6422518528556136521417259811E-600 4 -> 2.91151541552217582082937236255996E-2385 Inexact Rounded remx3499 remainder -07345.6422518528556136521417259811E-600 41188325.7041362608934957584583381E-763 -> NaN Division_impossible subx3499 subtract -07345.6422518528556136521417259811E-600 41188325.7041362608934957584583381E-763 -> -7.34564225185285561365214172598110E-597 Inexact Rounded addx3500 add -253280724.939458021588167965038184 616988.426425908872398170896375634E+396 -> 6.16988426425908872398170896375634E+401 Inexact Rounded comx3500 compare -253280724.939458021588167965038184 616988.426425908872398170896375634E+396 -> -1 divx3500 divide -253280724.939458021588167965038184 616988.426425908872398170896375634E+396 -> -4.10511306357337753351655511866170E-394 Inexact Rounded dvix3500 divideint -253280724.939458021588167965038184 616988.426425908872398170896375634E+396 -> -0 mulx3500 multiply -253280724.939458021588167965038184 616988.426425908872398170896375634E+396 -> -1.56271275924409657991913620522315E+410 Inexact Rounded powx3500 power -253280724.939458021588167965038184 6 -> 2.64005420221406808782284459794424E+50 Inexact Rounded remx3500 remainder -253280724.939458021588167965038184 616988.426425908872398170896375634E+396 -> -253280724.939458021588167965038184 subx3500 subtract -253280724.939458021588167965038184 616988.426425908872398170896375634E+396 -> -6.16988426425908872398170896375634E+401 Inexact Rounded --- NEW FILE: randoms.decTest --- ------------------------------------------------------------------------ -- randoms.decTest -- decimal random testcases -- -- Copyright (c) IBM Corporation, 1981, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ [...3990 lines suppressed...] xmul498 multiply -7.27403536 -481469656E-835183700 -> 3.50222730E-835183691 Inexact Rounded xpow498 power -7.27403536 -5 -> -0.0000491046885 Inexact Rounded xrem498 remainder -7.27403536 -481469656E-835183700 -> NaN Division_impossible xsub498 subtract -7.27403536 -481469656E-835183700 -> -7.27403536 Inexact Rounded xadd499 add -6157.74292 -94075286.2E+92555877 -> -9.40752862E+92555884 Inexact Rounded xcom499 compare -6157.74292 -94075286.2E+92555877 -> 1 xdiv499 divide -6157.74292 -94075286.2E+92555877 -> 6.54554790E-92555882 Inexact Rounded xdvi499 divideint -6157.74292 -94075286.2E+92555877 -> 0 xmul499 multiply -6157.74292 -94075286.2E+92555877 -> 5.79291428E+92555888 Inexact Rounded xpow499 power -6157.74292 -9 -> -7.85608218E-35 Inexact Rounded xrem499 remainder -6157.74292 -94075286.2E+92555877 -> -6157.74292 xsub499 subtract -6157.74292 -94075286.2E+92555877 -> 9.40752862E+92555884 Inexact Rounded xadd500 add -525445087.E+231529167 188227460 -> -5.25445087E+231529175 Inexact Rounded xcom500 compare -525445087.E+231529167 188227460 -> -1 xdiv500 divide -525445087.E+231529167 188227460 -> -2.79154321E+231529167 Inexact Rounded xdvi500 divideint -525445087.E+231529167 188227460 -> NaN Division_impossible xmul500 multiply -525445087.E+231529167 188227460 -> -9.89031941E+231529183 Inexact Rounded xpow500 power -525445087.E+231529167 188227460 -> Infinity Overflow Inexact Rounded xrem500 remainder -525445087.E+231529167 188227460 -> NaN Division_impossible xsub500 subtract -525445087.E+231529167 188227460 -> -5.25445087E+231529175 Inexact Rounded --- NEW FILE: remainder.decTest --- ------------------------------------------------------------------------ -- remainder.decTest -- decimal remainder -- -- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 extended: 1 precision: 9 rounding: half_up maxExponent: 384 minexponent: -383 -- sanity checks (as base, above) remx001 remainder 1 1 -> 0 remx002 remainder 2 1 -> 0 remx003 remainder 1 2 -> 1 remx004 remainder 2 2 -> 0 remx005 remainder 0 1 -> 0 remx006 remainder 0 2 -> 0 remx007 remainder 1 3 -> 1 remx008 remainder 2 3 -> 2 remx009 remainder 3 3 -> 0 remx010 remainder 2.4 1 -> 0.4 remx011 remainder 2.4 -1 -> 0.4 remx012 remainder -2.4 1 -> -0.4 remx013 remainder -2.4 -1 -> -0.4 remx014 remainder 2.40 1 -> 0.40 remx015 remainder 2.400 1 -> 0.400 remx016 remainder 2.4 2 -> 0.4 remx017 remainder 2.400 2 -> 0.400 remx018 remainder 2. 2 -> 0 remx019 remainder 20 20 -> 0 remx020 remainder 187 187 -> 0 remx021 remainder 5 2 -> 1 remx022 remainder 5 2.0 -> 1.0 remx023 remainder 5 2.000 -> 1.000 remx024 remainder 5 0.200 -> 0.000 remx025 remainder 5 0.200 -> 0.000 remx030 remainder 1 2 -> 1 remx031 remainder 1 4 -> 1 remx032 remainder 1 8 -> 1 remx033 remainder 1 16 -> 1 remx034 remainder 1 32 -> 1 remx035 remainder 1 64 -> 1 remx040 remainder 1 -2 -> 1 remx041 remainder 1 -4 -> 1 remx042 remainder 1 -8 -> 1 remx043 remainder 1 -16 -> 1 remx044 remainder 1 -32 -> 1 remx045 remainder 1 -64 -> 1 remx050 remainder -1 2 -> -1 remx051 remainder -1 4 -> -1 remx052 remainder -1 8 -> -1 remx053 remainder -1 16 -> -1 remx054 remainder -1 32 -> -1 remx055 remainder -1 64 -> -1 remx060 remainder -1 -2 -> -1 remx061 remainder -1 -4 -> -1 remx062 remainder -1 -8 -> -1 remx063 remainder -1 -16 -> -1 remx064 remainder -1 -32 -> -1 remx065 remainder -1 -64 -> -1 remx066 remainder 999999999 1 -> 0 remx067 remainder 999999999.4 1 -> 0.4 remx068 remainder 999999999.5 1 -> 0.5 remx069 remainder 999999999.9 1 -> 0.9 remx070 remainder 999999999.999 1 -> 0.999 precision: 6 remx071 remainder 999999999 1 -> NaN Division_impossible remx072 remainder 99999999 1 -> NaN Division_impossible remx073 remainder 9999999 1 -> NaN Division_impossible remx074 remainder 999999 1 -> 0 remx075 remainder 99999 1 -> 0 remx076 remainder 9999 1 -> 0 remx077 remainder 999 1 -> 0 remx078 remainder 99 1 -> 0 remx079 remainder 9 1 -> 0 precision: 9 remx080 remainder 0. 1 -> 0 remx081 remainder .0 1 -> 0.0 remx082 remainder 0.00 1 -> 0.00 remx083 remainder 0.00E+9 1 -> 0 remx084 remainder 0.00E+3 1 -> 0 remx085 remainder 0.00E+2 1 -> 0 remx086 remainder 0.00E+1 1 -> 0.0 remx087 remainder 0.00E+0 1 -> 0.00 remx088 remainder 0.00E-0 1 -> 0.00 remx089 remainder 0.00E-1 1 -> 0.000 remx090 remainder 0.00E-2 1 -> 0.0000 remx091 remainder 0.00E-3 1 -> 0.00000 remx092 remainder 0.00E-4 1 -> 0.000000 remx093 remainder 0.00E-5 1 -> 0E-7 remx094 remainder 0.00E-6 1 -> 0E-8 remx095 remainder 0.0000E-50 1 -> 0E-54 -- Various flavours of remainder by 0 precision: 9 maxexponent: 999999999 minexponent: -999999999 remx101 remainder 0 0 -> NaN Division_undefined remx102 remainder 0 -0 -> NaN Division_undefined remx103 remainder -0 0 -> NaN Division_undefined remx104 remainder -0 -0 -> NaN Division_undefined remx105 remainder 0.0E5 0 -> NaN Division_undefined remx106 remainder 0.000 0 -> NaN Division_undefined -- [Some think this next group should be Division_by_zero exception, but -- IEEE 854 is explicit that it is Invalid operation .. for -- remainder-near, anyway] remx107 remainder 0.0001 0 -> NaN Invalid_operation remx108 remainder 0.01 0 -> NaN Invalid_operation remx109 remainder 0.1 0 -> NaN Invalid_operation remx110 remainder 1 0 -> NaN Invalid_operation remx111 remainder 1 0.0 -> NaN Invalid_operation remx112 remainder 10 0.0 -> NaN Invalid_operation remx113 remainder 1E+100 0.0 -> NaN Invalid_operation remx114 remainder 1E+1000 0 -> NaN Invalid_operation remx115 remainder 0.0001 -0 -> NaN Invalid_operation remx116 remainder 0.01 -0 -> NaN Invalid_operation remx119 remainder 0.1 -0 -> NaN Invalid_operation remx120 remainder 1 -0 -> NaN Invalid_operation remx121 remainder 1 -0.0 -> NaN Invalid_operation remx122 remainder 10 -0.0 -> NaN Invalid_operation remx123 remainder 1E+100 -0.0 -> NaN Invalid_operation remx124 remainder 1E+1000 -0 -> NaN Invalid_operation -- and zeros on left remx130 remainder 0 1 -> 0 remx131 remainder 0 -1 -> 0 remx132 remainder 0.0 1 -> 0.0 remx133 remainder 0.0 -1 -> 0.0 remx134 remainder -0 1 -> -0 remx135 remainder -0 -1 -> -0 remx136 remainder -0.0 1 -> -0.0 remx137 remainder -0.0 -1 -> -0.0 -- 0.5ers remx143 remainder 0.5 2 -> 0.5 remx144 remainder 0.5 2.1 -> 0.5 remx145 remainder 0.5 2.01 -> 0.50 remx146 remainder 0.5 2.001 -> 0.500 remx147 remainder 0.50 2 -> 0.50 remx148 remainder 0.50 2.01 -> 0.50 remx149 remainder 0.50 2.001 -> 0.500 -- steadies remx150 remainder 1 1 -> 0 remx151 remainder 1 2 -> 1 remx152 remainder 1 3 -> 1 remx153 remainder 1 4 -> 1 remx154 remainder 1 5 -> 1 remx155 remainder 1 6 -> 1 remx156 remainder 1 7 -> 1 remx157 remainder 1 8 -> 1 remx158 remainder 1 9 -> 1 remx159 remainder 1 10 -> 1 remx160 remainder 1 1 -> 0 remx161 remainder 2 1 -> 0 remx162 remainder 3 1 -> 0 remx163 remainder 4 1 -> 0 remx164 remainder 5 1 -> 0 remx165 remainder 6 1 -> 0 remx166 remainder 7 1 -> 0 remx167 remainder 8 1 -> 0 remx168 remainder 9 1 -> 0 remx169 remainder 10 1 -> 0 -- some differences from remainderNear remx171 remainder 0.4 1.020 -> 0.400 remx172 remainder 0.50 1.020 -> 0.500 remx173 remainder 0.51 1.020 -> 0.510 remx174 remainder 0.52 1.020 -> 0.520 remx175 remainder 0.6 1.020 -> 0.600 -- More flavours of remainder by 0 maxexponent: 999999999 minexponent: -999999999 remx201 remainder 0 0 -> NaN Division_undefined remx202 remainder 0.0E5 0 -> NaN Division_undefined remx203 remainder 0.000 0 -> NaN Division_undefined remx204 remainder 0.0001 0 -> NaN Invalid_operation remx205 remainder 0.01 0 -> NaN Invalid_operation remx206 remainder 0.1 0 -> NaN Invalid_operation remx207 remainder 1 0 -> NaN Invalid_operation remx208 remainder 1 0.0 -> NaN Invalid_operation remx209 remainder 10 0.0 -> NaN Invalid_operation remx210 remainder 1E+100 0.0 -> NaN Invalid_operation remx211 remainder 1E+1000 0 -> NaN Invalid_operation -- some differences from remainderNear remx231 remainder -0.4 1.020 -> -0.400 remx232 remainder -0.50 1.020 -> -0.500 remx233 remainder -0.51 1.020 -> -0.510 remx234 remainder -0.52 1.020 -> -0.520 remx235 remainder -0.6 1.020 -> -0.600 -- high Xs remx240 remainder 1E+2 1.00 -> 0.00 -- test some cases that are close to exponent overflow maxexponent: 999999999 minexponent: -999999999 remx270 remainder 1 1e999999999 -> 1 remx271 remainder 1 0.9e999999999 -> 1 remx272 remainder 1 0.99e999999999 -> 1 remx273 remainder 1 0.999999999e999999999 -> 1 remx274 remainder 9e999999999 1 -> NaN Division_impossible remx275 remainder 9.9e999999999 1 -> NaN Division_impossible remx276 remainder 9.99e999999999 1 -> NaN Division_impossible remx277 remainder 9.99999999e999999999 1 -> NaN Division_impossible remx280 remainder 0.1 9e-999999999 -> NaN Division_impossible remx281 remainder 0.1 99e-999999999 -> NaN Division_impossible remx282 remainder 0.1 999e-999999999 -> NaN Division_impossible remx283 remainder 0.1 9e-999999998 -> NaN Division_impossible remx284 remainder 0.1 99e-999999998 -> NaN Division_impossible remx285 remainder 0.1 999e-999999998 -> NaN Division_impossible remx286 remainder 0.1 999e-999999997 -> NaN Division_impossible remx287 remainder 0.1 9999e-999999997 -> NaN Division_impossible remx288 remainder 0.1 99999e-999999997 -> NaN Division_impossible -- remx3xx are from DiagBigDecimal remx301 remainder 1 3 -> 1 remx302 remainder 5 5 -> 0 remx303 remainder 13 10 -> 3 remx304 remainder 13 50 -> 13 remx305 remainder 13 100 -> 13 remx306 remainder 13 1000 -> 13 remx307 remainder .13 1 -> 0.13 remx308 remainder 0.133 1 -> 0.133 remx309 remainder 0.1033 1 -> 0.1033 remx310 remainder 1.033 1 -> 0.033 remx311 remainder 10.33 1 -> 0.33 remx312 remainder 10.33 10 -> 0.33 remx313 remainder 103.3 1 -> 0.3 remx314 remainder 133 10 -> 3 remx315 remainder 1033 10 -> 3 remx316 remainder 1033 50 -> 33 remx317 remainder 101.0 3 -> 2.0 remx318 remainder 102.0 3 -> 0.0 remx319 remainder 103.0 3 -> 1.0 remx320 remainder 2.40 1 -> 0.40 remx321 remainder 2.400 1 -> 0.400 remx322 remainder 2.4 1 -> 0.4 remx323 remainder 2.4 2 -> 0.4 remx324 remainder 2.400 2 -> 0.400 remx325 remainder 1 0.3 -> 0.1 remx326 remainder 1 0.30 -> 0.10 remx327 remainder 1 0.300 -> 0.100 remx328 remainder 1 0.3000 -> 0.1000 remx329 remainder 1.0 0.3 -> 0.1 remx330 remainder 1.00 0.3 -> 0.10 remx331 remainder 1.000 0.3 -> 0.100 remx332 remainder 1.0000 0.3 -> 0.1000 remx333 remainder 0.5 2 -> 0.5 remx334 remainder 0.5 2.1 -> 0.5 remx335 remainder 0.5 2.01 -> 0.50 remx336 remainder 0.5 2.001 -> 0.500 remx337 remainder 0.50 2 -> 0.50 remx338 remainder 0.50 2.01 -> 0.50 remx339 remainder 0.50 2.001 -> 0.500 remx340 remainder 0.5 0.5000001 -> 0.5000000 remx341 remainder 0.5 0.50000001 -> 0.50000000 remx342 remainder 0.5 0.500000001 -> 0.500000000 remx343 remainder 0.5 0.5000000001 -> 0.500000000 Rounded remx344 remainder 0.5 0.50000000001 -> 0.500000000 Rounded remx345 remainder 0.5 0.4999999 -> 1E-7 remx346 remainder 0.5 0.49999999 -> 1E-8 remx347 remainder 0.5 0.499999999 -> 1E-9 remx348 remainder 0.5 0.4999999999 -> 1E-10 remx349 remainder 0.5 0.49999999999 -> 1E-11 remx350 remainder 0.5 0.499999999999 -> 1E-12 remx351 remainder 0.03 7 -> 0.03 remx352 remainder 5 2 -> 1 remx353 remainder 4.1 2 -> 0.1 remx354 remainder 4.01 2 -> 0.01 remx355 remainder 4.001 2 -> 0.001 remx356 remainder 4.0001 2 -> 0.0001 remx357 remainder 4.00001 2 -> 0.00001 remx358 remainder 4.000001 2 -> 0.000001 remx359 remainder 4.0000001 2 -> 1E-7 remx360 remainder 1.2 0.7345 -> 0.4655 remx361 remainder 0.8 12 -> 0.8 remx362 remainder 0.8 0.2 -> 0.0 remx363 remainder 0.8 0.3 -> 0.2 remx364 remainder 0.800 12 -> 0.800 remx365 remainder 0.800 1.7 -> 0.800 remx366 remainder 2.400 2 -> 0.400 precision: 6 remx371 remainder 2.400 2 -> 0.400 precision: 3 -- long operand, rounded, case remx372 remainder 12345678900000 12e+12 -> 3.46E+11 Inexact Rounded -- 12000000000000 precision: 5 remx381 remainder 12345 1 -> 0 remx382 remainder 12345 1.0001 -> 0.7657 remx383 remainder 12345 1.001 -> 0.668 remx384 remainder 12345 1.01 -> 0.78 remx385 remainder 12345 1.1 -> 0.8 remx386 remainder 12355 4 -> 3 remx387 remainder 12345 4 -> 1 remx388 remainder 12355 4.0001 -> 2.6912 remx389 remainder 12345 4.0001 -> 0.6914 remx390 remainder 12345 4.9 -> 1.9 remx391 remainder 12345 4.99 -> 4.73 remx392 remainder 12345 4.999 -> 2.469 remx393 remainder 12345 4.9999 -> 0.2469 remx394 remainder 12345 5 -> 0 remx395 remainder 12345 5.0001 -> 4.7532 remx396 remainder 12345 5.001 -> 2.532 remx397 remainder 12345 5.01 -> 0.36 remx398 remainder 12345 5.1 -> 3.0 precision: 9 -- the nasty division-by-1 cases remx401 remainder 0.5 1 -> 0.5 remx402 remainder 0.55 1 -> 0.55 remx403 remainder 0.555 1 -> 0.555 remx404 remainder 0.5555 1 -> 0.5555 remx405 remainder 0.55555 1 -> 0.55555 remx406 remainder 0.555555 1 -> 0.555555 remx407 remainder 0.5555555 1 -> 0.5555555 remx408 remainder 0.55555555 1 -> 0.55555555 remx409 remainder 0.555555555 1 -> 0.555555555 -- Specials remx680 remainder Inf -Inf -> NaN Invalid_operation remx681 remainder Inf -1000 -> NaN Invalid_operation remx682 remainder Inf -1 -> NaN Invalid_operation remx683 remainder Inf 0 -> NaN Invalid_operation remx684 remainder Inf -0 -> NaN Invalid_operation remx685 remainder Inf 1 -> NaN Invalid_operation remx686 remainder Inf 1000 -> NaN Invalid_operation remx687 remainder Inf Inf -> NaN Invalid_operation remx688 remainder -1000 Inf -> -1000 remx689 remainder -Inf Inf -> NaN Invalid_operation remx691 remainder -1 Inf -> -1 remx692 remainder 0 Inf -> 0 remx693 remainder -0 Inf -> -0 remx694 remainder 1 Inf -> 1 remx695 remainder 1000 Inf -> 1000 remx696 remainder Inf Inf -> NaN Invalid_operation remx700 remainder -Inf -Inf -> NaN Invalid_operation remx701 remainder -Inf -1000 -> NaN Invalid_operation remx702 remainder -Inf -1 -> NaN Invalid_operation remx703 remainder -Inf -0 -> NaN Invalid_operation remx704 remainder -Inf 0 -> NaN Invalid_operation remx705 remainder -Inf 1 -> NaN Invalid_operation remx706 remainder -Inf 1000 -> NaN Invalid_operation remx707 remainder -Inf Inf -> NaN Invalid_operation remx708 remainder -Inf -Inf -> NaN Invalid_operation remx709 remainder -1000 Inf -> -1000 remx710 remainder -1 -Inf -> -1 remx711 remainder -0 -Inf -> -0 remx712 remainder 0 -Inf -> 0 remx713 remainder 1 -Inf -> 1 remx714 remainder 1000 -Inf -> 1000 remx715 remainder Inf -Inf -> NaN Invalid_operation remx721 remainder NaN -Inf -> NaN remx722 remainder NaN -1000 -> NaN remx723 remainder NaN -1 -> NaN remx724 remainder NaN -0 -> NaN remx725 remainder -NaN 0 -> -NaN remx726 remainder NaN 1 -> NaN remx727 remainder NaN 1000 -> NaN remx728 remainder NaN Inf -> NaN remx729 remainder NaN -NaN -> NaN remx730 remainder -Inf NaN -> NaN remx731 remainder -1000 NaN -> NaN remx732 remainder -1 NaN -> NaN remx733 remainder -0 -NaN -> -NaN remx734 remainder 0 NaN -> NaN remx735 remainder 1 -NaN -> -NaN remx736 remainder 1000 NaN -> NaN remx737 remainder Inf NaN -> NaN remx741 remainder sNaN -Inf -> NaN Invalid_operation remx742 remainder sNaN -1000 -> NaN Invalid_operation remx743 remainder -sNaN -1 -> -NaN Invalid_operation remx744 remainder sNaN -0 -> NaN Invalid_operation remx745 remainder sNaN 0 -> NaN Invalid_operation remx746 remainder sNaN 1 -> NaN Invalid_operation remx747 remainder sNaN 1000 -> NaN Invalid_operation remx749 remainder sNaN NaN -> NaN Invalid_operation remx750 remainder sNaN sNaN -> NaN Invalid_operation remx751 remainder NaN sNaN -> NaN Invalid_operation remx752 remainder -Inf sNaN -> NaN Invalid_operation remx753 remainder -1000 sNaN -> NaN Invalid_operation remx754 remainder -1 sNaN -> NaN Invalid_operation remx755 remainder -0 sNaN -> NaN Invalid_operation remx756 remainder 0 sNaN -> NaN Invalid_operation remx757 remainder 1 sNaN -> NaN Invalid_operation remx758 remainder 1000 sNaN -> NaN Invalid_operation remx759 remainder Inf -sNaN -> -NaN Invalid_operation -- propaging NaNs remx760 remainder NaN1 NaN7 -> NaN1 remx761 remainder sNaN2 NaN8 -> NaN2 Invalid_operation remx762 remainder NaN3 sNaN9 -> NaN9 Invalid_operation remx763 remainder sNaN4 sNaN10 -> NaN4 Invalid_operation remx764 remainder 15 NaN11 -> NaN11 remx765 remainder NaN6 NaN12 -> NaN6 remx766 remainder Inf NaN13 -> NaN13 remx767 remainder NaN14 -Inf -> NaN14 remx768 remainder 0 NaN15 -> NaN15 remx769 remainder NaN16 -0 -> NaN16 -- test some cases that are close to exponent overflow maxexponent: 999999999 minexponent: -999999999 remx770 remainder 1 1e999999999 -> 1 remx771 remainder 1 0.9e999999999 -> 1 remx772 remainder 1 0.99e999999999 -> 1 remx773 remainder 1 0.999999999e999999999 -> 1 remx774 remainder 9e999999999 1 -> NaN Division_impossible remx775 remainder 9.9e999999999 1 -> NaN Division_impossible remx776 remainder 9.99e999999999 1 -> NaN Division_impossible remx777 remainder 9.99999999e999999999 1 -> NaN Division_impossible -- long operand checks maxexponent: 999 minexponent: -999 precision: 9 remx801 remainder 12345678000 100 -> 0 remx802 remainder 1 12345678000 -> 1 remx803 remainder 1234567800 10 -> 0 remx804 remainder 1 1234567800 -> 1 remx805 remainder 1234567890 10 -> 0 remx806 remainder 1 1234567890 -> 1 remx807 remainder 1234567891 10 -> 1 remx808 remainder 1 1234567891 -> 1 remx809 remainder 12345678901 100 -> 1 remx810 remainder 1 12345678901 -> 1 remx811 remainder 1234567896 10 -> 6 remx812 remainder 1 1234567896 -> 1 precision: 15 remx821 remainder 12345678000 100 -> 0 remx822 remainder 1 12345678000 -> 1 remx823 remainder 1234567800 10 -> 0 remx824 remainder 1 1234567800 -> 1 remx825 remainder 1234567890 10 -> 0 remx826 remainder 1 1234567890 -> 1 remx827 remainder 1234567891 10 -> 1 remx828 remainder 1 1234567891 -> 1 remx829 remainder 12345678901 100 -> 1 remx830 remainder 1 12345678901 -> 1 remx831 remainder 1234567896 10 -> 6 remx832 remainder 1 1234567896 -> 1 -- worries from divideint precision: 8 remx840 remainder 100000000.0 1 -> NaN Division_impossible remx841 remainder 100000000.4 1 -> NaN Division_impossible remx842 remainder 100000000.5 1 -> NaN Division_impossible remx843 remainder 100000000.9 1 -> NaN Division_impossible remx844 remainder 100000000.999 1 -> NaN Division_impossible precision: 6 remx850 remainder 100000003 5 -> NaN Division_impossible remx851 remainder 10000003 5 -> NaN Division_impossible remx852 remainder 1000003 5 -> 3 remx853 remainder 100003 5 -> 3 remx854 remainder 10003 5 -> 3 remx855 remainder 1003 5 -> 3 remx856 remainder 103 5 -> 3 remx857 remainder 13 5 -> 3 remx858 remainder 1 5 -> 1 -- Vladimir's cases remx860 remainder 123.0e1 10000000000000000 -> 1230 remx861 remainder 1230 10000000000000000 -> 1230 remx862 remainder 12.3e2 10000000000000000 -> 1230 remx863 remainder 1.23e3 10000000000000000 -> 1230 remx864 remainder 123e1 10000000000000000 -> 1230 remx870 remainder 123e1 1000000000000000 -> 1230 remx871 remainder 123e1 100000000000000 -> 1230 remx872 remainder 123e1 10000000000000 -> 1230 remx873 remainder 123e1 1000000000000 -> 1230 remx874 remainder 123e1 100000000000 -> 1230 remx875 remainder 123e1 10000000000 -> 1230 remx876 remainder 123e1 1000000000 -> 1230 remx877 remainder 123e1 100000000 -> 1230 remx878 remainder 1230 100000000 -> 1230 remx879 remainder 123e1 10000000 -> 1230 remx880 remainder 123e1 1000000 -> 1230 remx881 remainder 123e1 100000 -> 1230 remx882 remainder 123e1 10000 -> 1230 remx883 remainder 123e1 1000 -> 230 remx884 remainder 123e1 100 -> 30 remx885 remainder 123e1 10 -> 0 remx886 remainder 123e1 1 -> 0 remx889 remainder 123e1 20000000000000000 -> 1230 remx890 remainder 123e1 2000000000000000 -> 1230 remx891 remainder 123e1 200000000000000 -> 1230 remx892 remainder 123e1 20000000000000 -> 1230 remx893 remainder 123e1 2000000000000 -> 1230 remx894 remainder 123e1 200000000000 -> 1230 remx895 remainder 123e1 20000000000 -> 1230 remx896 remainder 123e1 2000000000 -> 1230 remx897 remainder 123e1 200000000 -> 1230 remx899 remainder 123e1 20000000 -> 1230 remx900 remainder 123e1 2000000 -> 1230 remx901 remainder 123e1 200000 -> 1230 remx902 remainder 123e1 20000 -> 1230 remx903 remainder 123e1 2000 -> 1230 remx904 remainder 123e1 200 -> 30 remx905 remainder 123e1 20 -> 10 remx906 remainder 123e1 2 -> 0 remx909 remainder 123e1 50000000000000000 -> 1230 remx910 remainder 123e1 5000000000000000 -> 1230 remx911 remainder 123e1 500000000000000 -> 1230 remx912 remainder 123e1 50000000000000 -> 1230 remx913 remainder 123e1 5000000000000 -> 1230 remx914 remainder 123e1 500000000000 -> 1230 remx915 remainder 123e1 50000000000 -> 1230 remx916 remainder 123e1 5000000000 -> 1230 remx917 remainder 123e1 500000000 -> 1230 remx919 remainder 123e1 50000000 -> 1230 remx920 remainder 123e1 5000000 -> 1230 remx921 remainder 123e1 500000 -> 1230 remx922 remainder 123e1 50000 -> 1230 remx923 remainder 123e1 5000 -> 1230 remx924 remainder 123e1 500 -> 230 remx925 remainder 123e1 50 -> 30 remx926 remainder 123e1 5 -> 0 remx929 remainder 123e1 90000000000000000 -> 1230 remx930 remainder 123e1 9000000000000000 -> 1230 remx931 remainder 123e1 900000000000000 -> 1230 remx932 remainder 123e1 90000000000000 -> 1230 remx933 remainder 123e1 9000000000000 -> 1230 remx934 remainder 123e1 900000000000 -> 1230 remx935 remainder 123e1 90000000000 -> 1230 remx936 remainder 123e1 9000000000 -> 1230 remx937 remainder 123e1 900000000 -> 1230 remx939 remainder 123e1 90000000 -> 1230 remx940 remainder 123e1 9000000 -> 1230 remx941 remainder 123e1 900000 -> 1230 remx942 remainder 123e1 90000 -> 1230 remx943 remainder 123e1 9000 -> 1230 remx944 remainder 123e1 900 -> 330 remx945 remainder 123e1 90 -> 60 remx946 remainder 123e1 9 -> 6 remx950 remainder 123e1 10000000000000000 -> 1230 remx951 remainder 123e1 100000000000000000 -> 1230 remx952 remainder 123e1 1000000000000000000 -> 1230 remx953 remainder 123e1 10000000000000000000 -> 1230 remx954 remainder 123e1 100000000000000000000 -> 1230 remx955 remainder 123e1 1000000000000000000000 -> 1230 remx956 remainder 123e1 10000000000000000000000 -> 1230 remx957 remainder 123e1 100000000000000000000000 -> 1230 remx958 remainder 123e1 1000000000000000000000000 -> 1230 remx959 remainder 123e1 10000000000000000000000000 -> 1230 remx960 remainder 123e1 19999999999999999 -> 1230 remx961 remainder 123e1 199999999999999990 -> 1230 remx962 remainder 123e1 1999999999999999999 -> 1230 remx963 remainder 123e1 19999999999999999990 -> 1230 remx964 remainder 123e1 199999999999999999999 -> 1230 remx965 remainder 123e1 1999999999999999999990 -> 1230 remx966 remainder 123e1 19999999999999999999999 -> 1230 remx967 remainder 123e1 199999999999999999999990 -> 1230 remx968 remainder 123e1 1999999999999999999999999 -> 1230 remx969 remainder 123e1 19999999999999999999999990 -> 1230 remx970 remainder 1e1 10000000000000000 -> 10 remx971 remainder 1e1 100000000000000000 -> 10 remx972 remainder 1e1 1000000000000000000 -> 10 remx973 remainder 1e1 10000000000000000000 -> 10 remx974 remainder 1e1 100000000000000000000 -> 10 remx975 remainder 1e1 1000000000000000000000 -> 10 remx976 remainder 1e1 10000000000000000000000 -> 10 remx977 remainder 1e1 100000000000000000000000 -> 10 remx978 remainder 1e1 1000000000000000000000000 -> 10 remx979 remainder 1e1 10000000000000000000000000 -> 10 remx980 remainder 123e1 1000E999999 -> 1.23E+3 -- 123E+1 internally -- overflow and underflow tests [from divide] precision: 9 maxexponent: 999999999 minexponent: -999999999 remx990 remainder +1.23456789012345E-0 9E+999999999 -> 1.23456789 Inexact Rounded remx991 remainder 9E+999999999 +0.23456789012345E-0 -> NaN Division_impossible remx992 remainder +0.100 9E+999999999 -> 0.100 remx993 remainder 9E-999999999 +9.100 -> 9E-999999999 remx995 remainder -1.23456789012345E-0 9E+999999999 -> -1.23456789 Inexact Rounded remx996 remainder 9E+999999999 -0.83456789012345E-0 -> NaN Division_impossible remx997 remainder -0.100 9E+999999999 -> -0.100 remx998 remainder 9E-999999999 -9.100 -> 9E-999999999 -- Null tests remx1000 remainder 10 # -> NaN Invalid_operation remx1001 remainder # 10 -> NaN Invalid_operation --- NEW FILE: remainderNear.decTest --- ------------------------------------------------------------------------ -- remainderNear.decTest -- decimal remainder-near (IEEE remainder) -- -- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 extended: 1 precision: 9 rounding: half_up maxExponent: 384 minexponent: -383 rmnx001 remaindernear 1 1 -> 0 rmnx002 remaindernear 2 1 -> 0 rmnx003 remaindernear 1 2 -> 1 rmnx004 remaindernear 2 2 -> 0 rmnx005 remaindernear 0 1 -> 0 rmnx006 remaindernear 0 2 -> 0 rmnx007 remaindernear 1 3 -> 1 rmnx008 remaindernear 2 3 -> -1 rmnx009 remaindernear 3 3 -> 0 rmnx010 remaindernear 2.4 1 -> 0.4 rmnx011 remaindernear 2.4 -1 -> 0.4 rmnx012 remaindernear -2.4 1 -> -0.4 rmnx013 remaindernear -2.4 -1 -> -0.4 rmnx014 remaindernear 2.40 1 -> 0.40 rmnx015 remaindernear 2.400 1 -> 0.400 rmnx016 remaindernear 2.4 2 -> 0.4 rmnx017 remaindernear 2.400 2 -> 0.400 rmnx018 remaindernear 2. 2 -> 0 rmnx019 remaindernear 20 20 -> 0 rmnx020 remaindernear 187 187 -> 0 rmnx021 remaindernear 5 2 -> 1 rmnx022 remaindernear 5 2.0 -> 1.0 rmnx023 remaindernear 5 2.000 -> 1.000 rmnx024 remaindernear 5 0.200 -> 0.000 rmnx025 remaindernear 5 0.200 -> 0.000 rmnx030 remaindernear 1 2 -> 1 rmnx031 remaindernear 1 4 -> 1 rmnx032 remaindernear 1 8 -> 1 rmnx033 remaindernear 1 16 -> 1 rmnx034 remaindernear 1 32 -> 1 rmnx035 remaindernear 1 64 -> 1 rmnx040 remaindernear 1 -2 -> 1 rmnx041 remaindernear 1 -4 -> 1 rmnx042 remaindernear 1 -8 -> 1 rmnx043 remaindernear 1 -16 -> 1 rmnx044 remaindernear 1 -32 -> 1 rmnx045 remaindernear 1 -64 -> 1 rmnx050 remaindernear -1 2 -> -1 rmnx051 remaindernear -1 4 -> -1 rmnx052 remaindernear -1 8 -> -1 rmnx053 remaindernear -1 16 -> -1 rmnx054 remaindernear -1 32 -> -1 rmnx055 remaindernear -1 64 -> -1 rmnx060 remaindernear -1 -2 -> -1 rmnx061 remaindernear -1 -4 -> -1 rmnx062 remaindernear -1 -8 -> -1 rmnx063 remaindernear -1 -16 -> -1 rmnx064 remaindernear -1 -32 -> -1 rmnx065 remaindernear -1 -64 -> -1 rmnx066 remaindernear 999999997 1 -> 0 rmnx067 remaindernear 999999997.4 1 -> 0.4 rmnx068 remaindernear 999999997.5 1 -> -0.5 rmnx069 remaindernear 999999997.9 1 -> -0.1 rmnx070 remaindernear 999999997.999 1 -> -0.001 rmnx071 remaindernear 999999998 1 -> 0 rmnx072 remaindernear 999999998.4 1 -> 0.4 rmnx073 remaindernear 999999998.5 1 -> 0.5 rmnx074 remaindernear 999999998.9 1 -> -0.1 rmnx075 remaindernear 999999998.999 1 -> -0.001 rmnx076 remaindernear 999999999 1 -> 0 rmnx077 remaindernear 999999999.4 1 -> 0.4 rmnx078 remaindernear 999999999.5 1 -> NaN Division_impossible rmnx079 remaindernear 999999999.9 1 -> NaN Division_impossible rmnx080 remaindernear 999999999.999 1 -> NaN Division_impossible precision: 6 rmnx081 remaindernear 999999999 1 -> NaN Division_impossible rmnx082 remaindernear 99999999 1 -> NaN Division_impossible rmnx083 remaindernear 9999999 1 -> NaN Division_impossible rmnx084 remaindernear 999999 1 -> 0 rmnx085 remaindernear 99999 1 -> 0 rmnx086 remaindernear 9999 1 -> 0 rmnx087 remaindernear 999 1 -> 0 rmnx088 remaindernear 99 1 -> 0 rmnx089 remaindernear 9 1 -> 0 precision: 9 rmnx090 remaindernear 0. 1 -> 0 rmnx091 remaindernear .0 1 -> 0.0 rmnx092 remaindernear 0.00 1 -> 0.00 rmnx093 remaindernear 0.00E+9 1 -> 0 rmnx094 remaindernear 0.0000E-50 1 -> 0E-54 -- Various flavours of remaindernear by 0 precision: 9 maxexponent: 999999999 minexponent: -999999999 rmnx101 remaindernear 0 0 -> NaN Division_undefined rmnx102 remaindernear 0 -0 -> NaN Division_undefined rmnx103 remaindernear -0 0 -> NaN Division_undefined rmnx104 remaindernear -0 -0 -> NaN Division_undefined rmnx105 remaindernear 0.0E5 0 -> NaN Division_undefined rmnx106 remaindernear 0.000 0 -> NaN Division_undefined -- [Some think this next group should be Division_by_zero exception, -- but IEEE 854 is explicit that it is Invalid operation .. for -- remaindernear-near, anyway] rmnx107 remaindernear 0.0001 0 -> NaN Invalid_operation rmnx108 remaindernear 0.01 0 -> NaN Invalid_operation rmnx109 remaindernear 0.1 0 -> NaN Invalid_operation rmnx110 remaindernear 1 0 -> NaN Invalid_operation rmnx111 remaindernear 1 0.0 -> NaN Invalid_operation rmnx112 remaindernear 10 0.0 -> NaN Invalid_operation rmnx113 remaindernear 1E+100 0.0 -> NaN Invalid_operation rmnx114 remaindernear 1E+1000 0 -> NaN Invalid_operation rmnx115 remaindernear 0.0001 -0 -> NaN Invalid_operation rmnx116 remaindernear 0.01 -0 -> NaN Invalid_operation rmnx119 remaindernear 0.1 -0 -> NaN Invalid_operation rmnx120 remaindernear 1 -0 -> NaN Invalid_operation rmnx121 remaindernear 1 -0.0 -> NaN Invalid_operation rmnx122 remaindernear 10 -0.0 -> NaN Invalid_operation rmnx123 remaindernear 1E+100 -0.0 -> NaN Invalid_operation rmnx124 remaindernear 1E+1000 -0 -> NaN Invalid_operation -- and zeros on left rmnx130 remaindernear 0 1 -> 0 rmnx131 remaindernear 0 -1 -> 0 rmnx132 remaindernear 0.0 1 -> 0.0 rmnx133 remaindernear 0.0 -1 -> 0.0 rmnx134 remaindernear -0 1 -> -0 rmnx135 remaindernear -0 -1 -> -0 rmnx136 remaindernear -0.0 1 -> -0.0 rmnx137 remaindernear -0.0 -1 -> -0.0 -- 0.5ers rmmx143 remaindernear 0.5 2 -> 0.5 rmmx144 remaindernear 0.5 2.1 -> 0.5 rmmx145 remaindernear 0.5 2.01 -> 0.50 rmmx146 remaindernear 0.5 2.001 -> 0.500 rmmx147 remaindernear 0.50 2 -> 0.50 rmmx148 remaindernear 0.50 2.01 -> 0.50 rmmx149 remaindernear 0.50 2.001 -> 0.500 -- some differences from remainder rmnx150 remaindernear 0.4 1.020 -> 0.400 rmnx151 remaindernear 0.50 1.020 -> 0.500 rmnx152 remaindernear 0.51 1.020 -> 0.510 rmnx153 remaindernear 0.52 1.020 -> -0.500 rmnx154 remaindernear 0.6 1.020 -> -0.420 rmnx155 remaindernear 0.49 1 -> 0.49 rmnx156 remaindernear 0.50 1 -> 0.50 rmnx157 remaindernear 1.50 1 -> -0.50 rmnx158 remaindernear 2.50 1 -> 0.50 rmnx159 remaindernear 9.50 1 -> -0.50 rmnx160 remaindernear 0.51 1 -> -0.49 -- the nasty division-by-1 cases rmnx161 remaindernear 0.4 1 -> 0.4 rmnx162 remaindernear 0.45 1 -> 0.45 rmnx163 remaindernear 0.455 1 -> 0.455 rmnx164 remaindernear 0.4555 1 -> 0.4555 rmnx165 remaindernear 0.45555 1 -> 0.45555 rmnx166 remaindernear 0.455555 1 -> 0.455555 rmnx167 remaindernear 0.4555555 1 -> 0.4555555 rmnx168 remaindernear 0.45555555 1 -> 0.45555555 rmnx169 remaindernear 0.455555555 1 -> 0.455555555 -- with spill... rmnx171 remaindernear 0.5 1 -> 0.5 rmnx172 remaindernear 0.55 1 -> -0.45 rmnx173 remaindernear 0.555 1 -> -0.445 rmnx174 remaindernear 0.5555 1 -> -0.4445 rmnx175 remaindernear 0.55555 1 -> -0.44445 rmnx176 remaindernear 0.555555 1 -> -0.444445 rmnx177 remaindernear 0.5555555 1 -> -0.4444445 rmnx178 remaindernear 0.55555555 1 -> -0.44444445 rmnx179 remaindernear 0.555555555 1 -> -0.444444445 -- progression rmnx180 remaindernear 1 1 -> 0 rmnx181 remaindernear 1 2 -> 1 rmnx182 remaindernear 1 3 -> 1 rmnx183 remaindernear 1 4 -> 1 rmnx184 remaindernear 1 5 -> 1 rmnx185 remaindernear 1 6 -> 1 rmnx186 remaindernear 1 7 -> 1 rmnx187 remaindernear 1 8 -> 1 rmnx188 remaindernear 1 9 -> 1 rmnx189 remaindernear 1 10 -> 1 rmnx190 remaindernear 1 1 -> 0 rmnx191 remaindernear 2 1 -> 0 rmnx192 remaindernear 3 1 -> 0 rmnx193 remaindernear 4 1 -> 0 rmnx194 remaindernear 5 1 -> 0 rmnx195 remaindernear 6 1 -> 0 rmnx196 remaindernear 7 1 -> 0 rmnx197 remaindernear 8 1 -> 0 rmnx198 remaindernear 9 1 -> 0 rmnx199 remaindernear 10 1 -> 0 -- Various flavours of remaindernear by 0 maxexponent: 999999999 minexponent: -999999999 rmnx201 remaindernear 0 0 -> NaN Division_undefined rmnx202 remaindernear 0.0E5 0 -> NaN Division_undefined rmnx203 remaindernear 0.000 0 -> NaN Division_undefined rmnx204 remaindernear 0.0001 0 -> NaN Invalid_operation rmnx205 remaindernear 0.01 0 -> NaN Invalid_operation rmnx206 remaindernear 0.1 0 -> NaN Invalid_operation rmnx207 remaindernear 1 0 -> NaN Invalid_operation rmnx208 remaindernear 1 0.0 -> NaN Invalid_operation rmnx209 remaindernear 10 0.0 -> NaN Invalid_operation rmnx210 remaindernear 1E+100 0.0 -> NaN Invalid_operation rmnx211 remaindernear 1E+1000 0 -> NaN Invalid_operation -- tests from the extended specification rmnx221 remaindernear 2.1 3 -> -0.9 rmnx222 remaindernear 10 6 -> -2 rmnx223 remaindernear 10 3 -> 1 rmnx224 remaindernear -10 3 -> -1 rmnx225 remaindernear 10.2 1 -> 0.2 rmnx226 remaindernear 10 0.3 -> 0.1 rmnx227 remaindernear 3.6 1.3 -> -0.3 -- some differences from remainder rmnx231 remaindernear 0.4 1.020 -> 0.400 rmnx232 remaindernear 0.50 1.020 -> 0.500 rmnx233 remaindernear 0.51 1.020 -> 0.510 rmnx234 remaindernear 0.52 1.020 -> -0.500 rmnx235 remaindernear 0.6 1.020 -> -0.420 -- test some cases that are close to exponent overflow maxexponent: 999999999 minexponent: -999999999 rmnx270 remaindernear 1 1e999999999 -> 1 rmnx271 remaindernear 1 0.9e999999999 -> 1 rmnx272 remaindernear 1 0.99e999999999 -> 1 rmnx273 remaindernear 1 0.999999999e999999999 -> 1 rmnx274 remaindernear 9e999999999 1 -> NaN Division_impossible rmnx275 remaindernear 9.9e999999999 1 -> NaN Division_impossible rmnx276 remaindernear 9.99e999999999 1 -> NaN Division_impossible rmnx277 remaindernear 9.99999999e999999999 1 -> NaN Division_impossible rmnx280 remaindernear 0.1 9e-999999999 -> NaN Division_impossible rmnx281 remaindernear 0.1 99e-999999999 -> NaN Division_impossible rmnx282 remaindernear 0.1 999e-999999999 -> NaN Division_impossible rmnx283 remaindernear 0.1 9e-999999998 -> NaN Division_impossible rmnx284 remaindernear 0.1 99e-999999998 -> NaN Division_impossible rmnx285 remaindernear 0.1 999e-999999998 -> NaN Division_impossible rmnx286 remaindernear 0.1 999e-999999997 -> NaN Division_impossible rmnx287 remaindernear 0.1 9999e-999999997 -> NaN Division_impossible rmnx288 remaindernear 0.1 99999e-999999997 -> NaN Division_impossible -- rmnx3xx are from DiagBigDecimal rmnx301 remaindernear 1 3 -> 1 rmnx302 remaindernear 5 5 -> 0 rmnx303 remaindernear 13 10 -> 3 rmnx304 remaindernear 13 50 -> 13 rmnx305 remaindernear 13 100 -> 13 rmnx306 remaindernear 13 1000 -> 13 rmnx307 remaindernear .13 1 -> 0.13 rmnx308 remaindernear 0.133 1 -> 0.133 rmnx309 remaindernear 0.1033 1 -> 0.1033 rmnx310 remaindernear 1.033 1 -> 0.033 rmnx311 remaindernear 10.33 1 -> 0.33 rmnx312 remaindernear 10.33 10 -> 0.33 rmnx313 remaindernear 103.3 1 -> 0.3 rmnx314 remaindernear 133 10 -> 3 rmnx315 remaindernear 1033 10 -> 3 rmnx316 remaindernear 1033 50 -> -17 rmnx317 remaindernear 101.0 3 -> -1.0 rmnx318 remaindernear 102.0 3 -> 0.0 rmnx319 remaindernear 103.0 3 -> 1.0 rmnx320 remaindernear 2.40 1 -> 0.40 rmnx321 remaindernear 2.400 1 -> 0.400 rmnx322 remaindernear 2.4 1 -> 0.4 rmnx323 remaindernear 2.4 2 -> 0.4 rmnx324 remaindernear 2.400 2 -> 0.400 rmnx325 remaindernear 1 0.3 -> 0.1 rmnx326 remaindernear 1 0.30 -> 0.10 rmnx327 remaindernear 1 0.300 -> 0.100 rmnx328 remaindernear 1 0.3000 -> 0.1000 rmnx329 remaindernear 1.0 0.3 -> 0.1 rmnx330 remaindernear 1.00 0.3 -> 0.10 rmnx331 remaindernear 1.000 0.3 -> 0.100 rmnx332 remaindernear 1.0000 0.3 -> 0.1000 rmnx333 remaindernear 0.5 2 -> 0.5 rmnx334 remaindernear 0.5 2.1 -> 0.5 rmnx335 remaindernear 0.5 2.01 -> 0.50 rmnx336 remaindernear 0.5 2.001 -> 0.500 rmnx337 remaindernear 0.50 2 -> 0.50 rmnx338 remaindernear 0.50 2.01 -> 0.50 rmnx339 remaindernear 0.50 2.001 -> 0.500 rmnx340 remaindernear 0.5 0.5000001 -> -1E-7 rmnx341 remaindernear 0.5 0.50000001 -> -1E-8 rmnx342 remaindernear 0.5 0.500000001 -> -1E-9 rmnx343 remaindernear 0.5 0.5000000001 -> -1E-10 rmnx344 remaindernear 0.5 0.50000000001 -> -1E-11 rmnx345 remaindernear 0.5 0.4999999 -> 1E-7 rmnx346 remaindernear 0.5 0.49999999 -> 1E-8 rmnx347 remaindernear 0.5 0.499999999 -> 1E-9 rmnx348 remaindernear 0.5 0.4999999999 -> 1E-10 rmnx349 remaindernear 0.5 0.49999999999 -> 1E-11 rmnx350 remaindernear 0.03 7 -> 0.03 rmnx351 remaindernear 5 2 -> 1 rmnx352 remaindernear 4.1 2 -> 0.1 rmnx353 remaindernear 4.01 2 -> 0.01 rmnx354 remaindernear 4.001 2 -> 0.001 rmnx355 remaindernear 4.0001 2 -> 0.0001 rmnx356 remaindernear 4.00001 2 -> 0.00001 rmnx357 remaindernear 4.000001 2 -> 0.000001 rmnx358 remaindernear 4.0000001 2 -> 1E-7 rmnx360 remaindernear 1.2 0.7345 -> -0.2690 rmnx361 remaindernear 0.8 12 -> 0.8 rmnx362 remaindernear 0.8 0.2 -> 0.0 rmnx363 remaindernear 0.8 0.3 -> -0.1 rmnx364 remaindernear 0.800 12 -> 0.800 rmnx365 remaindernear 0.800 1.7 -> 0.800 rmnx366 remaindernear 2.400 2 -> 0.400 precision: 6 rmnx371 remaindernear 2.400 2 -> 0.400 precision: 3 rmnx372 remaindernear 12345678900000 12e+12 -> 3.46E+11 Inexact Rounded precision: 5 rmnx381 remaindernear 12345 1 -> 0 rmnx382 remaindernear 12345 1.0001 -> -0.2344 rmnx383 remaindernear 12345 1.001 -> -0.333 rmnx384 remaindernear 12345 1.01 -> -0.23 rmnx385 remaindernear 12345 1.1 -> -0.3 rmnx386 remaindernear 12355 4 -> -1 rmnx387 remaindernear 12345 4 -> 1 rmnx388 remaindernear 12355 4.0001 -> -1.3089 rmnx389 remaindernear 12345 4.0001 -> 0.6914 rmnx390 remaindernear 12345 4.9 -> 1.9 rmnx391 remaindernear 12345 4.99 -> -0.26 rmnx392 remaindernear 12345 4.999 -> 2.469 rmnx393 remaindernear 12345 4.9999 -> 0.2469 rmnx394 remaindernear 12345 5 -> 0 rmnx395 remaindernear 12345 5.0001 -> -0.2469 rmnx396 remaindernear 12345 5.001 -> -2.469 rmnx397 remaindernear 12345 5.01 -> 0.36 rmnx398 remaindernear 12345 5.1 -> -2.1 precision: 9 -- some nasty division-by-1 cases [some similar above] rmnx401 remaindernear 0.4 1 -> 0.4 rmnx402 remaindernear 0.45 1 -> 0.45 rmnx403 remaindernear 0.455 1 -> 0.455 rmnx404 remaindernear 0.4555 1 -> 0.4555 rmnx405 remaindernear 0.45555 1 -> 0.45555 rmnx406 remaindernear 0.455555 1 -> 0.455555 rmnx407 remaindernear 0.4555555 1 -> 0.4555555 rmnx408 remaindernear 0.45555555 1 -> 0.45555555 rmnx409 remaindernear 0.455555555 1 -> 0.455555555 -- some tricky LHSs rmnx420 remaindernear 99999999.999999999 1E+8 -> -1E-9 rmnx421 remaindernear 999999999.999999999 1E+9 -> -1E-9 precision: 9 rmnx430 remaindernear 0.455555555 1 -> 0.455555555 precision: 8 rmnx431 remaindernear 0.455555555 1 -> 0.45555556 Inexact Rounded precision: 7 rmnx432 remaindernear 0.455555555 1 -> 0.4555556 Inexact Rounded precision: 6 rmnx433 remaindernear 0.455555555 1 -> 0.455556 Inexact Rounded precision: 5 rmnx434 remaindernear 0.455555555 1 -> 0.45556 Inexact Rounded precision: 4 rmnx435 remaindernear 0.455555555 1 -> 0.4556 Inexact Rounded precision: 3 rmnx436 remaindernear 0.455555555 1 -> 0.456 Inexact Rounded precision: 2 rmnx437 remaindernear 0.455555555 1 -> 0.46 Inexact Rounded precision: 1 rmnx438 remaindernear 0.455555555 1 -> 0.5 Inexact Rounded -- early tests; from text descriptions precision: 9 rmnx601 remaindernear 10 6 -> -2 rmnx602 remaindernear -10 6 -> 2 rmnx603 remaindernear 11 3 -> -1 rmnx604 remaindernear 11 5 -> 1 rmnx605 remaindernear 7.7 8 -> -0.3 rmnx606 remaindernear 31.5 3 -> 1.5 -- i=10 rmnx607 remaindernear 34.5 3 -> -1.5 -- i=11 -- Specials rmnx680 remaindernear Inf -Inf -> NaN Invalid_operation rmnx681 remaindernear Inf -1000 -> NaN Invalid_operation rmnx682 remaindernear Inf -1 -> NaN Invalid_operation rmnx683 remaindernear Inf 0 -> NaN Invalid_operation rmnx684 remaindernear Inf -0 -> NaN Invalid_operation rmnx685 remaindernear Inf 1 -> NaN Invalid_operation rmnx686 remaindernear Inf 1000 -> NaN Invalid_operation rmnx687 remaindernear Inf Inf -> NaN Invalid_operation rmnx688 remaindernear -1000 Inf -> -1000 rmnx689 remaindernear -Inf Inf -> NaN Invalid_operation rmnx691 remaindernear -1 Inf -> -1 rmnx692 remaindernear 0 Inf -> 0 rmnx693 remaindernear -0 Inf -> -0 rmnx694 remaindernear 1 Inf -> 1 rmnx695 remaindernear 1000 Inf -> 1000 rmnx696 remaindernear Inf Inf -> NaN Invalid_operation rmnx700 remaindernear -Inf -Inf -> NaN Invalid_operation rmnx701 remaindernear -Inf -1000 -> NaN Invalid_operation rmnx702 remaindernear -Inf -1 -> NaN Invalid_operation rmnx703 remaindernear -Inf -0 -> NaN Invalid_operation rmnx704 remaindernear -Inf 0 -> NaN Invalid_operation rmnx705 remaindernear -Inf 1 -> NaN Invalid_operation rmnx706 remaindernear -Inf 1000 -> NaN Invalid_operation rmnx707 remaindernear -Inf Inf -> NaN Invalid_operation rmnx708 remaindernear -Inf -Inf -> NaN Invalid_operation rmnx709 remaindernear -1000 Inf -> -1000 rmnx710 remaindernear -1 -Inf -> -1 rmnx711 remaindernear -0 -Inf -> -0 rmnx712 remaindernear 0 -Inf -> 0 rmnx713 remaindernear 1 -Inf -> 1 rmnx714 remaindernear 1000 -Inf -> 1000 rmnx715 remaindernear Inf -Inf -> NaN Invalid_operation rmnx721 remaindernear NaN -Inf -> NaN rmnx722 remaindernear NaN -1000 -> NaN rmnx723 remaindernear NaN -1 -> NaN rmnx724 remaindernear NaN -0 -> NaN rmnx725 remaindernear NaN 0 -> NaN rmnx726 remaindernear NaN 1 -> NaN rmnx727 remaindernear NaN 1000 -> NaN rmnx728 remaindernear NaN Inf -> NaN rmnx729 remaindernear NaN NaN -> NaN rmnx730 remaindernear -Inf NaN -> NaN rmnx731 remaindernear -1000 NaN -> NaN rmnx732 remaindernear -1 -NaN -> -NaN rmnx733 remaindernear -0 NaN -> NaN rmnx734 remaindernear 0 NaN -> NaN rmnx735 remaindernear 1 NaN -> NaN rmnx736 remaindernear 1000 NaN -> NaN rmnx737 remaindernear Inf NaN -> NaN rmnx741 remaindernear sNaN -Inf -> NaN Invalid_operation rmnx742 remaindernear sNaN -1000 -> NaN Invalid_operation rmnx743 remaindernear -sNaN -1 -> -NaN Invalid_operation rmnx744 remaindernear sNaN -0 -> NaN Invalid_operation rmnx745 remaindernear sNaN 0 -> NaN Invalid_operation rmnx746 remaindernear sNaN 1 -> NaN Invalid_operation rmnx747 remaindernear sNaN 1000 -> NaN Invalid_operation rmnx749 remaindernear sNaN NaN -> NaN Invalid_operation rmnx750 remaindernear sNaN sNaN -> NaN Invalid_operation rmnx751 remaindernear NaN sNaN -> NaN Invalid_operation rmnx752 remaindernear -Inf sNaN -> NaN Invalid_operation rmnx753 remaindernear -1000 sNaN -> NaN Invalid_operation rmnx754 remaindernear -1 sNaN -> NaN Invalid_operation rmnx755 remaindernear -0 -sNaN -> -NaN Invalid_operation rmnx756 remaindernear 0 sNaN -> NaN Invalid_operation rmnx757 remaindernear 1 sNaN -> NaN Invalid_operation rmnx758 remaindernear 1000 sNaN -> NaN Invalid_operation rmnx759 remaindernear Inf sNaN -> NaN Invalid_operation rmnx760 remaindernear NaN sNaN -> NaN Invalid_operation -- propaging NaNs rmnx761 remaindernear NaN1 NaN7 -> NaN1 rmnx762 remaindernear sNaN2 NaN8 -> NaN2 Invalid_operation rmnx763 remaindernear NaN3 -sNaN9 -> -NaN9 Invalid_operation rmnx764 remaindernear sNaN4 sNaN10 -> NaN4 Invalid_operation rmnx765 remaindernear 15 NaN11 -> NaN11 rmnx766 remaindernear NaN6 NaN12 -> NaN6 rmnx767 remaindernear Inf -NaN13 -> -NaN13 rmnx768 remaindernear NaN14 -Inf -> NaN14 rmnx769 remaindernear 0 NaN15 -> NaN15 rmnx770 remaindernear -NaN16 -0 -> -NaN16 -- test some cases that are close to exponent overflow maxexponent: 999999999 minexponent: -999999999 rmnx780 remaindernear 1 1e999999999 -> 1 rmnx781 remaindernear 1 0.9e999999999 -> 1 rmnx782 remaindernear 1 0.99e999999999 -> 1 rmnx783 remaindernear 1 0.999999999e999999999 -> 1 rmnx784 remaindernear 9e999999999 1 -> NaN Division_impossible rmnx785 remaindernear 9.9e999999999 1 -> NaN Division_impossible rmnx786 remaindernear 9.99e999999999 1 -> NaN Division_impossible rmnx787 remaindernear 9.99999999e999999999 1 -> NaN Division_impossible -- overflow and underflow tests [from divide] precision: 9 maxexponent: 999999999 minexponent: -999999999 rmnx790 remaindernear +1.23456789012345E-0 9E+999999999 -> 1.23456789 Inexact Rounded rmnx791 remaindernear 9E+999999999 +0.23456789012345E-0 -> NaN Division_impossible rmnx792 remaindernear +0.100 9E+999999999 -> 0.100 rmnx793 remaindernear 9E-999999999 +9.100 -> 9E-999999999 rmnx795 remaindernear -1.23456789012345E-0 9E+999999999 -> -1.23456789 Inexact Rounded rmnx796 remaindernear 9E+999999999 -0.83456789012345E-0 -> NaN Division_impossible rmnx797 remaindernear -0.100 9E+999999999 -> -0.100 rmnx798 remaindernear 9E-999999999 -9.100 -> 9E-999999999 -- long operands checks maxexponent: 999 minexponent: -999 precision: 9 rmnx801 remaindernear 12345678000 100 -> 0 rmnx802 remaindernear 1 12345678000 -> 1 rmnx803 remaindernear 1234567800 10 -> 0 rmnx804 remaindernear 1 1234567800 -> 1 rmnx805 remaindernear 1234567890 10 -> 0 rmnx806 remaindernear 1 1234567890 -> 1 rmnx807 remaindernear 1234567891 10 -> 1 rmnx808 remaindernear 1 1234567891 -> 1 rmnx809 remaindernear 12345678901 100 -> 1 rmnx810 remaindernear 1 12345678901 -> 1 rmnx811 remaindernear 1234567896 10 -> -4 rmnx812 remaindernear 1 1234567896 -> 1 precision: 15 rmnx841 remaindernear 12345678000 100 -> 0 rmnx842 remaindernear 1 12345678000 -> 1 rmnx843 remaindernear 1234567800 10 -> 0 rmnx844 remaindernear 1 1234567800 -> 1 rmnx845 remaindernear 1234567890 10 -> 0 rmnx846 remaindernear 1 1234567890 -> 1 rmnx847 remaindernear 1234567891 10 -> 1 rmnx848 remaindernear 1 1234567891 -> 1 rmnx849 remaindernear 12345678901 100 -> 1 rmnx850 remaindernear 1 12345678901 -> 1 rmnx851 remaindernear 1234567896 10 -> -4 rmnx852 remaindernear 1 1234567896 -> 1 -- Null tests rmnx900 remaindernear 10 # -> NaN Invalid_operation rmnx901 remaindernear # 10 -> NaN Invalid_operation --- NEW FILE: rescale.decTest --- ------------------------------------------------------------------------ -- rescale.decTest -- decimal rescale operation -- -- Copyright (c) IBM Corporation, 1981, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.35 -- [obsolete] Quantize.decTest has the improved version extended: 1 precision: 9 rounding: half_up maxExponent: 999 minexponent: -999 -- sanity checks resx001 rescale 0 0 -> 0 resx002 rescale 1 0 -> 1 resx003 rescale 0.1 +2 -> 0E+2 Inexact Rounded resx005 rescale 0.1 +1 -> 0E+1 Inexact Rounded resx006 rescale 0.1 0 -> 0 Inexact Rounded resx007 rescale 0.1 -1 -> 0.1 resx008 rescale 0.1 -2 -> 0.10 resx009 rescale 0.1 -3 -> 0.100 resx010 rescale 0.9 +2 -> 0E+2 Inexact Rounded resx011 rescale 0.9 +1 -> 0E+1 Inexact Rounded resx012 rescale 0.9 +0 -> 1 Inexact Rounded resx013 rescale 0.9 -1 -> 0.9 resx014 rescale 0.9 -2 -> 0.90 resx015 rescale 0.9 -3 -> 0.900 -- negatives resx021 rescale -0 0 -> -0 resx022 rescale -1 0 -> -1 resx023 rescale -0.1 +2 -> -0E+2 Inexact Rounded resx025 rescale -0.1 +1 -> -0E+1 Inexact Rounded resx026 rescale -0.1 0 -> -0 Inexact Rounded resx027 rescale -0.1 -1 -> -0.1 resx028 rescale -0.1 -2 -> -0.10 resx029 rescale -0.1 -3 -> -0.100 resx030 rescale -0.9 +2 -> -0E+2 Inexact Rounded resx031 rescale -0.9 +1 -> -0E+1 Inexact Rounded resx032 rescale -0.9 +0 -> -1 Inexact Rounded resx033 rescale -0.9 -1 -> -0.9 resx034 rescale -0.9 -2 -> -0.90 resx035 rescale -0.9 -3 -> -0.900 resx036 rescale -0.5 +2 -> -0E+2 Inexact Rounded resx037 rescale -0.5 +1 -> -0E+1 Inexact Rounded resx038 rescale -0.5 +0 -> -1 Inexact Rounded resx039 rescale -0.5 -1 -> -0.5 resx040 rescale -0.5 -2 -> -0.50 resx041 rescale -0.5 -3 -> -0.500 resx042 rescale -0.9 +2 -> -0E+2 Inexact Rounded resx043 rescale -0.9 +1 -> -0E+1 Inexact Rounded resx044 rescale -0.9 +0 -> -1 Inexact Rounded resx045 rescale -0.9 -1 -> -0.9 resx046 rescale -0.9 -2 -> -0.90 resx047 rescale -0.9 -3 -> -0.900 -- examples from Specification resx060 rescale 2.17 -3 -> 2.170 resx061 rescale 2.17 -2 -> 2.17 resx062 rescale 2.17 -1 -> 2.2 Inexact Rounded resx063 rescale 2.17 0 -> 2 Inexact Rounded resx064 rescale 2.17 +1 -> 0E+1 Inexact Rounded resx065 rescale 2 Inf -> NaN Invalid_operation resx066 rescale -0.1 0 -> -0 Inexact Rounded resx067 rescale -0 5 -> -0E+5 resx068 rescale +35236450.6 -2 -> NaN Invalid_operation resx069 rescale -35236450.6 -2 -> NaN Invalid_operation resx070 rescale 217 -1 -> 217.0 resx071 rescale 217 0 -> 217 resx072 rescale 217 +1 -> 2.2E+2 Inexact Rounded resx073 rescale 217 +2 -> 2E+2 Inexact Rounded -- general tests .. resx089 rescale 12 +4 -> 0E+4 Inexact Rounded resx090 rescale 12 +3 -> 0E+3 Inexact Rounded resx091 rescale 12 +2 -> 0E+2 Inexact Rounded resx092 rescale 12 +1 -> 1E+1 Inexact Rounded resx093 rescale 1.2345 -2 -> 1.23 Inexact Rounded resx094 rescale 1.2355 -2 -> 1.24 Inexact Rounded resx095 rescale 1.2345 -6 -> 1.234500 resx096 rescale 9.9999 -2 -> 10.00 Inexact Rounded resx097 rescale 0.0001 -2 -> 0.00 Inexact Rounded resx098 rescale 0.001 -2 -> 0.00 Inexact Rounded resx099 rescale 0.009 -2 -> 0.01 Inexact Rounded resx100 rescale 92 +2 -> 1E+2 Inexact Rounded resx101 rescale -1 0 -> -1 resx102 rescale -1 -1 -> -1.0 resx103 rescale -1 -2 -> -1.00 resx104 rescale 0 0 -> 0 resx105 rescale 0 -1 -> 0.0 resx106 rescale 0 -2 -> 0.00 resx107 rescale 0.00 0 -> 0 resx108 rescale 0 +1 -> 0E+1 resx109 rescale 0 +2 -> 0E+2 resx110 rescale +1 0 -> 1 resx111 rescale +1 -1 -> 1.0 resx112 rescale +1 -2 -> 1.00 resx120 rescale 1.04 -3 -> 1.040 resx121 rescale 1.04 -2 -> 1.04 resx122 rescale 1.04 -1 -> 1.0 Inexact Rounded resx123 rescale 1.04 0 -> 1 Inexact Rounded resx124 rescale 1.05 -3 -> 1.050 resx125 rescale 1.05 -2 -> 1.05 resx126 rescale 1.05 -1 -> 1.1 Inexact Rounded resx127 rescale 1.05 0 -> 1 Inexact Rounded resx128 rescale 1.05 -3 -> 1.050 resx129 rescale 1.05 -2 -> 1.05 resx130 rescale 1.05 -1 -> 1.1 Inexact Rounded resx131 rescale 1.05 0 -> 1 Inexact Rounded resx132 rescale 1.06 -3 -> 1.060 resx133 rescale 1.06 -2 -> 1.06 resx134 rescale 1.06 -1 -> 1.1 Inexact Rounded resx135 rescale 1.06 0 -> 1 Inexact Rounded resx140 rescale -10 -2 -> -10.00 resx141 rescale +1 -2 -> 1.00 resx142 rescale +10 -2 -> 10.00 resx143 rescale 1E+10 -2 -> NaN Invalid_operation resx144 rescale 1E-10 -2 -> 0.00 Inexact Rounded resx145 rescale 1E-3 -2 -> 0.00 Inexact Rounded resx146 rescale 1E-2 -2 -> 0.01 resx147 rescale 1E-1 -2 -> 0.10 resx148 rescale 0E-10 -2 -> 0.00 resx150 rescale 1.0600 -5 -> 1.06000 resx151 rescale 1.0600 -4 -> 1.0600 resx152 rescale 1.0600 -3 -> 1.060 Rounded resx153 rescale 1.0600 -2 -> 1.06 Rounded resx154 rescale 1.0600 -1 -> 1.1 Inexact Rounded resx155 rescale 1.0600 0 -> 1 Inexact Rounded -- +ve exponents .. resx201 rescale -1 +0 -> -1 resx202 rescale -1 +1 -> -0E+1 Inexact Rounded resx203 rescale -1 +2 -> -0E+2 Inexact Rounded resx204 rescale 0 +0 -> 0 resx205 rescale 0 +1 -> 0E+1 resx206 rescale 0 +2 -> 0E+2 resx207 rescale +1 +0 -> 1 resx208 rescale +1 +1 -> 0E+1 Inexact Rounded resx209 rescale +1 +2 -> 0E+2 Inexact Rounded resx220 rescale 1.04 +3 -> 0E+3 Inexact Rounded resx221 rescale 1.04 +2 -> 0E+2 Inexact Rounded resx222 rescale 1.04 +1 -> 0E+1 Inexact Rounded resx223 rescale 1.04 +0 -> 1 Inexact Rounded resx224 rescale 1.05 +3 -> 0E+3 Inexact Rounded resx225 rescale 1.05 +2 -> 0E+2 Inexact Rounded resx226 rescale 1.05 +1 -> 0E+1 Inexact Rounded resx227 rescale 1.05 +0 -> 1 Inexact Rounded resx228 rescale 1.05 +3 -> 0E+3 Inexact Rounded resx229 rescale 1.05 +2 -> 0E+2 Inexact Rounded resx230 rescale 1.05 +1 -> 0E+1 Inexact Rounded resx231 rescale 1.05 +0 -> 1 Inexact Rounded resx232 rescale 1.06 +3 -> 0E+3 Inexact Rounded resx233 rescale 1.06 +2 -> 0E+2 Inexact Rounded resx234 rescale 1.06 +1 -> 0E+1 Inexact Rounded resx235 rescale 1.06 +0 -> 1 Inexact Rounded resx240 rescale -10 +1 -> -1E+1 Rounded resx241 rescale +1 +1 -> 0E+1 Inexact Rounded resx242 rescale +10 +1 -> 1E+1 Rounded resx243 rescale 1E+1 +1 -> 1E+1 -- underneath this is E+1 resx244 rescale 1E+2 +1 -> 1.0E+2 -- underneath this is E+1 resx245 rescale 1E+3 +1 -> 1.00E+3 -- underneath this is E+1 resx246 rescale 1E+4 +1 -> 1.000E+4 -- underneath this is E+1 resx247 rescale 1E+5 +1 -> 1.0000E+5 -- underneath this is E+1 resx248 rescale 1E+6 +1 -> 1.00000E+6 -- underneath this is E+1 resx249 rescale 1E+7 +1 -> 1.000000E+7 -- underneath this is E+1 resx250 rescale 1E+8 +1 -> 1.0000000E+8 -- underneath this is E+1 resx251 rescale 1E+9 +1 -> 1.00000000E+9 -- underneath this is E+1 -- next one tries to add 9 zeros resx252 rescale 1E+10 +1 -> NaN Invalid_operation resx253 rescale 1E-10 +1 -> 0E+1 Inexact Rounded resx254 rescale 1E-2 +1 -> 0E+1 Inexact Rounded resx255 rescale 0E-10 +1 -> 0E+1 resx256 rescale -0E-10 +1 -> -0E+1 resx257 rescale -0E-1 +1 -> -0E+1 resx258 rescale -0 +1 -> -0E+1 resx259 rescale -0E+1 +1 -> -0E+1 resx260 rescale -10 +2 -> -0E+2 Inexact Rounded resx261 rescale +1 +2 -> 0E+2 Inexact Rounded resx262 rescale +10 +2 -> 0E+2 Inexact Rounded resx263 rescale 1E+1 +2 -> 0E+2 Inexact Rounded resx264 rescale 1E+2 +2 -> 1E+2 resx265 rescale 1E+3 +2 -> 1.0E+3 resx266 rescale 1E+4 +2 -> 1.00E+4 resx267 rescale 1E+5 +2 -> 1.000E+5 resx268 rescale 1E+6 +2 -> 1.0000E+6 resx269 rescale 1E+7 +2 -> 1.00000E+7 resx270 rescale 1E+8 +2 -> 1.000000E+8 resx271 rescale 1E+9 +2 -> 1.0000000E+9 resx272 rescale 1E+10 +2 -> 1.00000000E+10 resx273 rescale 1E-10 +2 -> 0E+2 Inexact Rounded resx274 rescale 1E-2 +2 -> 0E+2 Inexact Rounded resx275 rescale 0E-10 +2 -> 0E+2 resx280 rescale -10 +3 -> -0E+3 Inexact Rounded resx281 rescale +1 +3 -> 0E+3 Inexact Rounded resx282 rescale +10 +3 -> 0E+3 Inexact Rounded resx283 rescale 1E+1 +3 -> 0E+3 Inexact Rounded resx284 rescale 1E+2 +3 -> 0E+3 Inexact Rounded resx285 rescale 1E+3 +3 -> 1E+3 resx286 rescale 1E+4 +3 -> 1.0E+4 resx287 rescale 1E+5 +3 -> 1.00E+5 resx288 rescale 1E+6 +3 -> 1.000E+6 resx289 rescale 1E+7 +3 -> 1.0000E+7 resx290 rescale 1E+8 +3 -> 1.00000E+8 resx291 rescale 1E+9 +3 -> 1.000000E+9 resx292 rescale 1E+10 +3 -> 1.0000000E+10 resx293 rescale 1E-10 +3 -> 0E+3 Inexact Rounded resx294 rescale 1E-2 +3 -> 0E+3 Inexact Rounded resx295 rescale 0E-10 +3 -> 0E+3 -- round up from below [sign wrong in JIT compiler once] resx300 rescale 0.0078 -5 -> 0.00780 resx301 rescale 0.0078 -4 -> 0.0078 resx302 rescale 0.0078 -3 -> 0.008 Inexact Rounded resx303 rescale 0.0078 -2 -> 0.01 Inexact Rounded resx304 rescale 0.0078 -1 -> 0.0 Inexact Rounded resx305 rescale 0.0078 0 -> 0 Inexact Rounded resx306 rescale 0.0078 +1 -> 0E+1 Inexact Rounded resx307 rescale 0.0078 +2 -> 0E+2 Inexact Rounded resx310 rescale -0.0078 -5 -> -0.00780 resx311 rescale -0.0078 -4 -> -0.0078 resx312 rescale -0.0078 -3 -> -0.008 Inexact Rounded resx313 rescale -0.0078 -2 -> -0.01 Inexact Rounded resx314 rescale -0.0078 -1 -> -0.0 Inexact Rounded resx315 rescale -0.0078 0 -> -0 Inexact Rounded resx316 rescale -0.0078 +1 -> -0E+1 Inexact Rounded resx317 rescale -0.0078 +2 -> -0E+2 Inexact Rounded resx320 rescale 0.078 -5 -> 0.07800 resx321 rescale 0.078 -4 -> 0.0780 resx322 rescale 0.078 -3 -> 0.078 resx323 rescale 0.078 -2 -> 0.08 Inexact Rounded resx324 rescale 0.078 -1 -> 0.1 Inexact Rounded resx325 rescale 0.078 0 -> 0 Inexact Rounded resx326 rescale 0.078 +1 -> 0E+1 Inexact Rounded resx327 rescale 0.078 +2 -> 0E+2 Inexact Rounded resx330 rescale -0.078 -5 -> -0.07800 resx331 rescale -0.078 -4 -> -0.0780 resx332 rescale -0.078 -3 -> -0.078 resx333 rescale -0.078 -2 -> -0.08 Inexact Rounded resx334 rescale -0.078 -1 -> -0.1 Inexact Rounded resx335 rescale -0.078 0 -> -0 Inexact Rounded resx336 rescale -0.078 +1 -> -0E+1 Inexact Rounded resx337 rescale -0.078 +2 -> -0E+2 Inexact Rounded resx340 rescale 0.78 -5 -> 0.78000 resx341 rescale 0.78 -4 -> 0.7800 resx342 rescale 0.78 -3 -> 0.780 resx343 rescale 0.78 -2 -> 0.78 resx344 rescale 0.78 -1 -> 0.8 Inexact Rounded resx345 rescale 0.78 0 -> 1 Inexact Rounded resx346 rescale 0.78 +1 -> 0E+1 Inexact Rounded resx347 rescale 0.78 +2 -> 0E+2 Inexact Rounded resx350 rescale -0.78 -5 -> -0.78000 resx351 rescale -0.78 -4 -> -0.7800 resx352 rescale -0.78 -3 -> -0.780 resx353 rescale -0.78 -2 -> -0.78 resx354 rescale -0.78 -1 -> -0.8 Inexact Rounded resx355 rescale -0.78 0 -> -1 Inexact Rounded resx356 rescale -0.78 +1 -> -0E+1 Inexact Rounded resx357 rescale -0.78 +2 -> -0E+2 Inexact Rounded resx360 rescale 7.8 -5 -> 7.80000 resx361 rescale 7.8 -4 -> 7.8000 resx362 rescale 7.8 -3 -> 7.800 resx363 rescale 7.8 -2 -> 7.80 resx364 rescale 7.8 -1 -> 7.8 resx365 rescale 7.8 0 -> 8 Inexact Rounded resx366 rescale 7.8 +1 -> 1E+1 Inexact Rounded resx367 rescale 7.8 +2 -> 0E+2 Inexact Rounded resx368 rescale 7.8 +3 -> 0E+3 Inexact Rounded resx370 rescale -7.8 -5 -> -7.80000 resx371 rescale -7.8 -4 -> -7.8000 resx372 rescale -7.8 -3 -> -7.800 resx373 rescale -7.8 -2 -> -7.80 resx374 rescale -7.8 -1 -> -7.8 resx375 rescale -7.8 0 -> -8 Inexact Rounded resx376 rescale -7.8 +1 -> -1E+1 Inexact Rounded resx377 rescale -7.8 +2 -> -0E+2 Inexact Rounded resx378 rescale -7.8 +3 -> -0E+3 Inexact Rounded -- some individuals precision: 9 resx380 rescale 352364.506 -2 -> 352364.51 Inexact Rounded resx381 rescale 3523645.06 -2 -> 3523645.06 resx382 rescale 35236450.6 -2 -> NaN Invalid_operation resx383 rescale 352364506 -2 -> NaN Invalid_operation resx384 rescale -352364.506 -2 -> -352364.51 Inexact Rounded resx385 rescale -3523645.06 -2 -> -3523645.06 resx386 rescale -35236450.6 -2 -> NaN Invalid_operation resx387 rescale -352364506 -2 -> NaN Invalid_operation rounding: down resx389 rescale 35236450.6 -2 -> NaN Invalid_operation -- ? should that one instead have been: -- resx389 rescale 35236450.6 -2 -> NaN Invalid_operation rounding: half_up -- and a few more from e-mail discussions precision: 7 resx391 rescale 12.34567 -3 -> 12.346 Inexact Rounded resx392 rescale 123.4567 -3 -> 123.457 Inexact Rounded resx393 rescale 1234.567 -3 -> 1234.567 resx394 rescale 12345.67 -3 -> NaN Invalid_operation resx395 rescale 123456.7 -3 -> NaN Invalid_operation resx396 rescale 1234567. -3 -> NaN Invalid_operation -- some 9999 round-up cases precision: 9 resx400 rescale 9.999 -5 -> 9.99900 resx401 rescale 9.999 -4 -> 9.9990 resx402 rescale 9.999 -3 -> 9.999 resx403 rescale 9.999 -2 -> 10.00 Inexact Rounded resx404 rescale 9.999 -1 -> 10.0 Inexact Rounded resx405 rescale 9.999 0 -> 10 Inexact Rounded resx406 rescale 9.999 1 -> 1E+1 Inexact Rounded resx407 rescale 9.999 2 -> 0E+2 Inexact Rounded resx410 rescale 0.999 -5 -> 0.99900 resx411 rescale 0.999 -4 -> 0.9990 resx412 rescale 0.999 -3 -> 0.999 resx413 rescale 0.999 -2 -> 1.00 Inexact Rounded resx414 rescale 0.999 -1 -> 1.0 Inexact Rounded resx415 rescale 0.999 0 -> 1 Inexact Rounded resx416 rescale 0.999 1 -> 0E+1 Inexact Rounded resx420 rescale 0.0999 -5 -> 0.09990 resx421 rescale 0.0999 -4 -> 0.0999 resx422 rescale 0.0999 -3 -> 0.100 Inexact Rounded resx423 rescale 0.0999 -2 -> 0.10 Inexact Rounded resx424 rescale 0.0999 -1 -> 0.1 Inexact Rounded resx425 rescale 0.0999 0 -> 0 Inexact Rounded resx426 rescale 0.0999 1 -> 0E+1 Inexact Rounded resx430 rescale 0.00999 -5 -> 0.00999 resx431 rescale 0.00999 -4 -> 0.0100 Inexact Rounded resx432 rescale 0.00999 -3 -> 0.010 Inexact Rounded resx433 rescale 0.00999 -2 -> 0.01 Inexact Rounded resx434 rescale 0.00999 -1 -> 0.0 Inexact Rounded resx435 rescale 0.00999 0 -> 0 Inexact Rounded resx436 rescale 0.00999 1 -> 0E+1 Inexact Rounded resx440 rescale 0.000999 -5 -> 0.00100 Inexact Rounded resx441 rescale 0.000999 -4 -> 0.0010 Inexact Rounded resx442 rescale 0.000999 -3 -> 0.001 Inexact Rounded resx443 rescale 0.000999 -2 -> 0.00 Inexact Rounded resx444 rescale 0.000999 -1 -> 0.0 Inexact Rounded resx445 rescale 0.000999 0 -> 0 Inexact Rounded resx446 rescale 0.000999 1 -> 0E+1 Inexact Rounded precision: 8 resx449 rescale 9.999E-15 -23 -> NaN Invalid_operation resx450 rescale 9.999E-15 -22 -> 9.9990000E-15 resx451 rescale 9.999E-15 -21 -> 9.999000E-15 resx452 rescale 9.999E-15 -20 -> 9.99900E-15 resx453 rescale 9.999E-15 -19 -> 9.9990E-15 resx454 rescale 9.999E-15 -18 -> 9.999E-15 resx455 rescale 9.999E-15 -17 -> 1.000E-14 Inexact Rounded resx456 rescale 9.999E-15 -16 -> 1.00E-14 Inexact Rounded resx457 rescale 9.999E-15 -15 -> 1.0E-14 Inexact Rounded resx458 rescale 9.999E-15 -14 -> 1E-14 Inexact Rounded resx459 rescale 9.999E-15 -13 -> 0E-13 Inexact Rounded resx460 rescale 9.999E-15 -12 -> 0E-12 Inexact Rounded resx461 rescale 9.999E-15 -11 -> 0E-11 Inexact Rounded resx462 rescale 9.999E-15 -10 -> 0E-10 Inexact Rounded resx463 rescale 9.999E-15 -9 -> 0E-9 Inexact Rounded resx464 rescale 9.999E-15 -8 -> 0E-8 Inexact Rounded resx465 rescale 9.999E-15 -7 -> 0E-7 Inexact Rounded resx466 rescale 9.999E-15 -6 -> 0.000000 Inexact Rounded resx467 rescale 9.999E-15 -5 -> 0.00000 Inexact Rounded resx468 rescale 9.999E-15 -4 -> 0.0000 Inexact Rounded resx469 rescale 9.999E-15 -3 -> 0.000 Inexact Rounded resx470 rescale 9.999E-15 -2 -> 0.00 Inexact Rounded resx471 rescale 9.999E-15 -1 -> 0.0 Inexact Rounded resx472 rescale 9.999E-15 0 -> 0 Inexact Rounded resx473 rescale 9.999E-15 1 -> 0E+1 Inexact Rounded -- long operand checks [rhs checks removed] maxexponent: 999 minexponent: -999 precision: 9 resx481 rescale 12345678000 +3 -> 1.2345678E+10 Rounded resx482 rescale 1234567800 +1 -> 1.23456780E+9 Rounded resx483 rescale 1234567890 +1 -> 1.23456789E+9 Rounded resx484 rescale 1234567891 +1 -> 1.23456789E+9 Inexact Rounded resx485 rescale 12345678901 +2 -> 1.23456789E+10 Inexact Rounded resx486 rescale 1234567896 +1 -> 1.23456790E+9 Inexact Rounded -- a potential double-round resx487 rescale 1234.987643 -4 -> 1234.9876 Inexact Rounded resx488 rescale 1234.987647 -4 -> 1234.9876 Inexact Rounded precision: 15 resx491 rescale 12345678000 +3 -> 1.2345678E+10 Rounded resx492 rescale 1234567800 +1 -> 1.23456780E+9 Rounded resx493 rescale 1234567890 +1 -> 1.23456789E+9 Rounded resx494 rescale 1234567891 +1 -> 1.23456789E+9 Inexact Rounded resx495 rescale 12345678901 +2 -> 1.23456789E+10 Inexact Rounded resx496 rescale 1234567896 +1 -> 1.23456790E+9 Inexact Rounded resx497 rescale 1234.987643 -4 -> 1234.9876 Inexact Rounded resx498 rescale 1234.987647 -4 -> 1234.9876 Inexact Rounded -- Zeros resx500 rescale 0 1 -> 0E+1 resx501 rescale 0 0 -> 0 resx502 rescale 0 -1 -> 0.0 resx503 rescale 0.0 -1 -> 0.0 resx504 rescale 0.0 0 -> 0 resx505 rescale 0.0 +1 -> 0E+1 resx506 rescale 0E+1 -1 -> 0.0 resx507 rescale 0E+1 0 -> 0 resx508 rescale 0E+1 +1 -> 0E+1 resx509 rescale -0 1 -> -0E+1 resx510 rescale -0 0 -> -0 resx511 rescale -0 -1 -> -0.0 resx512 rescale -0.0 -1 -> -0.0 resx513 rescale -0.0 0 -> -0 resx514 rescale -0.0 +1 -> -0E+1 resx515 rescale -0E+1 -1 -> -0.0 resx516 rescale -0E+1 0 -> -0 resx517 rescale -0E+1 +1 -> -0E+1 -- Suspicious RHS values maxexponent: 999999999 minexponent: -999999999 precision: 15 resx520 rescale 1.234 999999E+3 -> 0E+999999000 Inexact Rounded resx521 rescale 123.456 999999E+3 -> 0E+999999000 Inexact Rounded resx522 rescale 1.234 999999999 -> 0E+999999999 Inexact Rounded resx523 rescale 123.456 999999999 -> 0E+999999999 Inexact Rounded resx524 rescale 123.456 1000000000 -> NaN Invalid_operation resx525 rescale 123.456 12345678903 -> NaN Invalid_operation -- next four are "won't fit" overflows resx526 rescale 1.234 -999999E+3 -> NaN Invalid_operation resx527 rescale 123.456 -999999E+3 -> NaN Invalid_operation resx528 rescale 1.234 -999999999 -> NaN Invalid_operation resx529 rescale 123.456 -999999999 -> NaN Invalid_operation resx530 rescale 123.456 -1000000014 -> NaN Invalid_operation resx531 rescale 123.456 -12345678903 -> NaN Invalid_operation maxexponent: 999 minexponent: -999 precision: 15 resx532 rescale 1.234E+999 999 -> 1E+999 Inexact Rounded resx533 rescale 1.234E+998 999 -> 0E+999 Inexact Rounded resx534 rescale 1.234 999 -> 0E+999 Inexact Rounded resx535 rescale 1.234 1000 -> NaN Invalid_operation resx536 rescale 1.234 5000 -> NaN Invalid_operation resx537 rescale 0 -999 -> 0E-999 -- next two are "won't fit" overflows resx538 rescale 1.234 -999 -> NaN Invalid_operation resx539 rescale 1.234 -1000 -> NaN Invalid_operation resx540 rescale 1.234 -5000 -> NaN Invalid_operation -- [more below] -- check bounds (lhs maybe out of range for destination, etc.) precision: 7 resx541 rescale 1E+999 +999 -> 1E+999 resx542 rescale 1E+1000 +999 -> NaN Invalid_operation resx543 rescale 1E+999 +1000 -> NaN Invalid_operation resx544 rescale 1E-999 -999 -> 1E-999 resx545 rescale 1E-1000 -999 -> 0E-999 Inexact Rounded resx546 rescale 1E-999 -1000 -> 1.0E-999 resx547 rescale 1E-1005 -999 -> 0E-999 Inexact Rounded resx548 rescale 1E-1006 -999 -> 0E-999 Inexact Rounded resx549 rescale 1E-1007 -999 -> 0E-999 Inexact Rounded resx550 rescale 1E-998 -1005 -> NaN Invalid_operation -- won't fit resx551 rescale 1E-999 -1005 -> 1.000000E-999 resx552 rescale 1E-1000 -1005 -> 1.00000E-1000 Subnormal resx553 rescale 1E-999 -1006 -> NaN Invalid_operation resx554 rescale 1E-999 -1007 -> NaN Invalid_operation -- related subnormal rounding resx555 rescale 1.666666E-999 -1005 -> 1.666666E-999 resx556 rescale 1.666666E-1000 -1005 -> 1.66667E-1000 Underflow Subnormal Inexact Rounded resx557 rescale 1.666666E-1001 -1005 -> 1.6667E-1001 Underflow Subnormal Inexact Rounded resx558 rescale 1.666666E-1002 -1005 -> 1.667E-1002 Underflow Subnormal Inexact Rounded resx559 rescale 1.666666E-1003 -1005 -> 1.67E-1003 Underflow Subnormal Inexact Rounded resx560 rescale 1.666666E-1004 -1005 -> 1.7E-1004 Underflow Subnormal Inexact Rounded resx561 rescale 1.666666E-1005 -1005 -> 2E-1005 Underflow Subnormal Inexact Rounded resx562 rescale 1.666666E-1006 -1005 -> 0E-1005 Inexact Rounded resx563 rescale 1.666666E-1007 -1005 -> 0E-1005 Inexact Rounded -- fractional RHS, some good and some bad precision: 9 resx564 rescale 222 +2.0 -> 2E+2 Inexact Rounded resx565 rescale 222 +2.00000000 -> 2E+2 Inexact Rounded resx566 rescale 222 +2.00100000000 -> NaN Invalid_operation resx567 rescale 222 +2.000001 -> NaN Invalid_operation resx568 rescale 222 +2.000000001 -> NaN Invalid_operation resx569 rescale 222 +2.0000000001 -> NaN Invalid_operation resx570 rescale 222 +2.00000000001 -> NaN Invalid_operation resx571 rescale 222 +2.99999999999 -> NaN Invalid_operation resx572 rescale 222 -2.00000000 -> 222.00 resx573 rescale 222 -2.00100000000 -> NaN Invalid_operation resx574 rescale 222 -2.0000001000 -> NaN Invalid_operation resx575 rescale 222 -2.00000000001 -> NaN Invalid_operation resx576 rescale 222 -2.99999999999 -> NaN Invalid_operation -- Specials resx580 rescale Inf -Inf -> Infinity resx581 rescale Inf -1000 -> NaN Invalid_operation resx582 rescale Inf -1 -> NaN Invalid_operation resx583 rescale Inf 0 -> NaN Invalid_operation resx584 rescale Inf 1 -> NaN Invalid_operation resx585 rescale Inf 1000 -> NaN Invalid_operation resx586 rescale Inf Inf -> Infinity resx587 rescale -1000 Inf -> NaN Invalid_operation resx588 rescale -Inf Inf -> -Infinity resx589 rescale -1 Inf -> NaN Invalid_operation resx590 rescale 0 Inf -> NaN Invalid_operation resx591 rescale 1 Inf -> NaN Invalid_operation resx592 rescale 1000 Inf -> NaN Invalid_operation resx593 rescale Inf Inf -> Infinity resx594 rescale Inf -0 -> NaN Invalid_operation resx595 rescale -0 Inf -> NaN Invalid_operation resx600 rescale -Inf -Inf -> -Infinity resx601 rescale -Inf -1000 -> NaN Invalid_operation resx602 rescale -Inf -1 -> NaN Invalid_operation resx603 rescale -Inf 0 -> NaN Invalid_operation resx604 rescale -Inf 1 -> NaN Invalid_operation resx605 rescale -Inf 1000 -> NaN Invalid_operation resx606 rescale -Inf Inf -> -Infinity resx607 rescale -1000 Inf -> NaN Invalid_operation resx608 rescale -Inf -Inf -> -Infinity resx609 rescale -1 -Inf -> NaN Invalid_operation resx610 rescale 0 -Inf -> NaN Invalid_operation resx611 rescale 1 -Inf -> NaN Invalid_operation resx612 rescale 1000 -Inf -> NaN Invalid_operation resx613 rescale Inf -Inf -> Infinity resx614 rescale -Inf -0 -> NaN Invalid_operation resx615 rescale -0 -Inf -> NaN Invalid_operation resx621 rescale NaN -Inf -> NaN resx622 rescale NaN -1000 -> NaN resx623 rescale NaN -1 -> NaN resx624 rescale NaN 0 -> NaN resx625 rescale NaN 1 -> NaN resx626 rescale NaN 1000 -> NaN resx627 rescale NaN Inf -> NaN resx628 rescale NaN NaN -> NaN resx629 rescale -Inf NaN -> NaN resx630 rescale -1000 NaN -> NaN resx631 rescale -1 NaN -> NaN resx632 rescale 0 NaN -> NaN resx633 rescale 1 -NaN -> -NaN resx634 rescale 1000 NaN -> NaN resx635 rescale Inf NaN -> NaN resx636 rescale NaN -0 -> NaN resx637 rescale -0 NaN -> NaN resx641 rescale sNaN -Inf -> NaN Invalid_operation resx642 rescale sNaN -1000 -> NaN Invalid_operation resx643 rescale sNaN -1 -> NaN Invalid_operation resx644 rescale sNaN 0 -> NaN Invalid_operation resx645 rescale sNaN 1 -> NaN Invalid_operation resx646 rescale sNaN 1000 -> NaN Invalid_operation resx647 rescale -sNaN NaN -> -NaN Invalid_operation resx648 rescale sNaN -sNaN -> NaN Invalid_operation resx649 rescale NaN sNaN -> NaN Invalid_operation resx650 rescale -Inf sNaN -> NaN Invalid_operation resx651 rescale -1000 sNaN -> NaN Invalid_operation resx652 rescale -1 sNaN -> NaN Invalid_operation resx653 rescale 0 sNaN -> NaN Invalid_operation resx654 rescale 1 -sNaN -> -NaN Invalid_operation resx655 rescale 1000 sNaN -> NaN Invalid_operation resx656 rescale Inf sNaN -> NaN Invalid_operation resx657 rescale NaN sNaN -> NaN Invalid_operation resx658 rescale sNaN -0 -> NaN Invalid_operation resx659 rescale -0 sNaN -> NaN Invalid_operation -- propagating NaNs resx661 rescale NaN9 -Inf -> NaN9 resx662 rescale NaN81 919 -> NaN81 resx663 rescale NaN72 Inf -> NaN72 resx664 rescale -NaN66 NaN5 -> -NaN66 resx665 rescale -Inf NaN4 -> NaN4 resx666 rescale -919 NaN32 -> NaN32 resx667 rescale Inf NaN2 -> NaN2 resx671 rescale sNaN99 -Inf -> NaN99 Invalid_operation resx672 rescale -sNaN98 -11 -> -NaN98 Invalid_operation resx673 rescale sNaN97 NaN -> NaN97 Invalid_operation resx674 rescale sNaN16 sNaN94 -> NaN16 Invalid_operation resx675 rescale NaN95 sNaN93 -> NaN93 Invalid_operation resx676 rescale -Inf sNaN92 -> NaN92 Invalid_operation resx677 rescale 088 -sNaN91 -> -NaN91 Invalid_operation resx678 rescale Inf -sNaN90 -> -NaN90 Invalid_operation resx679 rescale NaN sNaN87 -> NaN87 Invalid_operation -- subnormals and underflow precision: 4 maxexponent: 999 minexponent: -999 resx710 rescale 1.00E-999 -999 -> 1E-999 Rounded resx711 rescale 0.1E-999 -1000 -> 1E-1000 Subnormal resx712 rescale 0.10E-999 -1000 -> 1E-1000 Subnormal Rounded resx713 rescale 0.100E-999 -1000 -> 1E-1000 Subnormal Rounded resx714 rescale 0.01E-999 -1001 -> 1E-1001 Subnormal -- next is rounded to Emin resx715 rescale 0.999E-999 -999 -> 1E-999 Inexact Rounded resx716 rescale 0.099E-999 -1000 -> 1E-1000 Inexact Rounded Subnormal Underflow resx717 rescale 0.009E-999 -1001 -> 1E-1001 Inexact Rounded Subnormal Underflow resx718 rescale 0.001E-999 -1001 -> 0E-1001 Inexact Rounded resx719 rescale 0.0009E-999 -1001 -> 0E-1001 Inexact Rounded resx720 rescale 0.0001E-999 -1001 -> 0E-1001 Inexact Rounded resx730 rescale -1.00E-999 -999 -> -1E-999 Rounded resx731 rescale -0.1E-999 -999 -> -0E-999 Rounded Inexact resx732 rescale -0.10E-999 -999 -> -0E-999 Rounded Inexact resx733 rescale -0.100E-999 -999 -> -0E-999 Rounded Inexact resx734 rescale -0.01E-999 -999 -> -0E-999 Inexact Rounded -- next is rounded to Emin resx735 rescale -0.999E-999 -999 -> -1E-999 Inexact Rounded resx736 rescale -0.099E-999 -999 -> -0E-999 Inexact Rounded resx737 rescale -0.009E-999 -999 -> -0E-999 Inexact Rounded resx738 rescale -0.001E-999 -999 -> -0E-999 Inexact Rounded resx739 rescale -0.0001E-999 -999 -> -0E-999 Inexact Rounded resx740 rescale -1.00E-999 -1000 -> -1.0E-999 Rounded resx741 rescale -0.1E-999 -1000 -> -1E-1000 Subnormal resx742 rescale -0.10E-999 -1000 -> -1E-1000 Subnormal Rounded resx743 rescale -0.100E-999 -1000 -> -1E-1000 Subnormal Rounded resx744 rescale -0.01E-999 -1000 -> -0E-1000 Inexact Rounded -- next is rounded to Emin resx745 rescale -0.999E-999 -1000 -> -1.0E-999 Inexact Rounded resx746 rescale -0.099E-999 -1000 -> -1E-1000 Inexact Rounded Subnormal Underflow resx747 rescale -0.009E-999 -1000 -> -0E-1000 Inexact Rounded resx748 rescale -0.001E-999 -1000 -> -0E-1000 Inexact Rounded resx749 rescale -0.0001E-999 -1000 -> -0E-1000 Inexact Rounded resx750 rescale -1.00E-999 -1001 -> -1.00E-999 resx751 rescale -0.1E-999 -1001 -> -1.0E-1000 Subnormal resx752 rescale -0.10E-999 -1001 -> -1.0E-1000 Subnormal resx753 rescale -0.100E-999 -1001 -> -1.0E-1000 Subnormal Rounded resx754 rescale -0.01E-999 -1001 -> -1E-1001 Subnormal -- next is rounded to Emin resx755 rescale -0.999E-999 -1001 -> -1.00E-999 Inexact Rounded resx756 rescale -0.099E-999 -1001 -> -1.0E-1000 Inexact Rounded Subnormal Underflow resx757 rescale -0.009E-999 -1001 -> -1E-1001 Inexact Rounded Subnormal Underflow resx758 rescale -0.001E-999 -1001 -> -0E-1001 Inexact Rounded resx759 rescale -0.0001E-999 -1001 -> -0E-1001 Inexact Rounded resx760 rescale -1.00E-999 -1002 -> -1.000E-999 resx761 rescale -0.1E-999 -1002 -> -1.00E-1000 Subnormal resx762 rescale -0.10E-999 -1002 -> -1.00E-1000 Subnormal resx763 rescale -0.100E-999 -1002 -> -1.00E-1000 Subnormal resx764 rescale -0.01E-999 -1002 -> -1.0E-1001 Subnormal resx765 rescale -0.999E-999 -1002 -> -9.99E-1000 Subnormal resx766 rescale -0.099E-999 -1002 -> -9.9E-1001 Subnormal resx767 rescale -0.009E-999 -1002 -> -9E-1002 Subnormal resx768 rescale -0.001E-999 -1002 -> -1E-1002 Subnormal resx769 rescale -0.0001E-999 -1002 -> -0E-1002 Inexact Rounded -- rhs must be no less than Etiny resx770 rescale -1.00E-999 -1003 -> NaN Invalid_operation resx771 rescale -0.1E-999 -1003 -> NaN Invalid_operation resx772 rescale -0.10E-999 -1003 -> NaN Invalid_operation resx773 rescale -0.100E-999 -1003 -> NaN Invalid_operation resx774 rescale -0.01E-999 -1003 -> NaN Invalid_operation resx775 rescale -0.999E-999 -1003 -> NaN Invalid_operation resx776 rescale -0.099E-999 -1003 -> NaN Invalid_operation resx777 rescale -0.009E-999 -1003 -> NaN Invalid_operation resx778 rescale -0.001E-999 -1003 -> NaN Invalid_operation resx779 rescale -0.0001E-999 -1003 -> NaN Invalid_operation precision: 9 maxExponent: 999999999 minexponent: -999999999 -- getInt worries resx801 rescale 0 1000000000 -> NaN Invalid_operation resx802 rescale 0 -1000000000 -> 0E-1000000000 resx803 rescale 0 2000000000 -> NaN Invalid_operation resx804 rescale 0 -2000000000 -> NaN Invalid_operation resx805 rescale 0 3000000000 -> NaN Invalid_operation resx806 rescale 0 -3000000000 -> NaN Invalid_operation resx807 rescale 0 4000000000 -> NaN Invalid_operation resx808 rescale 0 -4000000000 -> NaN Invalid_operation resx809 rescale 0 5000000000 -> NaN Invalid_operation resx810 rescale 0 -5000000000 -> NaN Invalid_operation resx811 rescale 0 6000000000 -> NaN Invalid_operation resx812 rescale 0 -6000000000 -> NaN Invalid_operation resx813 rescale 0 7000000000 -> NaN Invalid_operation resx814 rescale 0 -7000000000 -> NaN Invalid_operation resx815 rescale 0 8000000000 -> NaN Invalid_operation resx816 rescale 0 -8000000000 -> NaN Invalid_operation resx817 rescale 0 9000000000 -> NaN Invalid_operation resx818 rescale 0 -9000000000 -> NaN Invalid_operation resx819 rescale 0 9999999999 -> NaN Invalid_operation resx820 rescale 0 -9999999999 -> NaN Invalid_operation resx821 rescale 0 10000000000 -> NaN Invalid_operation resx822 rescale 0 -10000000000 -> NaN Invalid_operation resx831 rescale 1 0E-1 -> 1 resx832 rescale 1 0E-2 -> 1 resx833 rescale 1 0E-3 -> 1 resx834 rescale 1 0E-4 -> 1 resx835 rescale 1 0E-100 -> 1 resx836 rescale 1 0E-100000 -> 1 resx837 rescale 1 0E+100 -> 1 resx838 rescale 1 0E+100000 -> 1 resx841 rescale 0 5E-1000000 -> NaN Invalid_operation resx842 rescale 0 5E-1000000 -> NaN Invalid_operation resx843 rescale 0 999999999 -> 0E+999999999 resx844 rescale 0 1000000000 -> NaN Invalid_operation resx845 rescale 0 -999999999 -> 0E-999999999 resx846 rescale 0 -1000000000 -> 0E-1000000000 resx847 rescale 0 -1000000001 -> 0E-1000000001 resx848 rescale 0 -1000000002 -> 0E-1000000002 resx849 rescale 0 -1000000003 -> 0E-1000000003 resx850 rescale 0 -1000000004 -> 0E-1000000004 resx851 rescale 0 -1000000005 -> 0E-1000000005 resx852 rescale 0 -1000000006 -> 0E-1000000006 resx853 rescale 0 -1000000007 -> 0E-1000000007 resx854 rescale 0 -1000000008 -> NaN Invalid_operation resx861 rescale 1 +2147483649 -> NaN Invalid_operation resx862 rescale 1 +2147483648 -> NaN Invalid_operation resx863 rescale 1 +2147483647 -> NaN Invalid_operation resx864 rescale 1 -2147483647 -> NaN Invalid_operation resx865 rescale 1 -2147483648 -> NaN Invalid_operation resx866 rescale 1 -2147483649 -> NaN Invalid_operation -- Null tests res900 rescale 10 # -> NaN Invalid_operation res901 rescale # 10 -> NaN Invalid_operation --- NEW FILE: rounding.decTest --- ------------------------------------------------------------------------ -- rounding.decTest -- decimal rounding modes testcases -- -- Copyright (c) IBM Corporation, 1981, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ [...1040 lines suppressed...] rmex401 multiply 9.999E+999999999 10 -> Infinity Overflow Inexact Rounded rounding: half_down rmex402 multiply -9.999E+999999999 10 -> -Infinity Overflow Inexact Rounded rmex403 multiply 9.999E+999999999 10 -> Infinity Overflow Inexact Rounded rounding: half_even rmex404 multiply -9.999E+999999999 10 -> -Infinity Overflow Inexact Rounded rmex405 multiply 9.999E+999999999 10 -> Infinity Overflow Inexact Rounded rounding: floor rmex406 multiply -9.999E+999999999 10 -> -Infinity Overflow Inexact Rounded rmex407 multiply 9.999E+999999999 10 -> 9.99999999E+999999999 Overflow Inexact Rounded rounding: ceiling rmex408 multiply -9.999E+999999999 10 -> -9.99999999E+999999999 Overflow Inexact Rounded rmex409 multiply 9.999E+999999999 10 -> Infinity Overflow Inexact Rounded rounding: up rmex410 multiply -9.999E+999999999 10 -> -Infinity Overflow Inexact Rounded rmex411 multiply 9.999E+999999999 10 -> Infinity Overflow Inexact Rounded rounding: down rmex412 multiply -9.999E+999999999 10 -> -9.99999999E+999999999 Overflow Inexact Rounded rmex413 multiply 9.999E+999999999 10 -> 9.99999999E+999999999 Overflow Inexact Rounded --- NEW FILE: samequantum.decTest --- ------------------------------------------------------------------------ -- samequantum.decTest -- check quantums match -- -- Copyright (c) IBM Corporation, 2001, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 extended: 1 precision: 9 rounding: half_up maxExponent: 999 minExponent: -999 samq001 samequantum 0 0 -> 1 samq002 samequantum 0 1 -> 1 samq003 samequantum 1 0 -> 1 samq004 samequantum 1 1 -> 1 samq011 samequantum 10 1E+1 -> 0 samq012 samequantum 10E+1 10E+1 -> 1 samq013 samequantum 100 10E+1 -> 0 samq014 samequantum 100 1E+2 -> 0 samq015 samequantum 0.1 1E-2 -> 0 samq016 samequantum 0.1 1E-1 -> 1 samq017 samequantum 0.1 1E-0 -> 0 samq018 samequantum 999 999 -> 1 samq019 samequantum 999E-1 99.9 -> 1 samq020 samequantum 111E-1 22.2 -> 1 samq021 samequantum 111E-1 1234.2 -> 1 -- zeros samq030 samequantum 0.0 1.1 -> 1 samq031 samequantum 0.0 1.11 -> 0 samq032 samequantum 0.0 0 -> 0 samq033 samequantum 0.0 0.0 -> 1 samq034 samequantum 0.0 0.00 -> 0 samq035 samequantum 0E+1 0E+0 -> 0 samq036 samequantum 0E+1 0E+1 -> 1 samq037 samequantum 0E+1 0E+2 -> 0 samq038 samequantum 0E-17 0E-16 -> 0 samq039 samequantum 0E-17 0E-17 -> 1 samq040 samequantum 0E-17 0E-18 -> 0 samq041 samequantum 0E-17 0.0E-15 -> 0 samq042 samequantum 0E-17 0.0E-16 -> 1 samq043 samequantum 0E-17 0.0E-17 -> 0 samq044 samequantum -0E-17 0.0E-16 -> 1 samq045 samequantum 0E-17 -0.0E-17 -> 0 samq046 samequantum 0E-17 -0.0E-16 -> 1 samq047 samequantum -0E-17 0.0E-17 -> 0 samq048 samequantum -0E-17 -0.0E-16 -> 1 samq049 samequantum -0E-17 -0.0E-17 -> 0 -- specials & combinations samq0110 samequantum -Inf -Inf -> 1 samq0111 samequantum -Inf Inf -> 1 samq0112 samequantum -Inf NaN -> 0 samq0113 samequantum -Inf -7E+3 -> 0 samq0114 samequantum -Inf -7 -> 0 samq0115 samequantum -Inf -7E-3 -> 0 samq0116 samequantum -Inf -0E-3 -> 0 samq0117 samequantum -Inf -0 -> 0 samq0118 samequantum -Inf -0E+3 -> 0 samq0119 samequantum -Inf 0E-3 -> 0 samq0120 samequantum -Inf 0 -> 0 samq0121 samequantum -Inf 0E+3 -> 0 samq0122 samequantum -Inf 7E-3 -> 0 samq0123 samequantum -Inf 7 -> 0 samq0124 samequantum -Inf 7E+3 -> 0 samq0125 samequantum -Inf sNaN -> 0 samq0210 samequantum Inf -Inf -> 1 samq0211 samequantum Inf Inf -> 1 samq0212 samequantum Inf NaN -> 0 samq0213 samequantum Inf -7E+3 -> 0 samq0214 samequantum Inf -7 -> 0 samq0215 samequantum Inf -7E-3 -> 0 samq0216 samequantum Inf -0E-3 -> 0 samq0217 samequantum Inf -0 -> 0 samq0218 samequantum Inf -0E+3 -> 0 samq0219 samequantum Inf 0E-3 -> 0 samq0220 samequantum Inf 0 -> 0 samq0221 samequantum Inf 0E+3 -> 0 samq0222 samequantum Inf 7E-3 -> 0 samq0223 samequantum Inf 7 -> 0 samq0224 samequantum Inf 7E+3 -> 0 samq0225 samequantum Inf sNaN -> 0 samq0310 samequantum NaN -Inf -> 0 samq0311 samequantum NaN Inf -> 0 samq0312 samequantum NaN NaN -> 1 samq0313 samequantum NaN -7E+3 -> 0 samq0314 samequantum NaN -7 -> 0 samq0315 samequantum NaN -7E-3 -> 0 samq0316 samequantum NaN -0E-3 -> 0 samq0317 samequantum NaN -0 -> 0 samq0318 samequantum NaN -0E+3 -> 0 samq0319 samequantum NaN 0E-3 -> 0 samq0320 samequantum NaN 0 -> 0 samq0321 samequantum NaN 0E+3 -> 0 samq0322 samequantum NaN 7E-3 -> 0 samq0323 samequantum NaN 7 -> 0 samq0324 samequantum NaN 7E+3 -> 0 samq0325 samequantum NaN sNaN -> 1 samq0410 samequantum -7E+3 -Inf -> 0 samq0411 samequantum -7E+3 Inf -> 0 samq0412 samequantum -7E+3 NaN -> 0 samq0413 samequantum -7E+3 -7E+3 -> 1 samq0414 samequantum -7E+3 -7 -> 0 samq0415 samequantum -7E+3 -7E-3 -> 0 samq0416 samequantum -7E+3 -0E-3 -> 0 samq0417 samequantum -7E+3 -0 -> 0 samq0418 samequantum -7E+3 -0E+3 -> 1 samq0419 samequantum -7E+3 0E-3 -> 0 samq0420 samequantum -7E+3 0 -> 0 samq0421 samequantum -7E+3 0E+3 -> 1 samq0422 samequantum -7E+3 7E-3 -> 0 samq0423 samequantum -7E+3 7 -> 0 samq0424 samequantum -7E+3 7E+3 -> 1 samq0425 samequantum -7E+3 sNaN -> 0 samq0510 samequantum -7 -Inf -> 0 samq0511 samequantum -7 Inf -> 0 samq0512 samequantum -7 NaN -> 0 samq0513 samequantum -7 -7E+3 -> 0 samq0514 samequantum -7 -7 -> 1 samq0515 samequantum -7 -7E-3 -> 0 samq0516 samequantum -7 -0E-3 -> 0 samq0517 samequantum -7 -0 -> 1 samq0518 samequantum -7 -0E+3 -> 0 samq0519 samequantum -7 0E-3 -> 0 samq0520 samequantum -7 0 -> 1 samq0521 samequantum -7 0E+3 -> 0 samq0522 samequantum -7 7E-3 -> 0 samq0523 samequantum -7 7 -> 1 samq0524 samequantum -7 7E+3 -> 0 samq0525 samequantum -7 sNaN -> 0 samq0610 samequantum -7E-3 -Inf -> 0 samq0611 samequantum -7E-3 Inf -> 0 samq0612 samequantum -7E-3 NaN -> 0 samq0613 samequantum -7E-3 -7E+3 -> 0 samq0614 samequantum -7E-3 -7 -> 0 samq0615 samequantum -7E-3 -7E-3 -> 1 samq0616 samequantum -7E-3 -0E-3 -> 1 samq0617 samequantum -7E-3 -0 -> 0 samq0618 samequantum -7E-3 -0E+3 -> 0 samq0619 samequantum -7E-3 0E-3 -> 1 samq0620 samequantum -7E-3 0 -> 0 samq0621 samequantum -7E-3 0E+3 -> 0 samq0622 samequantum -7E-3 7E-3 -> 1 samq0623 samequantum -7E-3 7 -> 0 samq0624 samequantum -7E-3 7E+3 -> 0 samq0625 samequantum -7E-3 sNaN -> 0 samq0710 samequantum -0E-3 -Inf -> 0 samq0711 samequantum -0E-3 Inf -> 0 samq0712 samequantum -0E-3 NaN -> 0 samq0713 samequantum -0E-3 -7E+3 -> 0 samq0714 samequantum -0E-3 -7 -> 0 samq0715 samequantum -0E-3 -7E-3 -> 1 samq0716 samequantum -0E-3 -0E-3 -> 1 samq0717 samequantum -0E-3 -0 -> 0 samq0718 samequantum -0E-3 -0E+3 -> 0 samq0719 samequantum -0E-3 0E-3 -> 1 samq0720 samequantum -0E-3 0 -> 0 samq0721 samequantum -0E-3 0E+3 -> 0 samq0722 samequantum -0E-3 7E-3 -> 1 samq0723 samequantum -0E-3 7 -> 0 samq0724 samequantum -0E-3 7E+3 -> 0 samq0725 samequantum -0E-3 sNaN -> 0 samq0810 samequantum -0 -Inf -> 0 samq0811 samequantum -0 Inf -> 0 samq0812 samequantum -0 NaN -> 0 samq0813 samequantum -0 -7E+3 -> 0 samq0814 samequantum -0 -7 -> 1 samq0815 samequantum -0 -7E-3 -> 0 samq0816 samequantum -0 -0E-3 -> 0 samq0817 samequantum -0 -0 -> 1 samq0818 samequantum -0 -0E+3 -> 0 samq0819 samequantum -0 0E-3 -> 0 samq0820 samequantum -0 0 -> 1 samq0821 samequantum -0 0E+3 -> 0 samq0822 samequantum -0 7E-3 -> 0 samq0823 samequantum -0 7 -> 1 samq0824 samequantum -0 7E+3 -> 0 samq0825 samequantum -0 sNaN -> 0 samq0910 samequantum -0E+3 -Inf -> 0 samq0911 samequantum -0E+3 Inf -> 0 samq0912 samequantum -0E+3 NaN -> 0 samq0913 samequantum -0E+3 -7E+3 -> 1 samq0914 samequantum -0E+3 -7 -> 0 samq0915 samequantum -0E+3 -7E-3 -> 0 samq0916 samequantum -0E+3 -0E-3 -> 0 samq0917 samequantum -0E+3 -0 -> 0 samq0918 samequantum -0E+3 -0E+3 -> 1 samq0919 samequantum -0E+3 0E-3 -> 0 samq0920 samequantum -0E+3 0 -> 0 samq0921 samequantum -0E+3 0E+3 -> 1 samq0922 samequantum -0E+3 7E-3 -> 0 samq0923 samequantum -0E+3 7 -> 0 samq0924 samequantum -0E+3 7E+3 -> 1 samq0925 samequantum -0E+3 sNaN -> 0 samq1110 samequantum 0E-3 -Inf -> 0 samq1111 samequantum 0E-3 Inf -> 0 samq1112 samequantum 0E-3 NaN -> 0 samq1113 samequantum 0E-3 -7E+3 -> 0 samq1114 samequantum 0E-3 -7 -> 0 samq1115 samequantum 0E-3 -7E-3 -> 1 samq1116 samequantum 0E-3 -0E-3 -> 1 samq1117 samequantum 0E-3 -0 -> 0 samq1118 samequantum 0E-3 -0E+3 -> 0 samq1119 samequantum 0E-3 0E-3 -> 1 samq1120 samequantum 0E-3 0 -> 0 samq1121 samequantum 0E-3 0E+3 -> 0 samq1122 samequantum 0E-3 7E-3 -> 1 samq1123 samequantum 0E-3 7 -> 0 samq1124 samequantum 0E-3 7E+3 -> 0 samq1125 samequantum 0E-3 sNaN -> 0 samq1210 samequantum 0 -Inf -> 0 samq1211 samequantum 0 Inf -> 0 samq1212 samequantum 0 NaN -> 0 samq1213 samequantum 0 -7E+3 -> 0 samq1214 samequantum 0 -7 -> 1 samq1215 samequantum 0 -7E-3 -> 0 samq1216 samequantum 0 -0E-3 -> 0 samq1217 samequantum 0 -0 -> 1 samq1218 samequantum 0 -0E+3 -> 0 samq1219 samequantum 0 0E-3 -> 0 samq1220 samequantum 0 0 -> 1 samq1221 samequantum 0 0E+3 -> 0 samq1222 samequantum 0 7E-3 -> 0 samq1223 samequantum 0 7 -> 1 samq1224 samequantum 0 7E+3 -> 0 samq1225 samequantum 0 sNaN -> 0 samq1310 samequantum 0E+3 -Inf -> 0 samq1311 samequantum 0E+3 Inf -> 0 samq1312 samequantum 0E+3 NaN -> 0 samq1313 samequantum 0E+3 -7E+3 -> 1 samq1314 samequantum 0E+3 -7 -> 0 samq1315 samequantum 0E+3 -7E-3 -> 0 samq1316 samequantum 0E+3 -0E-3 -> 0 samq1317 samequantum 0E+3 -0 -> 0 samq1318 samequantum 0E+3 -0E+3 -> 1 samq1319 samequantum 0E+3 0E-3 -> 0 samq1320 samequantum 0E+3 0 -> 0 samq1321 samequantum 0E+3 0E+3 -> 1 samq1322 samequantum 0E+3 7E-3 -> 0 samq1323 samequantum 0E+3 7 -> 0 samq1324 samequantum 0E+3 7E+3 -> 1 samq1325 samequantum 0E+3 sNaN -> 0 samq1410 samequantum 7E-3 -Inf -> 0 samq1411 samequantum 7E-3 Inf -> 0 samq1412 samequantum 7E-3 NaN -> 0 samq1413 samequantum 7E-3 -7E+3 -> 0 samq1414 samequantum 7E-3 -7 -> 0 samq1415 samequantum 7E-3 -7E-3 -> 1 samq1416 samequantum 7E-3 -0E-3 -> 1 samq1417 samequantum 7E-3 -0 -> 0 samq1418 samequantum 7E-3 -0E+3 -> 0 samq1419 samequantum 7E-3 0E-3 -> 1 samq1420 samequantum 7E-3 0 -> 0 samq1421 samequantum 7E-3 0E+3 -> 0 samq1422 samequantum 7E-3 7E-3 -> 1 samq1423 samequantum 7E-3 7 -> 0 samq1424 samequantum 7E-3 7E+3 -> 0 samq1425 samequantum 7E-3 sNaN -> 0 samq1510 samequantum 7 -Inf -> 0 samq1511 samequantum 7 Inf -> 0 samq1512 samequantum 7 NaN -> 0 samq1513 samequantum 7 -7E+3 -> 0 samq1514 samequantum 7 -7 -> 1 samq1515 samequantum 7 -7E-3 -> 0 samq1516 samequantum 7 -0E-3 -> 0 samq1517 samequantum 7 -0 -> 1 samq1518 samequantum 7 -0E+3 -> 0 samq1519 samequantum 7 0E-3 -> 0 samq1520 samequantum 7 0 -> 1 samq1521 samequantum 7 0E+3 -> 0 samq1522 samequantum 7 7E-3 -> 0 samq1523 samequantum 7 7 -> 1 samq1524 samequantum 7 7E+3 -> 0 samq1525 samequantum 7 sNaN -> 0 samq1610 samequantum 7E+3 -Inf -> 0 samq1611 samequantum 7E+3 Inf -> 0 samq1612 samequantum 7E+3 NaN -> 0 samq1613 samequantum 7E+3 -7E+3 -> 1 samq1614 samequantum 7E+3 -7 -> 0 samq1615 samequantum 7E+3 -7E-3 -> 0 samq1616 samequantum 7E+3 -0E-3 -> 0 samq1617 samequantum 7E+3 -0 -> 0 samq1618 samequantum 7E+3 -0E+3 -> 1 samq1619 samequantum 7E+3 0E-3 -> 0 samq1620 samequantum 7E+3 0 -> 0 samq1621 samequantum 7E+3 0E+3 -> 1 samq1622 samequantum 7E+3 7E-3 -> 0 samq1623 samequantum 7E+3 7 -> 0 samq1624 samequantum 7E+3 7E+3 -> 1 samq1625 samequantum 7E+3 sNaN -> 0 samq1710 samequantum sNaN -Inf -> 0 samq1711 samequantum sNaN Inf -> 0 samq1712 samequantum sNaN NaN -> 1 samq1713 samequantum sNaN -7E+3 -> 0 samq1714 samequantum sNaN -7 -> 0 samq1715 samequantum sNaN -7E-3 -> 0 samq1716 samequantum sNaN -0E-3 -> 0 samq1717 samequantum sNaN -0 -> 0 samq1718 samequantum sNaN -0E+3 -> 0 samq1719 samequantum sNaN 0E-3 -> 0 samq1720 samequantum sNaN 0 -> 0 samq1721 samequantum sNaN 0E+3 -> 0 samq1722 samequantum sNaN 7E-3 -> 0 samq1723 samequantum sNaN 7 -> 0 samq1724 samequantum sNaN 7E+3 -> 0 samq1725 samequantum sNaN sNaN -> 1 -- noisy NaNs samq1730 samequantum sNaN3 sNaN3 -> 1 samq1731 samequantum sNaN3 sNaN4 -> 1 samq1732 samequantum NaN3 NaN3 -> 1 samq1733 samequantum NaN3 NaN4 -> 1 samq1734 samequantum sNaN3 3 -> 0 samq1735 samequantum NaN3 3 -> 0 samq1736 samequantum 4 sNaN4 -> 0 samq1737 samequantum 3 NaN3 -> 0 samq1738 samequantum Inf sNaN4 -> 0 samq1739 samequantum -Inf NaN3 -> 0 --- NEW FILE: squareroot.decTest --- ------------------------------------------------------------------------ -- squareroot.decTest -- decimal square root -- -- Copyright (c) IBM Corporation, 2004. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ [...2919 lines suppressed...] sqtx811 squareroot 10E-22 -> 3.16227766017E-11 Underflow Subnormal Inexact Rounded sqtx812 squareroot 1E-22 -> 1E-11 Subnormal -- Exact Subnormal case -- special values maxexponent: 999 minexponent: -999 sqtx820 squareroot Inf -> Infinity sqtx821 squareroot -Inf -> NaN Invalid_operation sqtx822 squareroot NaN -> NaN sqtx823 squareroot sNaN -> NaN Invalid_operation -- propagating NaNs sqtx824 squareroot sNaN123 -> NaN123 Invalid_operation sqtx825 squareroot -sNaN321 -> -NaN321 Invalid_operation sqtx826 squareroot NaN456 -> NaN456 sqtx827 squareroot -NaN654 -> -NaN654 sqtx828 squareroot NaN1 -> NaN1 -- Null test sqtx900 squareroot # -> NaN Invalid_operation --- NEW FILE: subtract.decTest --- ------------------------------------------------------------------------ -- subtract.decTest -- decimal subtraction -- -- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 extended: 1 precision: 9 rounding: half_up maxExponent: 384 minexponent: -383 -- [first group are 'quick confidence check'] subx001 subtract 0 0 -> '0' subx002 subtract 1 1 -> '0' subx003 subtract 1 2 -> '-1' subx004 subtract 2 1 -> '1' subx005 subtract 2 2 -> '0' subx006 subtract 3 2 -> '1' subx007 subtract 2 3 -> '-1' subx011 subtract -0 0 -> '-0' subx012 subtract -1 1 -> '-2' subx013 subtract -1 2 -> '-3' subx014 subtract -2 1 -> '-3' subx015 subtract -2 2 -> '-4' subx016 subtract -3 2 -> '-5' subx017 subtract -2 3 -> '-5' subx021 subtract 0 -0 -> '0' subx022 subtract 1 -1 -> '2' subx023 subtract 1 -2 -> '3' subx024 subtract 2 -1 -> '3' subx025 subtract 2 -2 -> '4' subx026 subtract 3 -2 -> '5' subx027 subtract 2 -3 -> '5' subx030 subtract 11 1 -> 10 subx031 subtract 10 1 -> 9 subx032 subtract 9 1 -> 8 subx033 subtract 1 1 -> 0 subx034 subtract 0 1 -> -1 subx035 subtract -1 1 -> -2 subx036 subtract -9 1 -> -10 subx037 subtract -10 1 -> -11 subx038 subtract -11 1 -> -12 subx040 subtract '5.75' '3.3' -> '2.45' subx041 subtract '5' '-3' -> '8' subx042 subtract '-5' '-3' -> '-2' subx043 subtract '-7' '2.5' -> '-9.5' subx044 subtract '0.7' '0.3' -> '0.4' subx045 subtract '1.3' '0.3' -> '1.0' subx046 subtract '1.25' '1.25' -> '0.00' subx050 subtract '1.23456789' '1.00000000' -> '0.23456789' subx051 subtract '1.23456789' '1.00000089' -> '0.23456700' subx052 subtract '0.5555555559' '0.0000000001' -> '0.555555556' Inexact Rounded subx053 subtract '0.5555555559' '0.0000000005' -> '0.555555555' Inexact Rounded subx054 subtract '0.4444444444' '0.1111111111' -> '0.333333333' Inexact Rounded subx055 subtract '1.0000000000' '0.00000001' -> '0.999999990' Rounded subx056 subtract '0.4444444444999' '0' -> '0.444444444' Inexact Rounded subx057 subtract '0.4444444445000' '0' -> '0.444444445' Inexact Rounded subx060 subtract '70' '10000e+9' -> '-1.00000000E+13' Inexact Rounded subx061 subtract '700' '10000e+9' -> '-1.00000000E+13' Inexact Rounded subx062 subtract '7000' '10000e+9' -> '-9.99999999E+12' Inexact Rounded subx063 subtract '70000' '10000e+9' -> '-9.99999993E+12' Rounded subx064 subtract '700000' '10000e+9' -> '-9.99999930E+12' Rounded -- symmetry: subx065 subtract '10000e+9' '70' -> '1.00000000E+13' Inexact Rounded subx066 subtract '10000e+9' '700' -> '1.00000000E+13' Inexact Rounded subx067 subtract '10000e+9' '7000' -> '9.99999999E+12' Inexact Rounded subx068 subtract '10000e+9' '70000' -> '9.99999993E+12' Rounded subx069 subtract '10000e+9' '700000' -> '9.99999930E+12' Rounded -- change precision subx080 subtract '10000e+9' '70000' -> '9.99999993E+12' Rounded precision: 6 subx081 subtract '10000e+9' '70000' -> '1.00000E+13' Inexact Rounded precision: 9 -- some of the next group are really constructor tests subx090 subtract '00.0' '0.0' -> '0.0' subx091 subtract '00.0' '0.00' -> '0.00' subx092 subtract '0.00' '00.0' -> '0.00' subx093 subtract '00.0' '0.00' -> '0.00' subx094 subtract '0.00' '00.0' -> '0.00' subx095 subtract '3' '.3' -> '2.7' subx096 subtract '3.' '.3' -> '2.7' subx097 subtract '3.0' '.3' -> '2.7' subx098 subtract '3.00' '.3' -> '2.70' subx099 subtract '3' '3' -> '0' subx100 subtract '3' '+3' -> '0' subx101 subtract '3' '-3' -> '6' subx102 subtract '3' '0.3' -> '2.7' subx103 subtract '3.' '0.3' -> '2.7' subx104 subtract '3.0' '0.3' -> '2.7' subx105 subtract '3.00' '0.3' -> '2.70' subx106 subtract '3' '3.0' -> '0.0' subx107 subtract '3' '+3.0' -> '0.0' subx108 subtract '3' '-3.0' -> '6.0' -- the above all from add; massaged and extended. Now some new ones... -- [particularly important for comparisons] -- NB: -xE-8 below were non-exponents pre-ANSI X3-274, and -1E-7 or 0E-7 -- with input rounding. subx120 subtract '10.23456784' '10.23456789' -> '-5E-8' subx121 subtract '10.23456785' '10.23456789' -> '-4E-8' subx122 subtract '10.23456786' '10.23456789' -> '-3E-8' subx123 subtract '10.23456787' '10.23456789' -> '-2E-8' subx124 subtract '10.23456788' '10.23456789' -> '-1E-8' subx125 subtract '10.23456789' '10.23456789' -> '0E-8' subx126 subtract '10.23456790' '10.23456789' -> '1E-8' subx127 subtract '10.23456791' '10.23456789' -> '2E-8' subx128 subtract '10.23456792' '10.23456789' -> '3E-8' subx129 subtract '10.23456793' '10.23456789' -> '4E-8' subx130 subtract '10.23456794' '10.23456789' -> '5E-8' subx131 subtract '10.23456781' '10.23456786' -> '-5E-8' subx132 subtract '10.23456782' '10.23456786' -> '-4E-8' subx133 subtract '10.23456783' '10.23456786' -> '-3E-8' subx134 subtract '10.23456784' '10.23456786' -> '-2E-8' subx135 subtract '10.23456785' '10.23456786' -> '-1E-8' subx136 subtract '10.23456786' '10.23456786' -> '0E-8' subx137 subtract '10.23456787' '10.23456786' -> '1E-8' subx138 subtract '10.23456788' '10.23456786' -> '2E-8' subx139 subtract '10.23456789' '10.23456786' -> '3E-8' subx140 subtract '10.23456790' '10.23456786' -> '4E-8' subx141 subtract '10.23456791' '10.23456786' -> '5E-8' subx142 subtract '1' '0.999999999' -> '1E-9' subx143 subtract '0.999999999' '1' -> '-1E-9' subx144 subtract '-10.23456780' '-10.23456786' -> '6E-8' subx145 subtract '-10.23456790' '-10.23456786' -> '-4E-8' subx146 subtract '-10.23456791' '-10.23456786' -> '-5E-8' precision: 3 subx150 subtract '12345678900000' '9999999999999' -> 2.35E+12 Inexact Rounded subx151 subtract '9999999999999' '12345678900000' -> -2.35E+12 Inexact Rounded precision: 6 subx152 subtract '12345678900000' '9999999999999' -> 2.34568E+12 Inexact Rounded subx153 subtract '9999999999999' '12345678900000' -> -2.34568E+12 Inexact Rounded precision: 9 subx154 subtract '12345678900000' '9999999999999' -> 2.34567890E+12 Inexact Rounded subx155 subtract '9999999999999' '12345678900000' -> -2.34567890E+12 Inexact Rounded precision: 12 subx156 subtract '12345678900000' '9999999999999' -> 2.34567890000E+12 Inexact Rounded subx157 subtract '9999999999999' '12345678900000' -> -2.34567890000E+12 Inexact Rounded precision: 15 subx158 subtract '12345678900000' '9999999999999' -> 2345678900001 subx159 subtract '9999999999999' '12345678900000' -> -2345678900001 precision: 9 -- additional scaled arithmetic tests [0.97 problem] subx160 subtract '0' '.1' -> '-0.1' subx161 subtract '00' '.97983' -> '-0.97983' subx162 subtract '0' '.9' -> '-0.9' subx163 subtract '0' '0.102' -> '-0.102' subx164 subtract '0' '.4' -> '-0.4' subx165 subtract '0' '.307' -> '-0.307' subx166 subtract '0' '.43822' -> '-0.43822' subx167 subtract '0' '.911' -> '-0.911' subx168 subtract '.0' '.02' -> '-0.02' subx169 subtract '00' '.392' -> '-0.392' subx170 subtract '0' '.26' -> '-0.26' subx171 subtract '0' '0.51' -> '-0.51' subx172 subtract '0' '.2234' -> '-0.2234' subx173 subtract '0' '.2' -> '-0.2' subx174 subtract '.0' '.0008' -> '-0.0008' -- 0. on left subx180 subtract '0.0' '-.1' -> '0.1' subx181 subtract '0.00' '-.97983' -> '0.97983' subx182 subtract '0.0' '-.9' -> '0.9' subx183 subtract '0.0' '-0.102' -> '0.102' subx184 subtract '0.0' '-.4' -> '0.4' subx185 subtract '0.0' '-.307' -> '0.307' subx186 subtract '0.0' '-.43822' -> '0.43822' subx187 subtract '0.0' '-.911' -> '0.911' subx188 subtract '0.0' '-.02' -> '0.02' subx189 subtract '0.00' '-.392' -> '0.392' subx190 subtract '0.0' '-.26' -> '0.26' subx191 subtract '0.0' '-0.51' -> '0.51' subx192 subtract '0.0' '-.2234' -> '0.2234' subx193 subtract '0.0' '-.2' -> '0.2' subx194 subtract '0.0' '-.0008' -> '0.0008' -- negatives of same subx200 subtract '0' '-.1' -> '0.1' subx201 subtract '00' '-.97983' -> '0.97983' subx202 subtract '0' '-.9' -> '0.9' subx203 subtract '0' '-0.102' -> '0.102' subx204 subtract '0' '-.4' -> '0.4' subx205 subtract '0' '-.307' -> '0.307' subx206 subtract '0' '-.43822' -> '0.43822' subx207 subtract '0' '-.911' -> '0.911' subx208 subtract '.0' '-.02' -> '0.02' subx209 subtract '00' '-.392' -> '0.392' subx210 subtract '0' '-.26' -> '0.26' subx211 subtract '0' '-0.51' -> '0.51' subx212 subtract '0' '-.2234' -> '0.2234' subx213 subtract '0' '-.2' -> '0.2' subx214 subtract '.0' '-.0008' -> '0.0008' -- more fixed, LHS swaps [really the same as testcases under add] subx220 subtract '-56267E-12' 0 -> '-5.6267E-8' subx221 subtract '-56267E-11' 0 -> '-5.6267E-7' subx222 subtract '-56267E-10' 0 -> '-0.0000056267' subx223 subtract '-56267E-9' 0 -> '-0.000056267' subx224 subtract '-56267E-8' 0 -> '-0.00056267' subx225 subtract '-56267E-7' 0 -> '-0.0056267' subx226 subtract '-56267E-6' 0 -> '-0.056267' subx227 subtract '-56267E-5' 0 -> '-0.56267' subx228 subtract '-56267E-2' 0 -> '-562.67' subx229 subtract '-56267E-1' 0 -> '-5626.7' subx230 subtract '-56267E-0' 0 -> '-56267' -- symmetry ... subx240 subtract 0 '-56267E-12' -> '5.6267E-8' subx241 subtract 0 '-56267E-11' -> '5.6267E-7' subx242 subtract 0 '-56267E-10' -> '0.0000056267' subx243 subtract 0 '-56267E-9' -> '0.000056267' subx244 subtract 0 '-56267E-8' -> '0.00056267' subx245 subtract 0 '-56267E-7' -> '0.0056267' subx246 subtract 0 '-56267E-6' -> '0.056267' subx247 subtract 0 '-56267E-5' -> '0.56267' subx248 subtract 0 '-56267E-2' -> '562.67' subx249 subtract 0 '-56267E-1' -> '5626.7' subx250 subtract 0 '-56267E-0' -> '56267' -- now some more from the 'new' add precision: 9 subx301 subtract '1.23456789' '1.00000000' -> '0.23456789' subx302 subtract '1.23456789' '1.00000011' -> '0.23456778' subx311 subtract '0.4444444444' '0.5555555555' -> '-0.111111111' Inexact Rounded subx312 subtract '0.4444444440' '0.5555555555' -> '-0.111111112' Inexact Rounded subx313 subtract '0.4444444444' '0.5555555550' -> '-0.111111111' Inexact Rounded subx314 subtract '0.44444444449' '0' -> '0.444444444' Inexact Rounded subx315 subtract '0.444444444499' '0' -> '0.444444444' Inexact Rounded subx316 subtract '0.4444444444999' '0' -> '0.444444444' Inexact Rounded subx317 subtract '0.4444444445000' '0' -> '0.444444445' Inexact Rounded subx318 subtract '0.4444444445001' '0' -> '0.444444445' Inexact Rounded subx319 subtract '0.444444444501' '0' -> '0.444444445' Inexact Rounded subx320 subtract '0.44444444451' '0' -> '0.444444445' Inexact Rounded -- some carrying effects subx321 subtract '0.9998' '0.0000' -> '0.9998' subx322 subtract '0.9998' '0.0001' -> '0.9997' subx323 subtract '0.9998' '0.0002' -> '0.9996' subx324 subtract '0.9998' '0.0003' -> '0.9995' subx325 subtract '0.9998' '-0.0000' -> '0.9998' subx326 subtract '0.9998' '-0.0001' -> '0.9999' subx327 subtract '0.9998' '-0.0002' -> '1.0000' subx328 subtract '0.9998' '-0.0003' -> '1.0001' subx330 subtract '70' '10000e+9' -> '-1.00000000E+13' Inexact Rounded subx331 subtract '700' '10000e+9' -> '-1.00000000E+13' Inexact Rounded subx332 subtract '7000' '10000e+9' -> '-9.99999999E+12' Inexact Rounded subx333 subtract '70000' '10000e+9' -> '-9.99999993E+12' Rounded subx334 subtract '700000' '10000e+9' -> '-9.99999930E+12' Rounded subx335 subtract '7000000' '10000e+9' -> '-9.99999300E+12' Rounded -- symmetry: subx340 subtract '10000e+9' '70' -> '1.00000000E+13' Inexact Rounded subx341 subtract '10000e+9' '700' -> '1.00000000E+13' Inexact Rounded subx342 subtract '10000e+9' '7000' -> '9.99999999E+12' Inexact Rounded subx343 subtract '10000e+9' '70000' -> '9.99999993E+12' Rounded subx344 subtract '10000e+9' '700000' -> '9.99999930E+12' Rounded subx345 subtract '10000e+9' '7000000' -> '9.99999300E+12' Rounded -- same, higher precision precision: 15 subx346 subtract '10000e+9' '7' -> '9999999999993' subx347 subtract '10000e+9' '70' -> '9999999999930' subx348 subtract '10000e+9' '700' -> '9999999999300' subx349 subtract '10000e+9' '7000' -> '9999999993000' subx350 subtract '10000e+9' '70000' -> '9999999930000' subx351 subtract '10000e+9' '700000' -> '9999999300000' subx352 subtract '7' '10000e+9' -> '-9999999999993' subx353 subtract '70' '10000e+9' -> '-9999999999930' subx354 subtract '700' '10000e+9' -> '-9999999999300' subx355 subtract '7000' '10000e+9' -> '-9999999993000' subx356 subtract '70000' '10000e+9' -> '-9999999930000' subx357 subtract '700000' '10000e+9' -> '-9999999300000' -- zero preservation precision: 6 subx360 subtract '10000e+9' '70000' -> '1.00000E+13' Inexact Rounded subx361 subtract 1 '0.0001' -> '0.9999' subx362 subtract 1 '0.00001' -> '0.99999' subx363 subtract 1 '0.000001' -> '0.999999' subx364 subtract 1 '0.0000001' -> '1.00000' Inexact Rounded subx365 subtract 1 '0.00000001' -> '1.00000' Inexact Rounded -- some funny zeros [in case of bad signum] subx370 subtract 1 0 -> 1 subx371 subtract 1 0. -> 1 subx372 subtract 1 .0 -> 1.0 subx373 subtract 1 0.0 -> 1.0 subx374 subtract 0 1 -> -1 subx375 subtract 0. 1 -> -1 subx376 subtract .0 1 -> -1.0 subx377 subtract 0.0 1 -> -1.0 precision: 9 -- leading 0 digit before round subx910 subtract -103519362 -51897955.3 -> -51621406.7 subx911 subtract 159579.444 89827.5229 -> 69751.9211 subx920 subtract 333.123456 33.1234566 -> 299.999999 Inexact Rounded subx921 subtract 333.123456 33.1234565 -> 300.000000 Inexact Rounded subx922 subtract 133.123456 33.1234565 -> 99.9999995 subx923 subtract 133.123456 33.1234564 -> 99.9999996 subx924 subtract 133.123456 33.1234540 -> 100.000002 Rounded subx925 subtract 133.123456 43.1234560 -> 90.0000000 subx926 subtract 133.123456 43.1234561 -> 89.9999999 subx927 subtract 133.123456 43.1234566 -> 89.9999994 subx928 subtract 101.123456 91.1234566 -> 9.9999994 subx929 subtract 101.123456 99.1234566 -> 1.9999994 -- more of the same; probe for cluster boundary problems precision: 1 subx930 subtract 11 2 -> 9 precision: 2 subx932 subtract 101 2 -> 99 precision: 3 subx934 subtract 101 2.1 -> 98.9 subx935 subtract 101 92.01 -> 8.99 precision: 4 subx936 subtract 101 2.01 -> 98.99 subx937 subtract 101 92.01 -> 8.99 subx938 subtract 101 92.006 -> 8.994 precision: 5 subx939 subtract 101 2.001 -> 98.999 subx940 subtract 101 92.001 -> 8.999 subx941 subtract 101 92.0006 -> 8.9994 precision: 6 subx942 subtract 101 2.0001 -> 98.9999 subx943 subtract 101 92.0001 -> 8.9999 subx944 subtract 101 92.00006 -> 8.99994 precision: 7 subx945 subtract 101 2.00001 -> 98.99999 subx946 subtract 101 92.00001 -> 8.99999 subx947 subtract 101 92.000006 -> 8.999994 precision: 8 subx948 subtract 101 2.000001 -> 98.999999 subx949 subtract 101 92.000001 -> 8.999999 subx950 subtract 101 92.0000006 -> 8.9999994 precision: 9 subx951 subtract 101 2.0000001 -> 98.9999999 subx952 subtract 101 92.0000001 -> 8.9999999 subx953 subtract 101 92.00000006 -> 8.99999994 precision: 9 -- more LHS swaps [were fixed] subx390 subtract '-56267E-10' 0 -> '-0.0000056267' subx391 subtract '-56267E-6' 0 -> '-0.056267' subx392 subtract '-56267E-5' 0 -> '-0.56267' subx393 subtract '-56267E-4' 0 -> '-5.6267' subx394 subtract '-56267E-3' 0 -> '-56.267' subx395 subtract '-56267E-2' 0 -> '-562.67' subx396 subtract '-56267E-1' 0 -> '-5626.7' subx397 subtract '-56267E-0' 0 -> '-56267' subx398 subtract '-5E-10' 0 -> '-5E-10' subx399 subtract '-5E-7' 0 -> '-5E-7' subx400 subtract '-5E-6' 0 -> '-0.000005' subx401 subtract '-5E-5' 0 -> '-0.00005' subx402 subtract '-5E-4' 0 -> '-0.0005' subx403 subtract '-5E-1' 0 -> '-0.5' subx404 subtract '-5E0' 0 -> '-5' subx405 subtract '-5E1' 0 -> '-50' subx406 subtract '-5E5' 0 -> '-500000' subx407 subtract '-5E8' 0 -> '-500000000' subx408 subtract '-5E9' 0 -> '-5.00000000E+9' Rounded subx409 subtract '-5E10' 0 -> '-5.00000000E+10' Rounded subx410 subtract '-5E11' 0 -> '-5.00000000E+11' Rounded subx411 subtract '-5E100' 0 -> '-5.00000000E+100' Rounded -- more RHS swaps [were fixed] subx420 subtract 0 '-56267E-10' -> '0.0000056267' subx421 subtract 0 '-56267E-6' -> '0.056267' subx422 subtract 0 '-56267E-5' -> '0.56267' subx423 subtract 0 '-56267E-4' -> '5.6267' subx424 subtract 0 '-56267E-3' -> '56.267' subx425 subtract 0 '-56267E-2' -> '562.67' subx426 subtract 0 '-56267E-1' -> '5626.7' subx427 subtract 0 '-56267E-0' -> '56267' subx428 subtract 0 '-5E-10' -> '5E-10' subx429 subtract 0 '-5E-7' -> '5E-7' subx430 subtract 0 '-5E-6' -> '0.000005' subx431 subtract 0 '-5E-5' -> '0.00005' subx432 subtract 0 '-5E-4' -> '0.0005' subx433 subtract 0 '-5E-1' -> '0.5' subx434 subtract 0 '-5E0' -> '5' subx435 subtract 0 '-5E1' -> '50' subx436 subtract 0 '-5E5' -> '500000' subx437 subtract 0 '-5E8' -> '500000000' subx438 subtract 0 '-5E9' -> '5.00000000E+9' Rounded subx439 subtract 0 '-5E10' -> '5.00000000E+10' Rounded subx440 subtract 0 '-5E11' -> '5.00000000E+11' Rounded subx441 subtract 0 '-5E100' -> '5.00000000E+100' Rounded -- try borderline precision, with carries, etc. precision: 15 subx461 subtract '1E+12' '1' -> '999999999999' subx462 subtract '1E+12' '-1.11' -> '1000000000001.11' subx463 subtract '1.11' '-1E+12' -> '1000000000001.11' subx464 subtract '-1' '-1E+12' -> '999999999999' subx465 subtract '7E+12' '1' -> '6999999999999' subx466 subtract '7E+12' '-1.11' -> '7000000000001.11' subx467 subtract '1.11' '-7E+12' -> '7000000000001.11' subx468 subtract '-1' '-7E+12' -> '6999999999999' -- 123456789012345 123456789012345 1 23456789012345 subx470 subtract '0.444444444444444' '-0.555555555555563' -> '1.00000000000001' Inexact Rounded subx471 subtract '0.444444444444444' '-0.555555555555562' -> '1.00000000000001' Inexact Rounded subx472 subtract '0.444444444444444' '-0.555555555555561' -> '1.00000000000001' Inexact Rounded subx473 subtract '0.444444444444444' '-0.555555555555560' -> '1.00000000000000' Inexact Rounded subx474 subtract '0.444444444444444' '-0.555555555555559' -> '1.00000000000000' Inexact Rounded subx475 subtract '0.444444444444444' '-0.555555555555558' -> '1.00000000000000' Inexact Rounded subx476 subtract '0.444444444444444' '-0.555555555555557' -> '1.00000000000000' Inexact Rounded subx477 subtract '0.444444444444444' '-0.555555555555556' -> '1.00000000000000' Rounded subx478 subtract '0.444444444444444' '-0.555555555555555' -> '0.999999999999999' subx479 subtract '0.444444444444444' '-0.555555555555554' -> '0.999999999999998' subx480 subtract '0.444444444444444' '-0.555555555555553' -> '0.999999999999997' subx481 subtract '0.444444444444444' '-0.555555555555552' -> '0.999999999999996' subx482 subtract '0.444444444444444' '-0.555555555555551' -> '0.999999999999995' subx483 subtract '0.444444444444444' '-0.555555555555550' -> '0.999999999999994' -- and some more, including residue effects and different roundings precision: 9 rounding: half_up subx500 subtract '123456789' 0 -> '123456789' subx501 subtract '123456789' 0.000000001 -> '123456789' Inexact Rounded subx502 subtract '123456789' 0.000001 -> '123456789' Inexact Rounded subx503 subtract '123456789' 0.1 -> '123456789' Inexact Rounded subx504 subtract '123456789' 0.4 -> '123456789' Inexact Rounded subx505 subtract '123456789' 0.49 -> '123456789' Inexact Rounded subx506 subtract '123456789' 0.499999 -> '123456789' Inexact Rounded subx507 subtract '123456789' 0.499999999 -> '123456789' Inexact Rounded subx508 subtract '123456789' 0.5 -> '123456789' Inexact Rounded subx509 subtract '123456789' 0.500000001 -> '123456788' Inexact Rounded subx510 subtract '123456789' 0.500001 -> '123456788' Inexact Rounded subx511 subtract '123456789' 0.51 -> '123456788' Inexact Rounded subx512 subtract '123456789' 0.6 -> '123456788' Inexact Rounded subx513 subtract '123456789' 0.9 -> '123456788' Inexact Rounded subx514 subtract '123456789' 0.99999 -> '123456788' Inexact Rounded subx515 subtract '123456789' 0.999999999 -> '123456788' Inexact Rounded subx516 subtract '123456789' 1 -> '123456788' subx517 subtract '123456789' 1.000000001 -> '123456788' Inexact Rounded subx518 subtract '123456789' 1.00001 -> '123456788' Inexact Rounded subx519 subtract '123456789' 1.1 -> '123456788' Inexact Rounded rounding: half_even subx520 subtract '123456789' 0 -> '123456789' subx521 subtract '123456789' 0.000000001 -> '123456789' Inexact Rounded subx522 subtract '123456789' 0.000001 -> '123456789' Inexact Rounded subx523 subtract '123456789' 0.1 -> '123456789' Inexact Rounded subx524 subtract '123456789' 0.4 -> '123456789' Inexact Rounded subx525 subtract '123456789' 0.49 -> '123456789' Inexact Rounded subx526 subtract '123456789' 0.499999 -> '123456789' Inexact Rounded subx527 subtract '123456789' 0.499999999 -> '123456789' Inexact Rounded subx528 subtract '123456789' 0.5 -> '123456788' Inexact Rounded subx529 subtract '123456789' 0.500000001 -> '123456788' Inexact Rounded subx530 subtract '123456789' 0.500001 -> '123456788' Inexact Rounded subx531 subtract '123456789' 0.51 -> '123456788' Inexact Rounded subx532 subtract '123456789' 0.6 -> '123456788' Inexact Rounded subx533 subtract '123456789' 0.9 -> '123456788' Inexact Rounded subx534 subtract '123456789' 0.99999 -> '123456788' Inexact Rounded subx535 subtract '123456789' 0.999999999 -> '123456788' Inexact Rounded subx536 subtract '123456789' 1 -> '123456788' subx537 subtract '123456789' 1.00000001 -> '123456788' Inexact Rounded subx538 subtract '123456789' 1.00001 -> '123456788' Inexact Rounded subx539 subtract '123456789' 1.1 -> '123456788' Inexact Rounded -- critical few with even bottom digit... subx540 subtract '123456788' 0.499999999 -> '123456788' Inexact Rounded subx541 subtract '123456788' 0.5 -> '123456788' Inexact Rounded subx542 subtract '123456788' 0.500000001 -> '123456787' Inexact Rounded rounding: down subx550 subtract '123456789' 0 -> '123456789' subx551 subtract '123456789' 0.000000001 -> '123456788' Inexact Rounded subx552 subtract '123456789' 0.000001 -> '123456788' Inexact Rounded subx553 subtract '123456789' 0.1 -> '123456788' Inexact Rounded subx554 subtract '123456789' 0.4 -> '123456788' Inexact Rounded subx555 subtract '123456789' 0.49 -> '123456788' Inexact Rounded subx556 subtract '123456789' 0.499999 -> '123456788' Inexact Rounded subx557 subtract '123456789' 0.499999999 -> '123456788' Inexact Rounded subx558 subtract '123456789' 0.5 -> '123456788' Inexact Rounded subx559 subtract '123456789' 0.500000001 -> '123456788' Inexact Rounded subx560 subtract '123456789' 0.500001 -> '123456788' Inexact Rounded subx561 subtract '123456789' 0.51 -> '123456788' Inexact Rounded subx562 subtract '123456789' 0.6 -> '123456788' Inexact Rounded subx563 subtract '123456789' 0.9 -> '123456788' Inexact Rounded subx564 subtract '123456789' 0.99999 -> '123456788' Inexact Rounded subx565 subtract '123456789' 0.999999999 -> '123456788' Inexact Rounded subx566 subtract '123456789' 1 -> '123456788' subx567 subtract '123456789' 1.00000001 -> '123456787' Inexact Rounded subx568 subtract '123456789' 1.00001 -> '123456787' Inexact Rounded subx569 subtract '123456789' 1.1 -> '123456787' Inexact Rounded -- symmetry... rounding: half_up subx600 subtract 0 '123456789' -> '-123456789' subx601 subtract 0.000000001 '123456789' -> '-123456789' Inexact Rounded subx602 subtract 0.000001 '123456789' -> '-123456789' Inexact Rounded subx603 subtract 0.1 '123456789' -> '-123456789' Inexact Rounded subx604 subtract 0.4 '123456789' -> '-123456789' Inexact Rounded subx605 subtract 0.49 '123456789' -> '-123456789' Inexact Rounded subx606 subtract 0.499999 '123456789' -> '-123456789' Inexact Rounded subx607 subtract 0.499999999 '123456789' -> '-123456789' Inexact Rounded subx608 subtract 0.5 '123456789' -> '-123456789' Inexact Rounded subx609 subtract 0.500000001 '123456789' -> '-123456788' Inexact Rounded subx610 subtract 0.500001 '123456789' -> '-123456788' Inexact Rounded subx611 subtract 0.51 '123456789' -> '-123456788' Inexact Rounded subx612 subtract 0.6 '123456789' -> '-123456788' Inexact Rounded subx613 subtract 0.9 '123456789' -> '-123456788' Inexact Rounded subx614 subtract 0.99999 '123456789' -> '-123456788' Inexact Rounded subx615 subtract 0.999999999 '123456789' -> '-123456788' Inexact Rounded subx616 subtract 1 '123456789' -> '-123456788' subx617 subtract 1.000000001 '123456789' -> '-123456788' Inexact Rounded subx618 subtract 1.00001 '123456789' -> '-123456788' Inexact Rounded subx619 subtract 1.1 '123456789' -> '-123456788' Inexact Rounded rounding: half_even subx620 subtract 0 '123456789' -> '-123456789' subx621 subtract 0.000000001 '123456789' -> '-123456789' Inexact Rounded subx622 subtract 0.000001 '123456789' -> '-123456789' Inexact Rounded subx623 subtract 0.1 '123456789' -> '-123456789' Inexact Rounded subx624 subtract 0.4 '123456789' -> '-123456789' Inexact Rounded subx625 subtract 0.49 '123456789' -> '-123456789' Inexact Rounded subx626 subtract 0.499999 '123456789' -> '-123456789' Inexact Rounded subx627 subtract 0.499999999 '123456789' -> '-123456789' Inexact Rounded subx628 subtract 0.5 '123456789' -> '-123456788' Inexact Rounded subx629 subtract 0.500000001 '123456789' -> '-123456788' Inexact Rounded subx630 subtract 0.500001 '123456789' -> '-123456788' Inexact Rounded subx631 subtract 0.51 '123456789' -> '-123456788' Inexact Rounded subx632 subtract 0.6 '123456789' -> '-123456788' Inexact Rounded subx633 subtract 0.9 '123456789' -> '-123456788' Inexact Rounded subx634 subtract 0.99999 '123456789' -> '-123456788' Inexact Rounded subx635 subtract 0.999999999 '123456789' -> '-123456788' Inexact Rounded subx636 subtract 1 '123456789' -> '-123456788' subx637 subtract 1.00000001 '123456789' -> '-123456788' Inexact Rounded subx638 subtract 1.00001 '123456789' -> '-123456788' Inexact Rounded subx639 subtract 1.1 '123456789' -> '-123456788' Inexact Rounded -- critical few with even bottom digit... subx640 subtract 0.499999999 '123456788' -> '-123456788' Inexact Rounded subx641 subtract 0.5 '123456788' -> '-123456788' Inexact Rounded subx642 subtract 0.500000001 '123456788' -> '-123456787' Inexact Rounded rounding: down subx650 subtract 0 '123456789' -> '-123456789' subx651 subtract 0.000000001 '123456789' -> '-123456788' Inexact Rounded subx652 subtract 0.000001 '123456789' -> '-123456788' Inexact Rounded subx653 subtract 0.1 '123456789' -> '-123456788' Inexact Rounded subx654 subtract 0.4 '123456789' -> '-123456788' Inexact Rounded subx655 subtract 0.49 '123456789' -> '-123456788' Inexact Rounded subx656 subtract 0.499999 '123456789' -> '-123456788' Inexact Rounded subx657 subtract 0.499999999 '123456789' -> '-123456788' Inexact Rounded subx658 subtract 0.5 '123456789' -> '-123456788' Inexact Rounded subx659 subtract 0.500000001 '123456789' -> '-123456788' Inexact Rounded subx660 subtract 0.500001 '123456789' -> '-123456788' Inexact Rounded subx661 subtract 0.51 '123456789' -> '-123456788' Inexact Rounded subx662 subtract 0.6 '123456789' -> '-123456788' Inexact Rounded subx663 subtract 0.9 '123456789' -> '-123456788' Inexact Rounded subx664 subtract 0.99999 '123456789' -> '-123456788' Inexact Rounded subx665 subtract 0.999999999 '123456789' -> '-123456788' Inexact Rounded subx666 subtract 1 '123456789' -> '-123456788' subx667 subtract 1.00000001 '123456789' -> '-123456787' Inexact Rounded subx668 subtract 1.00001 '123456789' -> '-123456787' Inexact Rounded subx669 subtract 1.1 '123456789' -> '-123456787' Inexact Rounded -- lots of leading zeros in intermediate result, and showing effects of -- input rounding would have affected the following precision: 9 rounding: half_up subx670 subtract '123456789' '123456788.1' -> 0.9 subx671 subtract '123456789' '123456788.9' -> 0.1 subx672 subtract '123456789' '123456789.1' -> -0.1 subx673 subtract '123456789' '123456789.5' -> -0.5 subx674 subtract '123456789' '123456789.9' -> -0.9 rounding: half_even subx680 subtract '123456789' '123456788.1' -> 0.9 subx681 subtract '123456789' '123456788.9' -> 0.1 subx682 subtract '123456789' '123456789.1' -> -0.1 subx683 subtract '123456789' '123456789.5' -> -0.5 subx684 subtract '123456789' '123456789.9' -> -0.9 subx685 subtract '123456788' '123456787.1' -> 0.9 subx686 subtract '123456788' '123456787.9' -> 0.1 subx687 subtract '123456788' '123456788.1' -> -0.1 subx688 subtract '123456788' '123456788.5' -> -0.5 subx689 subtract '123456788' '123456788.9' -> -0.9 rounding: down subx690 subtract '123456789' '123456788.1' -> 0.9 subx691 subtract '123456789' '123456788.9' -> 0.1 subx692 subtract '123456789' '123456789.1' -> -0.1 subx693 subtract '123456789' '123456789.5' -> -0.5 subx694 subtract '123456789' '123456789.9' -> -0.9 -- input preparation tests rounding: half_up precision: 3 subx700 subtract '12345678900000' -9999999999999 -> '2.23E+13' Inexact Rounded subx701 subtract '9999999999999' -12345678900000 -> '2.23E+13' Inexact Rounded subx702 subtract '12E+3' '-3456' -> '1.55E+4' Inexact Rounded subx703 subtract '12E+3' '-3446' -> '1.54E+4' Inexact Rounded subx704 subtract '12E+3' '-3454' -> '1.55E+4' Inexact Rounded subx705 subtract '12E+3' '-3444' -> '1.54E+4' Inexact Rounded subx706 subtract '3456' '-12E+3' -> '1.55E+4' Inexact Rounded subx707 subtract '3446' '-12E+3' -> '1.54E+4' Inexact Rounded subx708 subtract '3454' '-12E+3' -> '1.55E+4' Inexact Rounded subx709 subtract '3444' '-12E+3' -> '1.54E+4' Inexact Rounded -- overflow and underflow tests [subnormals now possible] maxexponent: 999999999 minexponent: -999999999 precision: 9 rounding: down subx710 subtract 1E+999999999 -9E+999999999 -> 9.99999999E+999999999 Overflow Inexact Rounded subx711 subtract 9E+999999999 -1E+999999999 -> 9.99999999E+999999999 Overflow Inexact Rounded rounding: half_up subx712 subtract 1E+999999999 -9E+999999999 -> Infinity Overflow Inexact Rounded subx713 subtract 9E+999999999 -1E+999999999 -> Infinity Overflow Inexact Rounded subx714 subtract -1.1E-999999999 -1E-999999999 -> -1E-1000000000 Subnormal subx715 subtract 1E-999999999 +1.1e-999999999 -> -1E-1000000000 Subnormal subx716 subtract -1E+999999999 +9E+999999999 -> -Infinity Overflow Inexact Rounded subx717 subtract -9E+999999999 +1E+999999999 -> -Infinity Overflow Inexact Rounded subx718 subtract +1.1E-999999999 +1E-999999999 -> 1E-1000000000 Subnormal subx719 subtract -1E-999999999 -1.1e-999999999 -> 1E-1000000000 Subnormal precision: 3 subx720 subtract 1 9.999E+999999999 -> -Infinity Inexact Overflow Rounded subx721 subtract 1 -9.999E+999999999 -> Infinity Inexact Overflow Rounded subx722 subtract 9.999E+999999999 1 -> Infinity Inexact Overflow Rounded subx723 subtract -9.999E+999999999 1 -> -Infinity Inexact Overflow Rounded subx724 subtract 1 9.999E+999999999 -> -Infinity Inexact Overflow Rounded subx725 subtract 1 -9.999E+999999999 -> Infinity Inexact Overflow Rounded subx726 subtract 9.999E+999999999 1 -> Infinity Inexact Overflow Rounded subx727 subtract -9.999E+999999999 1 -> -Infinity Inexact Overflow Rounded -- [more below] -- long operand checks maxexponent: 999 minexponent: -999 precision: 9 sub731 subtract 12345678000 0 -> 1.23456780E+10 Rounded sub732 subtract 0 12345678000 -> -1.23456780E+10 Rounded sub733 subtract 1234567800 0 -> 1.23456780E+9 Rounded sub734 subtract 0 1234567800 -> -1.23456780E+9 Rounded sub735 subtract 1234567890 0 -> 1.23456789E+9 Rounded sub736 subtract 0 1234567890 -> -1.23456789E+9 Rounded sub737 subtract 1234567891 0 -> 1.23456789E+9 Inexact Rounded sub738 subtract 0 1234567891 -> -1.23456789E+9 Inexact Rounded sub739 subtract 12345678901 0 -> 1.23456789E+10 Inexact Rounded sub740 subtract 0 12345678901 -> -1.23456789E+10 Inexact Rounded sub741 subtract 1234567896 0 -> 1.23456790E+9 Inexact Rounded sub742 subtract 0 1234567896 -> -1.23456790E+9 Inexact Rounded precision: 15 sub751 subtract 12345678000 0 -> 12345678000 sub752 subtract 0 12345678000 -> -12345678000 sub753 subtract 1234567800 0 -> 1234567800 sub754 subtract 0 1234567800 -> -1234567800 sub755 subtract 1234567890 0 -> 1234567890 sub756 subtract 0 1234567890 -> -1234567890 sub757 subtract 1234567891 0 -> 1234567891 sub758 subtract 0 1234567891 -> -1234567891 sub759 subtract 12345678901 0 -> 12345678901 sub760 subtract 0 12345678901 -> -12345678901 sub761 subtract 1234567896 0 -> 1234567896 sub762 subtract 0 1234567896 -> -1234567896 -- Specials subx780 subtract -Inf Inf -> -Infinity subx781 subtract -Inf 1000 -> -Infinity subx782 subtract -Inf 1 -> -Infinity subx783 subtract -Inf -0 -> -Infinity subx784 subtract -Inf -1 -> -Infinity subx785 subtract -Inf -1000 -> -Infinity subx787 subtract -1000 Inf -> -Infinity subx788 subtract -Inf Inf -> -Infinity subx789 subtract -1 Inf -> -Infinity subx790 subtract 0 Inf -> -Infinity subx791 subtract 1 Inf -> -Infinity subx792 subtract 1000 Inf -> -Infinity subx800 subtract Inf Inf -> NaN Invalid_operation subx801 subtract Inf 1000 -> Infinity subx802 subtract Inf 1 -> Infinity subx803 subtract Inf 0 -> Infinity subx804 subtract Inf -0 -> Infinity subx805 subtract Inf -1 -> Infinity subx806 subtract Inf -1000 -> Infinity subx807 subtract Inf -Inf -> Infinity subx808 subtract -1000 -Inf -> Infinity subx809 subtract -Inf -Inf -> NaN Invalid_operation subx810 subtract -1 -Inf -> Infinity subx811 subtract -0 -Inf -> Infinity subx812 subtract 0 -Inf -> Infinity subx813 subtract 1 -Inf -> Infinity subx814 subtract 1000 -Inf -> Infinity subx815 subtract Inf -Inf -> Infinity subx821 subtract NaN Inf -> NaN subx822 subtract -NaN 1000 -> -NaN subx823 subtract NaN 1 -> NaN subx824 subtract NaN 0 -> NaN subx825 subtract NaN -0 -> NaN subx826 subtract NaN -1 -> NaN subx827 subtract NaN -1000 -> NaN subx828 subtract NaN -Inf -> NaN subx829 subtract -NaN NaN -> -NaN subx830 subtract -Inf NaN -> NaN subx831 subtract -1000 NaN -> NaN subx832 subtract -1 NaN -> NaN subx833 subtract -0 NaN -> NaN subx834 subtract 0 NaN -> NaN subx835 subtract 1 NaN -> NaN subx836 subtract 1000 -NaN -> -NaN subx837 subtract Inf NaN -> NaN subx841 subtract sNaN Inf -> NaN Invalid_operation subx842 subtract -sNaN 1000 -> -NaN Invalid_operation subx843 subtract sNaN 1 -> NaN Invalid_operation subx844 subtract sNaN 0 -> NaN Invalid_operation subx845 subtract sNaN -0 -> NaN Invalid_operation subx846 subtract sNaN -1 -> NaN Invalid_operation subx847 subtract sNaN -1000 -> NaN Invalid_operation subx848 subtract sNaN NaN -> NaN Invalid_operation subx849 subtract sNaN sNaN -> NaN Invalid_operation subx850 subtract NaN sNaN -> NaN Invalid_operation subx851 subtract -Inf -sNaN -> -NaN Invalid_operation subx852 subtract -1000 sNaN -> NaN Invalid_operation subx853 subtract -1 sNaN -> NaN Invalid_operation subx854 subtract -0 sNaN -> NaN Invalid_operation subx855 subtract 0 sNaN -> NaN Invalid_operation subx856 subtract 1 sNaN -> NaN Invalid_operation subx857 subtract 1000 sNaN -> NaN Invalid_operation subx858 subtract Inf sNaN -> NaN Invalid_operation subx859 subtract NaN sNaN -> NaN Invalid_operation -- propagating NaNs subx861 subtract NaN01 -Inf -> NaN1 subx862 subtract -NaN02 -1000 -> -NaN2 subx863 subtract NaN03 1000 -> NaN3 subx864 subtract NaN04 Inf -> NaN4 subx865 subtract NaN05 NaN61 -> NaN5 subx866 subtract -Inf -NaN71 -> -NaN71 subx867 subtract -1000 NaN81 -> NaN81 subx868 subtract 1000 NaN91 -> NaN91 subx869 subtract Inf NaN101 -> NaN101 subx871 subtract sNaN011 -Inf -> NaN11 Invalid_operation subx872 subtract sNaN012 -1000 -> NaN12 Invalid_operation subx873 subtract -sNaN013 1000 -> -NaN13 Invalid_operation subx874 subtract sNaN014 NaN171 -> NaN14 Invalid_operation subx875 subtract sNaN015 sNaN181 -> NaN15 Invalid_operation subx876 subtract NaN016 sNaN191 -> NaN191 Invalid_operation subx877 subtract -Inf sNaN201 -> NaN201 Invalid_operation subx878 subtract -1000 sNaN211 -> NaN211 Invalid_operation subx879 subtract 1000 -sNaN221 -> -NaN221 Invalid_operation subx880 subtract Inf sNaN231 -> NaN231 Invalid_operation subx881 subtract NaN025 sNaN241 -> NaN241 Invalid_operation -- edge case spills subx901 subtract 2.E-3 1.002 -> -1.000 subx902 subtract 2.0E-3 1.002 -> -1.0000 subx903 subtract 2.00E-3 1.0020 -> -1.00000 subx904 subtract 2.000E-3 1.00200 -> -1.000000 subx905 subtract 2.0000E-3 1.002000 -> -1.0000000 subx906 subtract 2.00000E-3 1.0020000 -> -1.00000000 subx907 subtract 2.000000E-3 1.00200000 -> -1.000000000 subx908 subtract 2.0000000E-3 1.002000000 -> -1.0000000000 -- subnormals and underflows precision: 3 maxexponent: 999 minexponent: -999 subx1010 subtract 0 1.00E-999 -> -1.00E-999 subx1011 subtract 0 0.1E-999 -> -1E-1000 Subnormal subx1012 subtract 0 0.10E-999 -> -1.0E-1000 Subnormal subx1013 subtract 0 0.100E-999 -> -1.0E-1000 Subnormal Rounded subx1014 subtract 0 0.01E-999 -> -1E-1001 Subnormal -- next is rounded to Emin subx1015 subtract 0 0.999E-999 -> -1.00E-999 Inexact Rounded Subnormal Underflow subx1016 subtract 0 0.099E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow subx1017 subtract 0 0.009E-999 -> -1E-1001 Inexact Rounded Subnormal Underflow subx1018 subtract 0 0.001E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow subx1019 subtract 0 0.0009E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow subx1020 subtract 0 0.0001E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow subx1030 subtract 0 -1.00E-999 -> 1.00E-999 subx1031 subtract 0 -0.1E-999 -> 1E-1000 Subnormal subx1032 subtract 0 -0.10E-999 -> 1.0E-1000 Subnormal subx1033 subtract 0 -0.100E-999 -> 1.0E-1000 Subnormal Rounded subx1034 subtract 0 -0.01E-999 -> 1E-1001 Subnormal -- next is rounded to Emin subx1035 subtract 0 -0.999E-999 -> 1.00E-999 Inexact Rounded Subnormal Underflow subx1036 subtract 0 -0.099E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow subx1037 subtract 0 -0.009E-999 -> 1E-1001 Inexact Rounded Subnormal Underflow subx1038 subtract 0 -0.001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow subx1039 subtract 0 -0.0009E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow subx1040 subtract 0 -0.0001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow -- some non-zero subnormal subtracts -- subx1056 is a tricky case rounding: half_up subx1050 subtract 1.00E-999 0.1E-999 -> 9.0E-1000 Subnormal subx1051 subtract 0.1E-999 0.1E-999 -> 0E-1000 subx1052 subtract 0.10E-999 0.1E-999 -> 0E-1001 subx1053 subtract 0.100E-999 0.1E-999 -> 0E-1001 Clamped subx1054 subtract 0.01E-999 0.1E-999 -> -9E-1001 Subnormal subx1055 subtract 0.999E-999 0.1E-999 -> 9.0E-1000 Inexact Rounded Subnormal Underflow subx1056 subtract 0.099E-999 0.1E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow subx1057 subtract 0.009E-999 0.1E-999 -> -9E-1001 Inexact Rounded Subnormal Underflow subx1058 subtract 0.001E-999 0.1E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow subx1059 subtract 0.0009E-999 0.1E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow subx1060 subtract 0.0001E-999 0.1E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow -- check for double-rounded subnormals precision: 5 maxexponent: 79 minexponent: -79 subx1101 subtract 0 1.52444E-80 -> -1.524E-80 Inexact Rounded Subnormal Underflow subx1102 subtract 0 1.52445E-80 -> -1.524E-80 Inexact Rounded Subnormal Underflow subx1103 subtract 0 1.52446E-80 -> -1.524E-80 Inexact Rounded Subnormal Underflow subx1104 subtract 1.52444E-80 0 -> 1.524E-80 Inexact Rounded Subnormal Underflow subx1105 subtract 1.52445E-80 0 -> 1.524E-80 Inexact Rounded Subnormal Underflow subx1106 subtract 1.52446E-80 0 -> 1.524E-80 Inexact Rounded Subnormal Underflow subx1111 subtract 1.2345678E-80 1.2345671E-80 -> 0E-83 Inexact Rounded Subnormal Underflow subx1112 subtract 1.2345678E-80 1.2345618E-80 -> 0E-83 Inexact Rounded Subnormal Underflow subx1113 subtract 1.2345678E-80 1.2345178E-80 -> 0E-83 Inexact Rounded Subnormal Underflow subx1114 subtract 1.2345678E-80 1.2341678E-80 -> 0E-83 Inexact Rounded Subnormal Underflow subx1115 subtract 1.2345678E-80 1.2315678E-80 -> 3E-83 Rounded Subnormal subx1116 subtract 1.2345678E-80 1.2145678E-80 -> 2.0E-82 Rounded Subnormal subx1117 subtract 1.2345678E-80 1.1345678E-80 -> 1.00E-81 Rounded Subnormal subx1118 subtract 1.2345678E-80 0.2345678E-80 -> 1.000E-80 Rounded Subnormal -- Null tests subx9990 subtract 10 # -> NaN Invalid_operation subx9991 subtract # 10 -> NaN Invalid_operation --- NEW FILE: testall.decTest --- ------------------------------------------------------------------------ -- testall.decTest -- run all general decimal arithmetic testcases -- -- Copyright (c) IBM Corporation, 1981, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.35 -- core tests (using Extended: 1) -------------------------------------- dectest: base dectest: abs dectest: add dectest: clamp dectest: compare dectest: divide dectest: divideint dectest: inexact dectest: max dectest: min dectest: minus dectest: multiply dectest: normalize dectest: plus dectest: power dectest: quantize dectest: randoms dectest: remainder dectest: remaindernear dectest: rescale -- [obsolete] dectest: rounding dectest: samequantum dectest: squareroot dectest: subtract dectest: tointegral dectest: trim -- The next are for the Strawman 4d concrete representations dectest: decimal32 dectest: decimal64 dectest: decimal128 -- General 31->33-digit boundary tests dectest: randomBound32 --- NEW FILE: tointegral.decTest --- ------------------------------------------------------------------------ -- tointegral.decTest -- round decimal to integral value -- -- Copyright (c) IBM Corporation, 2001, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.38 -- This set of tests tests the extended specification 'round-to-integral -- value' operation (from IEEE 854, later modified in 754r). -- All non-zero results are defined as being those from either copy or -- quantize, so those are assumed to have been tested. -- Note that 754r requires that Inexact not be set, and we similarly -- assume Rounded is not set. extended: 1 precision: 9 rounding: half_up maxExponent: 999 minExponent: -999 intx001 tointegral 0 -> 0 intx002 tointegral 0.0 -> 0 intx003 tointegral 0.1 -> 0 intx004 tointegral 0.2 -> 0 intx005 tointegral 0.3 -> 0 intx006 tointegral 0.4 -> 0 intx007 tointegral 0.5 -> 1 intx008 tointegral 0.6 -> 1 intx009 tointegral 0.7 -> 1 intx010 tointegral 0.8 -> 1 intx011 tointegral 0.9 -> 1 intx012 tointegral 1 -> 1 intx013 tointegral 1.0 -> 1 intx014 tointegral 1.1 -> 1 intx015 tointegral 1.2 -> 1 intx016 tointegral 1.3 -> 1 intx017 tointegral 1.4 -> 1 intx018 tointegral 1.5 -> 2 intx019 tointegral 1.6 -> 2 intx020 tointegral 1.7 -> 2 intx021 tointegral 1.8 -> 2 intx022 tointegral 1.9 -> 2 -- negatives intx031 tointegral -0 -> -0 intx032 tointegral -0.0 -> -0 intx033 tointegral -0.1 -> -0 intx034 tointegral -0.2 -> -0 intx035 tointegral -0.3 -> -0 intx036 tointegral -0.4 -> -0 intx037 tointegral -0.5 -> -1 intx038 tointegral -0.6 -> -1 intx039 tointegral -0.7 -> -1 intx040 tointegral -0.8 -> -1 intx041 tointegral -0.9 -> -1 intx042 tointegral -1 -> -1 intx043 tointegral -1.0 -> -1 intx044 tointegral -1.1 -> -1 intx045 tointegral -1.2 -> -1 intx046 tointegral -1.3 -> -1 intx047 tointegral -1.4 -> -1 intx048 tointegral -1.5 -> -2 intx049 tointegral -1.6 -> -2 intx050 tointegral -1.7 -> -2 intx051 tointegral -1.8 -> -2 intx052 tointegral -1.9 -> -2 -- next two would be NaN using quantize(x, 0) intx053 tointegral 10E+30 -> 1.0E+31 intx054 tointegral -10E+30 -> -1.0E+31 -- numbers around precision precision: 9 intx060 tointegral '56267E-10' -> '0' intx061 tointegral '56267E-5' -> '1' intx062 tointegral '56267E-2' -> '563' intx063 tointegral '56267E-1' -> '5627' intx065 tointegral '56267E-0' -> '56267' intx066 tointegral '56267E+0' -> '56267' intx067 tointegral '56267E+1' -> '5.6267E+5' intx068 tointegral '56267E+2' -> '5.6267E+6' intx069 tointegral '56267E+3' -> '5.6267E+7' intx070 tointegral '56267E+4' -> '5.6267E+8' intx071 tointegral '56267E+5' -> '5.6267E+9' intx072 tointegral '56267E+6' -> '5.6267E+10' intx073 tointegral '1.23E+96' -> '1.23E+96' intx074 tointegral '1.23E+384' -> '1.23E+384' intx075 tointegral '1.23E+999' -> '1.23E+999' intx080 tointegral '-56267E-10' -> '-0' intx081 tointegral '-56267E-5' -> '-1' intx082 tointegral '-56267E-2' -> '-563' intx083 tointegral '-56267E-1' -> '-5627' intx085 tointegral '-56267E-0' -> '-56267' intx086 tointegral '-56267E+0' -> '-56267' intx087 tointegral '-56267E+1' -> '-5.6267E+5' intx088 tointegral '-56267E+2' -> '-5.6267E+6' intx089 tointegral '-56267E+3' -> '-5.6267E+7' intx090 tointegral '-56267E+4' -> '-5.6267E+8' intx091 tointegral '-56267E+5' -> '-5.6267E+9' intx092 tointegral '-56267E+6' -> '-5.6267E+10' intx093 tointegral '-1.23E+96' -> '-1.23E+96' intx094 tointegral '-1.23E+384' -> '-1.23E+384' intx095 tointegral '-1.23E+999' -> '-1.23E+999' -- subnormal inputs intx100 tointegral 1E-999 -> 0 intx101 tointegral 0.1E-999 -> 0 intx102 tointegral 0.01E-999 -> 0 intx103 tointegral 0E-999 -> 0 -- specials and zeros intx120 tointegral 'Inf' -> Infinity intx121 tointegral '-Inf' -> -Infinity intx122 tointegral NaN -> NaN intx123 tointegral sNaN -> NaN Invalid_operation intx124 tointegral 0 -> 0 intx125 tointegral -0 -> -0 intx126 tointegral 0.000 -> 0 intx127 tointegral 0.00 -> 0 intx128 tointegral 0.0 -> 0 intx129 tointegral 0 -> 0 intx130 tointegral 0E-3 -> 0 intx131 tointegral 0E-2 -> 0 intx132 tointegral 0E-1 -> 0 intx133 tointegral 0E-0 -> 0 intx134 tointegral 0E+1 -> 0E+1 intx135 tointegral 0E+2 -> 0E+2 intx136 tointegral 0E+3 -> 0E+3 intx137 tointegral 0E+4 -> 0E+4 intx138 tointegral 0E+5 -> 0E+5 intx139 tointegral -0.000 -> -0 intx140 tointegral -0.00 -> -0 intx141 tointegral -0.0 -> -0 intx142 tointegral -0 -> -0 intx143 tointegral -0E-3 -> -0 intx144 tointegral -0E-2 -> -0 intx145 tointegral -0E-1 -> -0 intx146 tointegral -0E-0 -> -0 intx147 tointegral -0E+1 -> -0E+1 intx148 tointegral -0E+2 -> -0E+2 intx149 tointegral -0E+3 -> -0E+3 intx150 tointegral -0E+4 -> -0E+4 intx151 tointegral -0E+5 -> -0E+5 -- propagating NaNs intx152 tointegral NaN808 -> NaN808 intx153 tointegral sNaN080 -> NaN80 Invalid_operation intx154 tointegral -NaN808 -> -NaN808 intx155 tointegral -sNaN080 -> -NaN80 Invalid_operation intx156 tointegral -NaN -> -NaN intx157 tointegral -sNaN -> -NaN Invalid_operation -- examples rounding: half_up precision: 9 intx200 tointegral 2.1 -> 2 intx201 tointegral 100 -> 100 intx202 tointegral 100.0 -> 100 intx203 tointegral 101.5 -> 102 intx204 tointegral -101.5 -> -102 intx205 tointegral 10E+5 -> 1.0E+6 intx206 tointegral 7.89E+77 -> 7.89E+77 intx207 tointegral -Inf -> -Infinity --- NEW FILE: trim.decTest --- ------------------------------------------------------------------------ -- trim.decTest -- remove insignificant trailing zeros -- -- Copyright (c) IBM Corporation, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.35 extended: 1 precision: 9 rounding: half_up maxExponent: 999 minexponent: -999 trmx001 trim '1' -> '1' trmx002 trim '-1' -> '-1' trmx003 trim '1.00' -> '1' trmx004 trim '-1.00' -> '-1' trmx005 trim '0' -> '0' trmx006 trim '0.00' -> '0' trmx007 trim '00.0' -> '0' trmx008 trim '00.00' -> '0' trmx009 trim '00' -> '0' trmx010 trim '-2' -> '-2' trmx011 trim '2' -> '2' trmx012 trim '-2.00' -> '-2' trmx013 trim '2.00' -> '2' trmx014 trim '-0' -> '-0' trmx015 trim '-0.00' -> '-0' trmx016 trim '-00.0' -> '-0' trmx017 trim '-00.00' -> '-0' trmx018 trim '-00' -> '-0' trmx019 trim '0E+5' -> '0' trmx020 trim '-0E+1' -> '-0' trmx030 trim '+0.1' -> '0.1' trmx031 trim '-0.1' -> '-0.1' trmx032 trim '+0.01' -> '0.01' trmx033 trim '-0.01' -> '-0.01' trmx034 trim '+0.001' -> '0.001' trmx035 trim '-0.001' -> '-0.001' trmx036 trim '+0.000001' -> '0.000001' trmx037 trim '-0.000001' -> '-0.000001' trmx038 trim '+0.000000000001' -> '1E-12' trmx039 trim '-0.000000000001' -> '-1E-12' trmx041 trim 1.1 -> 1.1 trmx042 trim 1.10 -> 1.1 trmx043 trim 1.100 -> 1.1 trmx044 trim 1.110 -> 1.11 trmx045 trim -1.1 -> -1.1 trmx046 trim -1.10 -> -1.1 trmx047 trim -1.100 -> -1.1 trmx048 trim -1.110 -> -1.11 trmx049 trim 9.9 -> 9.9 trmx050 trim 9.90 -> 9.9 trmx051 trim 9.900 -> 9.9 trmx052 trim 9.990 -> 9.99 trmx053 trim -9.9 -> -9.9 trmx054 trim -9.90 -> -9.9 trmx055 trim -9.900 -> -9.9 trmx056 trim -9.990 -> -9.99 -- some insignificant trailing fractional zeros trmx060 trim 10.0 -> 10 trmx061 trim 10.00 -> 10 trmx062 trim 100.0 -> 100 trmx063 trim 100.00 -> 100 trmx064 trim 1.1000E+3 -> 1100 trmx065 trim 1.10000E+3 -> 1100 trmx066 trim -10.0 -> -10 trmx067 trim -10.00 -> -10 trmx068 trim -100.0 -> -100 trmx069 trim -100.00 -> -100 trmx070 trim -1.1000E+3 -> -1100 trmx071 trim -1.10000E+3 -> -1100 -- some insignificant trailing zeros with positive exponent trmx080 trim 10E+1 -> 1E+2 trmx081 trim 100E+1 -> 1E+3 trmx082 trim 1.0E+2 -> 1E+2 trmx083 trim 1.0E+3 -> 1E+3 trmx084 trim 1.1E+3 -> 1.1E+3 trmx085 trim 1.00E+3 -> 1E+3 trmx086 trim 1.10E+3 -> 1.1E+3 trmx087 trim -10E+1 -> -1E+2 trmx088 trim -100E+1 -> -1E+3 trmx089 trim -1.0E+2 -> -1E+2 trmx090 trim -1.0E+3 -> -1E+3 trmx091 trim -1.1E+3 -> -1.1E+3 trmx092 trim -1.00E+3 -> -1E+3 trmx093 trim -1.10E+3 -> -1.1E+3 -- some significant trailing zeros trmx100 trim 11 -> 11 trmx101 trim 10 -> 10 trmx102 trim 10. -> 10 trmx103 trim 1.1E+1 -> 11 trmx104 trim 1.0E+1 -> 10 trmx105 trim 1.10E+2 -> 110 trmx106 trim 1.00E+2 -> 100 trmx107 trim 1.100E+3 -> 1100 trmx108 trim 1.000E+3 -> 1000 trmx109 trim 1.000000E+6 -> 1000000 trmx110 trim -11 -> -11 trmx111 trim -10 -> -10 trmx112 trim -10. -> -10 trmx113 trim -1.1E+1 -> -11 trmx114 trim -1.0E+1 -> -10 trmx115 trim -1.10E+2 -> -110 trmx116 trim -1.00E+2 -> -100 trmx117 trim -1.100E+3 -> -1100 trmx118 trim -1.000E+3 -> -1000 trmx119 trim -1.00000E+5 -> -100000 trmx120 trim -1.000000E+6 -> -1000000 -- examples from decArith trmx140 trim '2.1' -> '2.1' trmx141 trim '-2.0' -> '-2' trmx142 trim '1.200' -> '1.2' trmx143 trim '-120' -> '-120' trmx144 trim '120.00' -> '120' trmx145 trim '0.00' -> '0' -- utilities pass through specials without raising exceptions trmx320 trim 'Inf' -> 'Infinity' trmx321 trim '-Inf' -> '-Infinity' trmx322 trim NaN -> NaN trmx323 trim sNaN -> sNaN trmx324 trim NaN999 -> NaN999 trmx325 trim sNaN777 -> sNaN777 trmx326 trim -NaN -> -NaN trmx327 trim -sNaN -> -sNaN trmx328 trim -NaN999 -> -NaN999 trmx329 trim -sNaN777 -> -sNaN777 -- Null test trmx900 trim # -> NaN Invalid_operation From rhettinger at users.sourceforge.net Thu Jul 1 07:02:04 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 07:02:06 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1016,1.1017 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26988/Misc Modified Files: NEWS Log Message: Move Decimal from the sandbox into production. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1016 retrieving revision 1.1017 diff -C2 -d -r1.1016 -r1.1017 *** NEWS 30 Jun 2004 09:09:38 -0000 1.1016 --- NEWS 1 Jul 2004 11:01:27 -0000 1.1017 *************** *** 351,354 **** --- 351,356 ---- ------- + - Added Decimal.py per PEP 327. + - Bug #981299: rsync is now a recognized protocol in urlparse that uses a "netloc" portion of a URL. From rhettinger at users.sourceforge.net Thu Jul 1 07:02:05 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 07:02:10 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_decimal.py, NONE, 1.1 regrtest.py, 1.153, 1.154 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26988/Lib/test Modified Files: regrtest.py Added Files: test_decimal.py Log Message: Move Decimal from the sandbox into production. --- NEW FILE: test_decimal.py --- # Copyright (c) 2004 Python Software Foundation. # All rights reserved. # Written by Eric Price # and Facundo Batista # and Raymond Hettinger # and Aahz (aahz at pobox.com) # and Tim Peters """ These are the test cases for the Decimal module. There are two groups of tests, Arithmetic and Behaviour. The former test the Decimal arithmetic using the tests provided by Mike Cowlishaw. The latter test the pythonic behaviour according to PEP 327. Cowlishaw's tests can be downloaded from: www2.hursley.ibm.com/decimal/dectest.zip [...1043 lines suppressed...] if arith or is_resource_enabled('decimal'): test_classes.extend([DecimalTest]) run_unittest(*test_classes) import decimal as DecimalModule run_doctest(DecimalModule, verbose) return if __name__ == '__main__': # Calling with no arguments runs all tests. # Calling with "Skip" will skipover the arithmetic tests. if len(sys.argv) == 1: test_main(arith=True, verbose=True) elif len(sys.argv) == 2: arith = sys.argv[1].lower() != 'skip' test_main(arith=arith, verbose=True) else: raise ValueError("test called with wrong arguments, use test_Decimal [Skip]") Index: regrtest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v retrieving revision 1.153 retrieving revision 1.154 diff -C2 -d -r1.153 -r1.154 *** regrtest.py 6 Jun 2004 15:53:18 -0000 1.153 --- regrtest.py 1 Jul 2004 11:01:31 -0000 1.154 *************** *** 72,75 **** --- 72,78 ---- a long time to complete. + decimal - Test the decimal module against a large suite that + verifies compliance with standards. + To enable all resources except one, use '-uall,-'. For example, to run all the tests except for the bsddb tests, give the *************** *** 113,117 **** from test import test_support ! RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network', 'bsddb') --- 116,121 ---- from test import test_support ! RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network', 'bsddb', ! 'decimal') From rhettinger at users.sourceforge.net Thu Jul 1 07:15:42 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 07:15:45 2004 Subject: [Python-checkins] python/dist/src/Lib/test test___all__.py, 1.38, 1.39 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29984 Modified Files: test___all__.py Log Message: Move Decimal from the sandbox into production. Index: test___all__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test___all__.py,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** test___all__.py 13 Jun 2004 05:46:14 -0000 1.38 --- test___all__.py 1 Jul 2004 11:15:39 -0000 1.39 *************** *** 83,86 **** --- 83,87 ---- self.check_all("csv") self.check_all("dbhash") + self.check_all("decimal") self.check_all("difflib") self.check_all("dircache") From rhettinger at users.sourceforge.net Thu Jul 1 07:52:17 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 07:52:21 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.55, 1.56 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5372 Modified Files: whatsnew24.tex Log Message: Move Decimal from the sandbox into production. Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** whatsnew24.tex 10 Jun 2004 05:03:16 -0000 1.55 --- whatsnew24.tex 1 Jul 2004 11:52:15 -0000 1.56 *************** *** 202,205 **** --- 202,267 ---- %====================================================================== + \section{PEP 327: Decimal Data Type} + + A new module, \module{decimal}, offers a \class{Decimal} data type for + decimal floating point arithmetic. Compared to the built-in \class{float} + type implemented with binary floating point, the new class is especially + useful for financial applications and other uses which require exact + decimal representation, control over precision, control over rounding + to meet legal or regulatory requirements, tracking of significant + decimal places, or for applications where the user expects the results + to match hand calculations done the way they were taught in school. + + For example, calculating a 5% tax on a 70 cent phone charge gives + different results in decimal floating point and binary floating point + with the difference being significant when rounding to the nearest + cent: + + \begin{verbatim} + >>> from decimal import * + >>> Decimal('0.70') * Decimal('1.05') + Decimal("0.7350") + >>> .70 * 1.05 + 0.73499999999999999 + \end{verbatim} + + Note that the \class{Decimal} result keeps a trailing zero, automatically + inferring four place significance from two digit mulitiplicands. A key + goal is to reproduce the mathematics we do by hand and avoid the tricky + issues that arise when decimal numbers cannot be represented exactly in + binary floating point. + + Exact representation enables the \class{Decimal} class to perform + modulo calculations and equality tests that would fail in binary + floating point: + + \begin{verbatim} + >>> Decimal('1.00') % Decimal('.10') + Decimal("0.00") + >>> 1.00 % 0.10 + 0.09999999999999995 + + >>> sum([Decimal('0.1')]*10) == Decimal('1.0') + True + >>> sum([0.1]*10) == 1.0 + False + \end{verbatim} + + The \module{decimal} module also allows arbitrarily large precisions to be + set for calculation: + + \begin{verbatim} + >>> getcontext().prec = 24 + >>> Decimal(1) / Decimal(7) + Decimal("0.142857142857142857142857") + \end{verbatim} + + \begin{seealso} + \seepep{327}{Decimal Data Type}{Written by Facundo Batista and implemented + by Eric Price, Facundo Bastista, Raymond Hettinger, Aahz, and Tim Peters.} + \end{seealso} + + + %====================================================================== \section{Other Language Changes} From amk at amk.ca Thu Jul 1 07:58:09 2004 From: amk at amk.ca (A.M. Kuchling) Date: Thu Jul 1 07:58:27 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.55, 1.56 In-Reply-To: References: Message-ID: <20040701115809.GA22778@rogue.amk.ca> On Thu, Jul 01, 2004 at 04:52:17AM -0700, rhettinger@users.sourceforge.net wrote: > Modified Files: > whatsnew24.tex > Log Message: > Move Decimal from the sandbox into production. Um, I'd really like to write my own text for this document. Please don't go to the effort of writing "What's New" sections. --amk From rhettinger at users.sourceforge.net Thu Jul 1 08:42:34 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 08:42:39 2004 Subject: [Python-checkins] python/nondist/peps pep-0320.txt,1.13,1.14 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15449 Modified Files: pep-0320.txt Log Message: Move two entries from 'planned' to 'done' Index: pep-0320.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0320.txt,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** pep-0320.txt 2 Jun 2004 14:48:16 -0000 1.13 --- pep-0320.txt 1 Jul 2004 12:42:30 -0000 1.14 *************** *** 44,47 **** --- 44,49 ---- PEP 322 Reverse Iteration. + PEP 327: A Decimal package for fixed precision arithmetic. + Encapsulate the decorate-sort-undecorate pattern in a keyword for list.sort(). *************** *** 53,56 **** --- 55,62 ---- Add a collections module with a deque() object. + Add two statistical/reduction functions, nlargest() and nsmallest() + to the heapq module. + + Planned features for 2.4 *************** *** 59,64 **** PEP 318: Function/method decorator syntax - PEP 327: A Decimal package for fixed precision arithmetic. - PEP 328: Imports: Multi-line and Absolute/Relative. (Still quite controversial.) --- 65,68 ---- *************** *** 68,78 **** Remove support for platforms as described in PEP 11. - - Add a module for statistical and reduction functions: - stddev, average, nlargest, nsmallest, product, etc. - (There is a tested implementation in the sandbox but it - may be held-off until Py2.5 because there doesn't not - appear to be any user demand and the author is concerned - that the module may not offer a sufficiently rich API). Finish implementing the Distutils bdist_dpkg command. (AMK) --- 72,75 ---- From rhettinger at users.sourceforge.net Thu Jul 1 08:56:57 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Jul 1 08:57:01 2004 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.234,1.235 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17562 Modified Files: tut.tex Log Message: * Fix typos. * Format an example so that the identation is more obvious. * Add a section on the decimal module to the Brief Tour Part II. Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.234 retrieving revision 1.235 diff -C2 -d -r1.234 -r1.235 *** tut.tex 3 Jun 2004 17:19:25 -0000 1.234 --- tut.tex 1 Jul 2004 12:56:54 -0000 1.235 *************** *** 4339,4343 **** \begin{verbatim} ! >>> class Reverse: "Iterator for looping over a sequence backwards" def __init__(self, data): --- 4339,4343 ---- \begin{verbatim} ! class Reverse: "Iterator for looping over a sequence backwards" def __init__(self, data): *************** *** 4353,4358 **** >>> for char in Reverse('spam'): ! print char ! m a --- 4353,4358 ---- >>> for char in Reverse('spam'): ! ... print char ! ... m a *************** *** 4372,4382 **** \begin{verbatim} ! >>> def reverse(data): ! for index in range(len(data)-1, -1, -1): ! yield data[index] ! >>> for char in reverse('golf'): ! print char ! f l --- 4372,4382 ---- \begin{verbatim} ! def reverse(data): ! for index in range(len(data)-1, -1, -1): ! yield data[index] ! >>> for char in reverse('golf'): ! ... print char ! ... f l *************** *** 4895,4899 **** \end{verbatim} ! The principal challenge of multi-thread applications is coordinating threads that share data or other resources. To that end, the threading module provides a number of synchronization primitives including locks, --- 4895,4899 ---- \end{verbatim} ! The principal challenge of multi-threaded applications is coordinating threads that share data or other resources. To that end, the threading module provides a number of synchronization primitives including locks, *************** *** 4936,4940 **** output is sent to standard error. Other output options include routing messages through email, datagrams, sockets, or to an HTTP Server. New ! filters select different routing based on message priority: DEBUG, INFO, WARNING, ERROR, and CRITICAL. --- 4936,4940 ---- output is sent to standard error. Other output options include routing messages through email, datagrams, sockets, or to an HTTP Server. New ! filters can select different routing based on message priority: DEBUG, INFO, WARNING, ERROR, and CRITICAL. *************** *** 4968,4977 **** ... return str(self.value) ... ! >>> a = A(10) # create a reference >>> d = weakref.WeakValueDictionary() >>> d['primary'] = a # does not create a reference ! >>> d['primary'] # fetch the object if it is still alive 10 ! >>> del a # remove the one reference >>> gc.collect() # run garbage collection right away 0 --- 4968,4977 ---- ... return str(self.value) ... ! >>> a = A(10) # create a reference >>> d = weakref.WeakValueDictionary() >>> d['primary'] = a # does not create a reference ! >>> d['primary'] # fetch the object if it is still alive 10 ! >>> del a # remove the one reference >>> gc.collect() # run garbage collection right away 0 *************** *** 5057,5060 **** --- 5057,5116 ---- + \section{Tools for Working with Decimal Floating Point\label{decimal-fp}} + + The \module{decimal} module, offers a \class{Decimal} data type for + decimal floating point arithmetic. Compared to the built-in \class{float} + type implemented with binary floating point, the new class is especially + useful for financial applications and other uses which require exact + decimal representation, control over precision, control over rounding + to meet legal or regulatory requirements, tracking of significant + decimal places, or for applications where the user expects the results + to match hand calculations done as taught in school. + + For example, calculating a 5% tax on a 70 cent phone charge gives + different results in decimal floating point and binary floating point + with the difference being significant when rounding to the nearest + cent: + + \begin{verbatim} + >>> from decimal import * + >>> Decimal('0.70') * Decimal('1.05') + Decimal("0.7350") + >>> .70 * 1.05 + 0.73499999999999999 + \end{verbatim} + + Note that the \class{Decimal} result keeps a trailing zero, automatically + inferring four place significance from two digit mulitiplicands. Decimal + reproduces mathematics as done by hand and avoids issues that can arise + when binary floating point cannot exactly represent decimal quantities. + + Exact representation enables the \class{Decimal} class to perform + modulo calculations and equality tests that are unsuitable for binary + floating point: + + \begin{verbatim} + >>> Decimal('1.00') % Decimal('.10') + Decimal("0.00") + >>> 1.00 % 0.10 + 0.09999999999999995 + + >>> sum([Decimal('0.1')]*10) == Decimal('1.0') + True + >>> sum([0.1]*10) == 1.0 + False + \end{verbatim} + + The \module{decimal} module also allows arbitrarily large precisions to be + set for calculation: + + \begin{verbatim} + >>> getcontext().prec = 36 + >>> Decimal(1) / Decimal(7) + Decimal("0.142857142857142857142857142857142857") + \end{verbatim} + + + \chapter{What Now? \label{whatNow}} From fdrake at users.sourceforge.net Thu Jul 1 10:26:44 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Jul 1 10:26:49 2004 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.235,1.236 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3701/tut Modified Files: tut.tex Log Message: add omitted markup Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.235 retrieving revision 1.236 diff -C2 -d -r1.235 -r1.236 *** tut.tex 1 Jul 2004 12:56:54 -0000 1.235 --- tut.tex 1 Jul 2004 14:26:31 -0000 1.236 *************** *** 4936,4941 **** output is sent to standard error. Other output options include routing messages through email, datagrams, sockets, or to an HTTP Server. New ! filters can select different routing based on message priority: DEBUG, ! INFO, WARNING, ERROR, and CRITICAL. The logging system can be configured directly from Python or can be --- 4936,4942 ---- output is sent to standard error. Other output options include routing messages through email, datagrams, sockets, or to an HTTP Server. New ! filters can select different routing based on message priority: ! \constant{DEBUG}, \constant{INFO}, \constant{WARNING}, \constant{ERROR}, ! and \constant{CRITICAL}. The logging system can be configured directly from Python or can be From fdrake at users.sourceforge.net Thu Jul 1 10:28:38 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Jul 1 10:28:47 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3972 Modified Files: decimal.py Log Message: fix small consistency nit Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** decimal.py 1 Jul 2004 11:01:31 -0000 1.1 --- decimal.py 1 Jul 2004 14:28:36 -0000 1.2 *************** *** 5,9 **** # and Facundo Batista # and Raymond Hettinger ! # and Aahz (aahz at pobox.com) # and Tim Peters --- 5,9 ---- # and Facundo Batista # and Raymond Hettinger ! # and Aahz # and Tim Peters From mwh at users.sourceforge.net Thu Jul 1 10:52:13 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Thu Jul 1 10:52:17 2004 Subject: [Python-checkins] python/dist/src/Lib cmd.py,1.37,1.38 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7724 Modified Files: cmd.py Log Message: Fix [ 924301 ] A leak case with cmd.py & readline & exception by ensuring that the readline completion function is always reset even in the case of an exception being raised. As a bonus, this makes the documentation for pre & postloop accurate again. Index: cmd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cmd.py,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** cmd.py 22 Oct 2003 14:38:54 -0000 1.37 --- cmd.py 1 Jul 2004 14:52:10 -0000 1.38 *************** *** 108,137 **** self.preloop() ! if intro is not None: ! self.intro = intro ! if self.intro: ! self.stdout.write(str(self.intro)+"\n") ! stop = None ! while not stop: ! if self.cmdqueue: ! line = self.cmdqueue.pop(0) ! else: ! if self.use_rawinput: ! try: ! line = raw_input(self.prompt) ! except EOFError: ! line = 'EOF' else: ! self.stdout.write(self.prompt) ! self.stdout.flush() ! line = self.stdin.readline() ! if not len(line): ! line = 'EOF' else: ! line = line[:-1] # chop \n ! line = self.precmd(line) ! stop = self.onecmd(line) ! stop = self.postcmd(stop, line) ! self.postloop() def precmd(self, line): --- 108,154 ---- self.preloop() ! if self.use_rawinput and self.completekey: ! try: ! import readline ! self.old_completer = readline.get_completer() ! readline.set_completer(self.complete) ! readline.parse_and_bind(self.completekey+": complete") ! except ImportError: ! pass ! try: ! if intro is not None: ! self.intro = intro ! if self.intro: ! self.stdout.write(str(self.intro)+"\n") ! stop = None ! while not stop: ! if self.cmdqueue: ! line = self.cmdqueue.pop(0) else: ! if self.use_rawinput: ! try: ! line = raw_input(self.prompt) ! except EOFError: ! line = 'EOF' else: ! self.stdout.write(self.prompt) ! self.stdout.flush() ! line = self.stdin.readline() ! if not len(line): ! line = 'EOF' ! else: ! line = line[:-1] # chop \n ! line = self.precmd(line) ! stop = self.onecmd(line) ! stop = self.postcmd(stop, line) ! self.postloop() ! finally: ! if self.use_rawinput and self.completekey: ! try: ! import readline ! readline.set_completer(self.old_completer) ! except ImportError: ! pass ! def precmd(self, line): *************** *** 148,159 **** def preloop(self): """Hook method executed once when the cmdloop() method is called.""" ! if self.completekey: ! try: ! import readline ! self.old_completer = readline.get_completer() ! readline.set_completer(self.complete) ! readline.parse_and_bind(self.completekey+": complete") ! except ImportError: ! pass def postloop(self): --- 165,169 ---- def preloop(self): """Hook method executed once when the cmdloop() method is called.""" ! pass def postloop(self): *************** *** 162,172 **** """ ! if self.completekey: ! try: ! import readline ! readline.set_completer(self.old_completer) ! except ImportError: ! pass ! def parseline(self, line): """Parse the line into a command name and a string containing --- 172,177 ---- """ ! pass ! def parseline(self, line): """Parse the line into a command name and a string containing From montanaro at users.sourceforge.net Thu Jul 1 15:26:24 2004 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Thu Jul 1 15:26:31 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libcodecs.tex, 1.28, 1.29 libstdtypes.tex, 1.155, 1.156 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31380 Modified Files: libcodecs.tex libstdtypes.tex Log Message: link to the codecs page from the "".encode() description. Index: libcodecs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcodecs.tex,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** libcodecs.tex 19 Mar 2004 08:06:00 -0000 1.28 --- libcodecs.tex 1 Jul 2004 19:26:04 -0000 1.29 *************** *** 514,518 **** all other methods and attribute from the underlying stream. ! \subsection{Standard Encodings} Python comes with a number of codecs builtin, either implemented as C --- 514,518 ---- all other methods and attribute from the underlying stream. ! \subsection{Standard Encodings\label{standard-encodings}} Python comes with a number of codecs builtin, either implemented as C Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.155 retrieving revision 1.156 diff -C2 -d -r1.155 -r1.156 *** libstdtypes.tex 3 Jun 2004 09:47:01 -0000 1.155 --- libstdtypes.tex 1 Jul 2004 19:26:04 -0000 1.156 *************** *** 579,583 **** \code{'strict'}, meaning that encoding errors raise a \exception{ValueError}. Other possible values are \code{'ignore'} and ! \code{'replace'}. \versionadded{2.0} \end{methoddesc} --- 579,584 ---- \code{'strict'}, meaning that encoding errors raise a \exception{ValueError}. Other possible values are \code{'ignore'} and ! \code{'replace'}. For a list of possible encodings, see ! section~\ref{standard-encodings}. \versionadded{2.0} \end{methoddesc} From doerwalter at users.sourceforge.net Thu Jul 1 15:58:50 2004 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Thu Jul 1 15:58:54 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libstdtypes.tex, 1.156, 1.157 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5364 Modified Files: libstdtypes.tex Log Message: Document that encode() and decode() raise UnicodeError instead of ValueError. Add a note about error handling schemes added by PEP 293. Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.156 retrieving revision 1.157 diff -C2 -d -r1.156 -r1.157 *** libstdtypes.tex 1 Jul 2004 19:26:04 -0000 1.156 --- libstdtypes.tex 1 Jul 2004 19:58:47 -0000 1.157 *************** *** 568,574 **** may be given to set a different error handling scheme. The default is \code{'strict'}, meaning that encoding errors raise ! \exception{ValueError}. Other possible values are \code{'ignore'} and ! \code{'replace'}. \versionadded{2.2} \end{methoddesc} --- 568,576 ---- may be given to set a different error handling scheme. The default is \code{'strict'}, meaning that encoding errors raise ! \exception{UnicodeError}. Other possible values are \code{'ignore'}, ! \code{'replace'} and any other name registered via ! \function{codecs.register_error}. \versionadded{2.2} + \versionchanged[Support for other error handling schemes added]{2.3} \end{methoddesc} *************** *** 578,585 **** error handling scheme. The default for \var{errors} is \code{'strict'}, meaning that encoding errors raise a ! \exception{ValueError}. Other possible values are \code{'ignore'} and ! \code{'replace'}. For a list of possible encodings, see ! section~\ref{standard-encodings}. \versionadded{2.0} \end{methoddesc} --- 580,590 ---- error handling scheme. The default for \var{errors} is \code{'strict'}, meaning that encoding errors raise a ! \exception{UnicodeError}. Other possible values are \code{'ignore'}, ! \code{'replace'}, \code{'xmlcharrefreplace'}, \code{'backslashreplace'} ! and any other name registered via \function{codecs.register_error}. ! For a list of possible encodings, see section~\ref{standard-encodings}. \versionadded{2.0} + \versionchanged[Support for \code{'xmlcharrefreplace'} and + \code{'backslashreplace'} and other error handling schemes added]{2.3} \end{methoddesc} From fdrake at users.sourceforge.net Thu Jul 1 16:28:50 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Jul 1 16:28:54 2004 Subject: [Python-checkins] python/dist/src/Lib repr.py,1.19,1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11534 Modified Files: repr.py Log Message: Committing Tim's patch for SF bug #983585: test_repr() fails with id() values that appear negative Index: repr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/repr.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** repr.py 22 May 2004 19:37:21 -0000 1.19 --- repr.py 1 Jul 2004 20:28:47 -0000 1.20 *************** *** 112,117 **** # exceptions -- then make up something except: ! return '<' + x.__class__.__name__ + ' instance at ' + \ ! hex(id(x))[2:] + '>' if len(s) > self.maxstring: i = max(0, (self.maxstring-3)//2) --- 112,116 ---- # exceptions -- then make up something except: ! return '<%s instance at %x>' % (x.__class__.__name__, id(x)) if len(s) > self.maxstring: i = max(0, (self.maxstring-3)//2) From bcannon at users.sourceforge.net Thu Jul 1 16:55:45 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Thu Jul 1 16:55:51 2004 Subject: [Python-checkins] python/dist/src/Doc/api utilities.tex,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16682/Doc/api Modified Files: utilities.tex Log Message: Change signatures for arguments to "s" and friends to be the proper ``const char *`` instead of just ``char *``. Also added the mentioning of "const" in some places where it was left out even when the signature already stated the fact. Closes bug #980925. Index: utilities.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/utilities.tex,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** utilities.tex 27 Jun 2004 16:51:45 -0000 1.14 --- utilities.tex 1 Jul 2004 20:55:42 -0000 1.15 *************** *** 385,389 **** \begin{description} ! \item[\samp{s} (string or Unicode object) {[char *]}] Convert a Python string or Unicode object to a C pointer to a character string. You must not provide storage for the string --- 385,389 ---- \begin{description} ! \item[\samp{s} (string or Unicode object) {[const char *]}] Convert a Python string or Unicode object to a C pointer to a character string. You must not provide storage for the string *************** *** 397,401 **** \item[\samp{s\#} (string, Unicode or any read buffer compatible object) ! {[char *, int]}] This variant on \samp{s} stores into two C variables, the first one a pointer to a character string, the second one its length. In this --- 397,401 ---- \item[\samp{s\#} (string, Unicode or any read buffer compatible object) ! {[const char *, int]}] This variant on \samp{s} stores into two C variables, the first one a pointer to a character string, the second one its length. In this *************** *** 406,415 **** representation. ! \item[\samp{z} (string or \code{None}) {[char *]}] Like \samp{s}, but the Python object may also be \code{None}, in which case the C pointer is set to \NULL. \item[\samp{z\#} (string or \code{None} or any read buffer ! compatible object) {[char *, int]}] This is to \samp{s\#} as \samp{z} is to \samp{s}. --- 406,415 ---- representation. ! \item[\samp{z} (string or \code{None}) {[const char *]}] Like \samp{s}, but the Python object may also be \code{None}, in which case the C pointer is set to \NULL. \item[\samp{z\#} (string or \code{None} or any read buffer ! compatible object) {[const char *, int]}] This is to \samp{s\#} as \samp{z} is to \samp{s}. *************** *** 434,438 **** This format requires two arguments. The first is only used as ! input, and must be a \ctype{char*} which points to the name of an encoding as a NUL-terminated string, or \NULL, in which case the default encoding is used. An exception is raised if the named --- 434,438 ---- This format requires two arguments. The first is only used as ! input, and must be a \ctype{const char*} which points to the name of an encoding as a NUL-terminated string, or \NULL, in which case the default encoding is used. An exception is raised if the named *************** *** 462,466 **** It requires three arguments. The first is only used as input, and ! must be a \ctype{char*} which points to the name of an encoding as a NUL-terminated string, or \NULL, in which case the default encoding is used. An exception is raised if the named encoding is not known --- 462,466 ---- It requires three arguments. The first is only used as input, and ! must be a \ctype{const char*} which points to the name of an encoding as a NUL-terminated string, or \NULL, in which case the default encoding is used. An exception is raised if the named encoding is not known From montanaro at users.sourceforge.net Thu Jul 1 22:14:37 2004 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Thu Jul 1 22:14:40 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libcodecs.tex,1.29,1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12915 Modified Files: libcodecs.tex Log Message: add cp866 row Index: libcodecs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcodecs.tex,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** libcodecs.tex 1 Jul 2004 19:26:04 -0000 1.29 --- libcodecs.tex 2 Jul 2004 02:14:34 -0000 1.30 *************** *** 617,620 **** --- 617,624 ---- {Danish, Norwegian} + \lineiii{cp866} + {866, IBM866} + {Russian} + \lineiii{cp869} {869, CP-GR, IBM869} From rhettinger at users.sourceforge.net Fri Jul 2 02:41:08 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jul 2 02:41:13 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1017,1.1018 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18086/Misc Modified Files: NEWS Log Message: SF Bug #215126: Over restricted type checking on eval() function The builtin eval() function now accepts any mapping for the locals argument. Time sensitive steps guarded by PyDict_CheckExact() to keep from slowing down the normal case. My timings so no measurable impact. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1017 retrieving revision 1.1018 diff -C2 -d -r1.1017 -r1.1018 *** NEWS 1 Jul 2004 11:01:27 -0000 1.1017 --- NEWS 2 Jul 2004 06:41:05 -0000 1.1018 *************** *** 13,16 **** --- 13,18 ---- ----------------- + - Bug #215126. The locals argument to eval() now accepts any mapping type. + - marshal now shares interned strings. This change introduces a new .pyc magic. From rhettinger at users.sourceforge.net Fri Jul 2 02:41:09 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jul 2 02:41:15 2004 Subject: [Python-checkins] python/dist/src/Objects frameobject.c, 2.78, 2.79 object.c, 2.217, 2.218 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18086/Objects Modified Files: frameobject.c object.c Log Message: SF Bug #215126: Over restricted type checking on eval() function The builtin eval() function now accepts any mapping for the locals argument. Time sensitive steps guarded by PyDict_CheckExact() to keep from slowing down the normal case. My timings so no measurable impact. Index: frameobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/frameobject.c,v retrieving revision 2.78 retrieving revision 2.79 diff -C2 -d -r2.78 -r2.79 *** frameobject.c 20 Mar 2004 21:10:27 -0000 2.78 --- frameobject.c 2 Jul 2004 06:41:06 -0000 2.79 *************** *** 545,549 **** #ifdef Py_DEBUG if (code == NULL || globals == NULL || !PyDict_Check(globals) || ! (locals != NULL && !PyDict_Check(locals))) { PyErr_BadInternalCall(); return NULL; --- 545,549 ---- #ifdef Py_DEBUG if (code == NULL || globals == NULL || !PyDict_Check(globals) || ! (locals != NULL && !PyMapping_Check(locals))) { PyErr_BadInternalCall(); return NULL; *************** *** 689,697 **** value = PyCell_GET(value); if (value == NULL) { ! if (PyDict_DelItem(dict, key) != 0) PyErr_Clear(); } else { ! if (PyDict_SetItem(dict, key, value) != 0) PyErr_Clear(); } --- 689,697 ---- value = PyCell_GET(value); if (value == NULL) { ! if (PyObject_DelItem(dict, key) != 0) PyErr_Clear(); } else { ! if (PyObject_SetItem(dict, key, value) != 0) PyErr_Clear(); } *************** *** 706,710 **** for (j = nmap; --j >= 0; ) { PyObject *key = PyTuple_GET_ITEM(map, j); ! PyObject *value = PyDict_GetItem(dict, key); if (deref) { if (value || clear) { --- 706,712 ---- for (j = nmap; --j >= 0; ) { PyObject *key = PyTuple_GET_ITEM(map, j); ! PyObject *value = PyObject_GetItem(dict, key); ! if (value == NULL) ! PyErr_Clear(); if (deref) { if (value || clear) { *************** *** 721,724 **** --- 723,727 ---- } } + Py_XDECREF(value); } } *************** *** 743,747 **** } map = f->f_code->co_varnames; ! if (!PyDict_Check(locals) || !PyTuple_Check(map)) return; PyErr_Fetch(&error_type, &error_value, &error_traceback); --- 746,750 ---- } map = f->f_code->co_varnames; ! if (!PyTuple_Check(map)) return; PyErr_Fetch(&error_type, &error_value, &error_traceback); *************** *** 781,785 **** if (locals == NULL) return; ! if (!PyDict_Check(locals) || !PyTuple_Check(map)) return; PyErr_Fetch(&error_type, &error_value, &error_traceback); --- 784,788 ---- if (locals == NULL) return; ! if (!PyTuple_Check(map)) return; PyErr_Fetch(&error_type, &error_value, &error_traceback); Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.217 retrieving revision 2.218 diff -C2 -d -r2.217 -r2.218 *** object.c 22 Apr 2004 17:23:49 -0000 2.217 --- object.c 2 Jul 2004 06:41:06 -0000 2.218 *************** *** 1622,1626 **** if (locals == NULL) goto error; ! result = PyDict_Keys(locals); if (result == NULL) goto error; --- 1622,1626 ---- if (locals == NULL) goto error; ! result = PyMapping_Keys(locals); if (result == NULL) goto error; From rhettinger at users.sourceforge.net Fri Jul 2 02:41:10 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jul 2 02:41:17 2004 Subject: [Python-checkins] python/dist/src/Python bltinmodule.c, 2.309, 2.310 ceval.c, 2.407, 2.408 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18086/Python Modified Files: bltinmodule.c ceval.c Log Message: SF Bug #215126: Over restricted type checking on eval() function The builtin eval() function now accepts any mapping for the locals argument. Time sensitive steps guarded by PyDict_CheckExact() to keep from slowing down the normal case. My timings so no measurable impact. Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.309 retrieving revision 2.310 diff -C2 -d -r2.309 -r2.310 *** bltinmodule.c 29 Mar 2004 11:50:55 -0000 2.309 --- bltinmodule.c 2 Jul 2004 06:41:07 -0000 2.310 *************** *** 456,464 **** PyCompilerFlags cf; ! if (!PyArg_ParseTuple(args, "O|O!O!:eval", ! &cmd, ! &PyDict_Type, &globals, ! &PyDict_Type, &locals)) return NULL; if (globals == Py_None) { globals = PyEval_GetGlobals(); --- 456,470 ---- PyCompilerFlags cf; ! if (!PyArg_UnpackTuple(args, "eval", 1, 3, &cmd, &globals, &locals)) return NULL; + if (locals != Py_None && !PyMapping_Check(locals)) { + PyErr_SetString(PyExc_TypeError, "locals must be a mapping"); + return NULL; + } + if (globals != Py_None && !PyDict_Check(globals)) { + PyErr_SetString(PyExc_TypeError, PyMapping_Check(globals) ? + "globals must be a real dict; try eval(expr, {}, mapping)" + : "globals must be a dict"); + } if (globals == Py_None) { globals = PyEval_GetGlobals(); *************** *** 518,523 **** The source may be a string representing a Python expression\n\ or a code object as returned by compile().\n\ ! The globals and locals are dictionaries, defaulting to the current\n\ ! globals and locals. If only globals is given, locals defaults to it."); --- 524,530 ---- The source may be a string representing a Python expression\n\ or a code object as returned by compile().\n\ ! The globals must be a dictionary and locals can be any mappping,\n\ ! defaulting to the current globals and locals.\n\ ! If only globals is given, locals defaults to it.\n"); Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.407 retrieving revision 2.408 diff -C2 -d -r2.407 -r2.408 *** ceval.c 27 Jun 2004 15:43:12 -0000 2.407 --- ceval.c 2 Jul 2004 06:41:07 -0000 2.408 *************** *** 1644,1648 **** v = POP(); if ((x = f->f_locals) != NULL) { ! err = PyDict_SetItem(x, w, v); Py_DECREF(v); if (err == 0) continue; --- 1644,1651 ---- v = POP(); if ((x = f->f_locals) != NULL) { ! if (PyDict_CheckExact(v)) ! err = PyDict_SetItem(x, w, v); ! else ! err = PyObject_SetItem(x, w, v); Py_DECREF(v); if (err == 0) continue; *************** *** 1657,1661 **** w = GETITEM(names, oparg); if ((x = f->f_locals) != NULL) { ! if ((err = PyDict_DelItem(x, w)) != 0) format_exc_check_arg(PyExc_NameError, NAME_ERROR_MSG ,w); --- 1660,1664 ---- w = GETITEM(names, oparg); if ((x = f->f_locals) != NULL) { ! if ((err = PyObject_DelItem(x, w)) != 0) format_exc_check_arg(PyExc_NameError, NAME_ERROR_MSG ,w); *************** *** 1734,1738 **** case LOAD_NAME: w = GETITEM(names, oparg); ! if ((x = f->f_locals) == NULL) { PyErr_Format(PyExc_SystemError, "no locals when loading %s", --- 1737,1741 ---- case LOAD_NAME: w = GETITEM(names, oparg); ! if ((v = f->f_locals) == NULL) { PyErr_Format(PyExc_SystemError, "no locals when loading %s", *************** *** 1740,1744 **** break; } ! x = PyDict_GetItem(x, w); if (x == NULL) { x = PyDict_GetItem(f->f_globals, w); --- 1743,1756 ---- break; } ! if (PyDict_CheckExact(v)) ! x = PyDict_GetItem(v, w); ! else { ! x = PyObject_GetItem(v, w); ! if (x == NULL && PyErr_Occurred()) { ! if (!PyErr_ExceptionMatches(PyExc_KeyError)) ! break; ! PyErr_Clear(); ! } ! } if (x == NULL) { x = PyDict_GetItem(f->f_globals, w); From rhettinger at users.sourceforge.net Fri Jul 2 02:41:37 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jul 2 02:41:41 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libfuncs.tex,1.165,1.166 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18086/Doc/lib Modified Files: libfuncs.tex Log Message: SF Bug #215126: Over restricted type checking on eval() function The builtin eval() function now accepts any mapping for the locals argument. Time sensitive steps guarded by PyDict_CheckExact() to keep from slowing down the normal case. My timings so no measurable impact. Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.165 retrieving revision 1.166 diff -C2 -d -r1.165 -r1.166 *** libfuncs.tex 5 May 2004 16:49:11 -0000 1.165 --- libfuncs.tex 2 Jul 2004 06:41:04 -0000 1.166 *************** *** 292,297 **** \begin{funcdesc}{eval}{expression\optional{, globals\optional{, locals}}} ! The arguments are a string and two optional dictionaries. The ! \var{expression} argument is parsed and evaluated as a Python expression (technically speaking, a condition list) using the \var{globals} and \var{locals} dictionaries as global and local name --- 292,301 ---- \begin{funcdesc}{eval}{expression\optional{, globals\optional{, locals}}} ! The arguments are a string and optional globals and locals. If provided, ! \var{globals} must be a dictionary. If provided, \var{locals} can be ! any mapping object. \versionchanged[formerly \var{locals} was required ! to be a dictionary]{2.4} ! ! The \var{expression} argument is parsed and evaluated as a Python expression (technically speaking, a condition list) using the \var{globals} and \var{locals} dictionaries as global and local name From rhettinger at users.sourceforge.net Fri Jul 2 02:41:37 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jul 2 02:41:42 2004 Subject: [Python-checkins] python/dist/src/Include frameobject.h,2.37,2.38 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18086/Include Modified Files: frameobject.h Log Message: SF Bug #215126: Over restricted type checking on eval() function The builtin eval() function now accepts any mapping for the locals argument. Time sensitive steps guarded by PyDict_CheckExact() to keep from slowing down the normal case. My timings so no measurable impact. Index: frameobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/frameobject.h,v retrieving revision 2.37 retrieving revision 2.38 diff -C2 -d -r2.37 -r2.38 *** frameobject.h 11 Sep 2002 15:36:31 -0000 2.37 --- frameobject.h 2 Jul 2004 06:41:04 -0000 2.38 *************** *** 20,24 **** PyObject *f_builtins; /* builtin symbol table (PyDictObject) */ PyObject *f_globals; /* global symbol table (PyDictObject) */ ! PyObject *f_locals; /* local symbol table (PyDictObject) */ PyObject **f_valuestack; /* points after the last local */ /* Next free slot in f_valuestack. Frame creation sets to f_valuestack. --- 20,24 ---- PyObject *f_builtins; /* builtin symbol table (PyDictObject) */ PyObject *f_globals; /* global symbol table (PyDictObject) */ ! PyObject *f_locals; /* local symbol table (any mapping) */ PyObject **f_valuestack; /* points after the last local */ /* Next free slot in f_valuestack. Frame creation sets to f_valuestack. From rhettinger at users.sourceforge.net Fri Jul 2 02:41:38 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jul 2 02:41:47 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_builtin.py, 1.29, 1.30 test_descrtut.py, 1.19, 1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18086/Lib/test Modified Files: test_builtin.py test_descrtut.py Log Message: SF Bug #215126: Over restricted type checking on eval() function The builtin eval() function now accepts any mapping for the locals argument. Time sensitive steps guarded by PyDict_CheckExact() to keep from slowing down the normal case. My timings so no measurable impact. Index: test_builtin.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_builtin.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** test_builtin.py 12 Feb 2004 17:35:11 -0000 1.29 --- test_builtin.py 2 Jul 2004 06:41:05 -0000 1.30 *************** *** 4,8 **** from test.test_support import fcmp, have_unicode, TESTFN, unlink ! import sys, warnings, cStringIO, random warnings.filterwarnings("ignore", "hex../oct.. of negative int", FutureWarning, __name__) --- 4,8 ---- from test.test_support import fcmp, have_unicode, TESTFN, unlink ! import sys, warnings, cStringIO, random, UserDict warnings.filterwarnings("ignore", "hex../oct.. of negative int", FutureWarning, __name__) *************** *** 263,266 **** --- 263,320 ---- self.assertRaises(TypeError, eval, ()) + def test_general_eval(self): + # Tests that general mappings can be used for the locals argument + + class M: + "Test mapping interface versus possible calls from eval()." + def __getitem__(self, key): + if key == 'a': + return 12 + raise KeyError + def keys(self): + return list('xyz') + + m = M() + g = globals() + self.assertEqual(eval('a', g, m), 12) + self.assertRaises(NameError, eval, 'b', g, m) + self.assertEqual(eval('dir()', g, m), list('xyz')) + self.assertEqual(eval('globals()', g, m), g) + self.assertEqual(eval('locals()', g, m), m) + + # Verify that dict subclasses work as well + class D(dict): + def __getitem__(self, key): + if key == 'a': + return 12 + return dict.__getitem__(self, key) + def keys(self): + return list('xyz') + + d = D() + self.assertEqual(eval('a', g, d), 12) + self.assertRaises(NameError, eval, 'b', g, d) + self.assertEqual(eval('dir()', g, d), list('xyz')) + self.assertEqual(eval('globals()', g, d), g) + self.assertEqual(eval('locals()', g, d), d) + + # Verify locals stores (used by list comps) + eval('[locals() for i in (2,3)]', g, d) + eval('[locals() for i in (2,3)]', g, UserDict.UserDict()) + + class SpreadSheet: + "Sample application showing nested, calculated lookups." + _cells = {} + def __setitem__(self, key, formula): + self._cells[key] = formula + def __getitem__(self, key ): + return eval(self._cells[key], globals(), self) + + ss = SpreadSheet() + ss['a1'] = '5' + ss['a2'] = 'a1*6' + ss['a3'] = 'a2*7' + self.assertEqual(ss['a3'], 210) + # Done outside of the method test_z to get the correct scope z = 0 Index: test_descrtut.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descrtut.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** test_descrtut.py 17 Dec 2003 20:43:32 -0000 1.19 --- test_descrtut.py 2 Jul 2004 06:41:05 -0000 1.20 *************** *** 79,92 **** >>> - However, our __getitem__() method is not used for variable access by the - interpreter: - - >>> exec "print foo" in a - Traceback (most recent call last): - File "", line 1, in ? - File "", line 1, in ? - NameError: name 'foo' is not defined - >>> - Now I'll show that defaultdict instances have dynamic instance variables, just like classic classes: --- 79,82 ---- From theller at users.sourceforge.net Fri Jul 2 03:54:24 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Jul 2 03:54:29 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils/command wininst.exe, 1.1.16.2, 1.1.16.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30999 Modified Files: Tag: release23-maint wininst.exe Log Message: Fix for SF 982215: bdist_wininst - Next button not greyed out during file copy. Patch from Mark Hammond. Recompiled binary. Index: wininst.exe =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/Attic/wininst.exe,v retrieving revision 1.1.16.2 retrieving revision 1.1.16.3 diff -C2 -d -r1.1.16.2 -r1.1.16.3 Binary files /tmp/cvs5eckkL and /tmp/cvsccJiCP differ From theller at users.sourceforge.net Fri Jul 2 03:54:33 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Jul 2 03:54:36 2004 Subject: [Python-checkins] python/dist/src/PC/bdist_wininst install.c, 1.1.14.1, 1.1.14.2 Message-ID: Update of /cvsroot/python/python/dist/src/PC/bdist_wininst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31021 Modified Files: Tag: release23-maint install.c Log Message: Fix for SF 982215: bdist_wininst - Next button not greyed out during file copy. Patch from Mark Hammond. Recompiled binary. Index: install.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/install.c,v retrieving revision 1.1.14.1 retrieving revision 1.1.14.2 diff -C2 -d -r1.1.14.1 -r1.1.14.2 *** install.c 15 Apr 2004 17:50:42 -0000 1.1.14.1 --- install.c 2 Jul 2004 07:54:30 -0000 1.1.14.2 *************** *** 1590,1593 **** --- 1590,1601 ---- hDialog = hwnd; + /* Disable the buttons while we work. Sending CANCELTOCLOSE has + the effect of disabling the cancel button, which is a) as we + do everything synchronously we can't cancel, and b) the next + step is 'finished', when it is too late to cancel anyway. + The next step being 'Finished' means we also don't need to + restore the button state back */ + PropSheet_SetWizButtons(GetParent(hwnd), 0); + SendMessage(GetParent(hwnd), PSM_CANCELTOCLOSE, 0, 0); /* Make sure the installation directory name ends in a */ /* backslash */ From theller at users.sourceforge.net Fri Jul 2 04:02:34 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Jul 2 04:02:37 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils/command wininst-7.1.exe, 1.2, 1.3 wininst-6.exe, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32602 Modified Files: wininst-7.1.exe wininst-6.exe Log Message: Fix for SF 982215: bdist_wininst - Next button not greyed out during file copy. Patch from Mark Hammond. Recompiled binary. Already packported to the 2.3 branch. Index: wininst-7.1.exe =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/wininst-7.1.exe,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 Binary files /tmp/cvs7kozMZ and /tmp/cvsheQlj4 differ Index: wininst-6.exe =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/wininst-6.exe,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 Binary files /tmp/cvsNm2oU6 and /tmp/cvsBSZQub differ From theller at users.sourceforge.net Fri Jul 2 04:02:43 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Jul 2 04:02:47 2004 Subject: [Python-checkins] python/dist/src/PC/bdist_wininst install.c, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/PC/bdist_wininst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32663 Modified Files: install.c Log Message: Fix for SF 982215: bdist_wininst - Next button not greyed out during file copy. Patch from Mark Hammond. Recompiled binary. Already packported to the 2.3 branch. Index: install.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/install.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** install.c 18 Jun 2004 17:03:38 -0000 1.4 --- install.c 2 Jul 2004 08:02:40 -0000 1.5 *************** *** 1709,1712 **** --- 1709,1720 ---- success = TRUE; + /* Disable the buttons while we work. Sending CANCELTOCLOSE has + the effect of disabling the cancel button, which is a) as we + do everything synchronously we can't cancel, and b) the next + step is 'finished', when it is too late to cancel anyway. + The next step being 'Finished' means we also don't need to + restore the button state back */ + PropSheet_SetWizButtons(GetParent(hwnd), 0); + SendMessage(GetParent(hwnd), PSM_CANCELTOCLOSE, 0, 0); /* Make sure the installation directory name ends in a */ /* backslash */ From theller at users.sourceforge.net Fri Jul 2 04:09:29 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Jul 2 04:09:32 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.125, 1.831.4.126 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1432 Modified Files: Tag: release23-maint NEWS Log Message: SF #982215 is fixed. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.125 retrieving revision 1.831.4.126 diff -C2 -d -r1.831.4.125 -r1.831.4.126 *** NEWS 29 Jun 2004 04:05:57 -0000 1.831.4.125 --- NEWS 2 Jul 2004 08:09:12 -0000 1.831.4.126 *************** *** 38,41 **** --- 38,44 ---- ------- + - Bug #982215: The Back and Next buttons in bdist_wininst installers are now + disabled during file copy operations. + - Bug #981299: rsync is now a recognized protocol in urlparse that uses a "netloc" portion of a URL. From theller at users.sourceforge.net Fri Jul 2 04:37:38 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Jul 2 04:37:42 2004 Subject: [Python-checkins] python/dist/src/Python dynload_win.c, 2.12, 2.12.14.1 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7473 Modified Files: Tag: release23-maint dynload_win.c Log Message: When importing an extension on Windows, the code reads the PE 'import table' of the dll, to make sure that the dll really was build for the correct Python version. It does this by looking for an entry 'pythonXY.dll' (X.Y is the Python version number). The code now checks the size of the dll's import table before reading entries from it. Before this patch, the code crashed trying to read the import table when the size was zero (as in Win2k's wmi.dll, for example). Look for imports of 'pythonXY_d.dll' in a debug build instead of 'pythonXY.dll'. Fixes SF 951851: Crash when reading "import table" of certain windows dlls. Index: dynload_win.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/dynload_win.c,v retrieving revision 2.12 retrieving revision 2.12.14.1 diff -C2 -d -r2.12 -r2.12.14.1 *** dynload_win.c 26 Aug 2002 21:20:30 -0000 2.12 --- dynload_win.c 2 Jul 2004 08:37:35 -0000 2.12.14.1 *************** *** 117,120 **** --- 117,124 ---- if (DWORD_AT(dllbase + opt_offset + num_dict_off) >= 2) { + /* We have at least 2 tables - the import table is the second + one. But still it may be that the table size is zero */ + if (0 == DWORD_AT(dllbase + opt_offset + import_off + sizeof(DWORD))) + return NULL; import_data = dllbase + DWORD_AT(dllbase + opt_offset + *************** *** 129,133 **** --- 133,141 ---- by numbers to the end of the basename */ pch = import_name + 6; + #ifdef _DEBUG + while (*pch && pch[0] != '_' && pch[1] != 'd' && pch[2] != '.') { + #else while (*pch && *pch != '.') { + #endif if (*pch >= '0' && *pch <= '9') { pch++; *************** *** 222,226 **** --- 230,238 ---- char buffer[256]; + #ifdef _DEBUG + PyOS_snprintf(buffer, sizeof(buffer), "python%d%d_d.dll", + #else PyOS_snprintf(buffer, sizeof(buffer), "python%d%d.dll", + #endif PY_MAJOR_VERSION,PY_MINOR_VERSION); import_python = GetPythonImport(hDLL); From theller at users.sourceforge.net Fri Jul 2 04:40:31 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Jul 2 04:40:35 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.126, 1.831.4.127 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7951 Modified Files: Tag: release23-maint NEWS Log Message: SF #951851 is fixed. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.126 retrieving revision 1.831.4.127 diff -C2 -d -r1.831.4.126 -r1.831.4.127 *** NEWS 2 Jul 2004 08:09:12 -0000 1.831.4.126 --- NEWS 2 Jul 2004 08:40:28 -0000 1.831.4.127 *************** *** 13,16 **** --- 13,19 ---- ----------------- + - Bug #951851: Python crashed when reading import table of certain + Windows DLLs + - Bug #966623. classes created with type() in an exec(, {}) don't have a __module__, but code in typeobject assumed it would always From theller at users.sourceforge.net Fri Jul 2 04:54:00 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Jul 2 04:54:03 2004 Subject: [Python-checkins] python/dist/src/Python dynload_win.c,2.12,2.13 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9904 Modified Files: dynload_win.c Log Message: When importing an extension on Windows, the code reads the PE 'import table' of the dll, to make sure that the dll really was build for the correct Python version. It does this by looking for an entry 'pythonXY.dll' (X.Y is the Python version number). The code now checks the size of the dll's import table before reading entries from it. Before this patch, the code crashed trying to read the import table when the size was zero (as in Win2k's wmi.dll, for example). Look for imports of 'pythonXY_d.dll' in a debug build instead of 'pythonXY.dll'. Fixes SF 951851: Crash when reading "import table" of certain windows dlls. Already backported to the 2.3 branch. Index: dynload_win.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/dynload_win.c,v retrieving revision 2.12 retrieving revision 2.13 diff -C2 -d -r2.12 -r2.13 *** dynload_win.c 26 Aug 2002 21:20:30 -0000 2.12 --- dynload_win.c 2 Jul 2004 08:53:57 -0000 2.13 *************** *** 117,120 **** --- 117,124 ---- if (DWORD_AT(dllbase + opt_offset + num_dict_off) >= 2) { + /* We have at least 2 tables - the import table is the second + one. But still it may be that the table size is zero */ + if (0 == DWORD_AT(dllbase + opt_offset + import_off + sizeof(DWORD))) + return NULL; import_data = dllbase + DWORD_AT(dllbase + opt_offset + *************** *** 129,133 **** --- 133,141 ---- by numbers to the end of the basename */ pch = import_name + 6; + #ifdef _DEBUG + while (*pch && pch[0] != '_' && pch[1] != 'd' && pch[2] != '.') { + #else while (*pch && *pch != '.') { + #endif if (*pch >= '0' && *pch <= '9') { pch++; *************** *** 222,226 **** --- 230,238 ---- char buffer[256]; + #ifdef _DEBUG + PyOS_snprintf(buffer, sizeof(buffer), "python%d%d_d.dll", + #else PyOS_snprintf(buffer, sizeof(buffer), "python%d%d.dll", + #endif PY_MAJOR_VERSION,PY_MINOR_VERSION); import_python = GetPythonImport(hDLL); From theller at users.sourceforge.net Fri Jul 2 04:56:23 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Jul 2 04:56:28 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1018,1.1019 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10448 Modified Files: NEWS Log Message: SF #951851 fixed. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1018 retrieving revision 1.1019 diff -C2 -d -r1.1018 -r1.1019 *** NEWS 2 Jul 2004 06:41:05 -0000 1.1018 --- NEWS 2 Jul 2004 08:56:20 -0000 1.1019 *************** *** 13,16 **** --- 13,19 ---- ----------------- + - Bug #951851: Python crashed when reading import table of certain + Windows DLLs. + - Bug #215126. The locals argument to eval() now accepts any mapping type. From theller at users.sourceforge.net Fri Jul 2 04:58:49 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Fri Jul 2 04:58:51 2004 Subject: [Python-checkins] python/dist/src/PCbuild readme.txt,1.53,1.54 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10792 Modified Files: readme.txt Log Message: Update info about the windows build. Index: readme.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/readme.txt,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** readme.txt 11 Apr 2004 19:02:59 -0000 1.53 --- readme.txt 2 Jul 2004 08:58:46 -0000 1.54 *************** *** 171,176 **** With or without strong cryptography? You can choose either with or without strong cryptography, as per the instructions below. By ! default, Python is built and distributed WITHOUT strong crypto ! XXX - is the above correct? Unpack into the dist\. directory, ensuring you expand with folder names. --- 171,175 ---- With or without strong cryptography? You can choose either with or without strong cryptography, as per the instructions below. By ! default, Python is built and distributed WITHOUT strong crypto. Unpack into the dist\. directory, ensuring you expand with folder names. *************** *** 265,269 **** Unpack into the "dist" directory, retaining the folder name from the archive - for example, the latest stable OpenSSL will install as ! dist/openssl-0.9.6g You can (theoretically) use any version of OpenSSL you like - the --- 264,268 ---- Unpack into the "dist" directory, retaining the folder name from the archive - for example, the latest stable OpenSSL will install as ! dist/openssl-0.9.7d You can (theoretically) use any version of OpenSSL you like - the From fdrake at users.sourceforge.net Fri Jul 2 14:57:46 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri Jul 2 14:57:51 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1019,1.1020 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8493/Misc Modified Files: NEWS Log Message: Make weak references subclassable: - weakref.ref and weakref.ReferenceType will become aliases for each other - weakref.ref will be a modern, new-style class with proper __new__ and __init__ methods - weakref.WeakValueDictionary will have a lighter memory footprint, using a new weakref.ref subclass to associate the key with the value, allowing us to have only a single object of overhead for each dictionary entry (currently, there are 3 objects of overhead per entry: a weakref to the value, a weakref to the dictionary, and a function object used as a weakref callback; the weakref to the dictionary could be avoided without this change) - a new macro, PyWeakref_CheckRefExact(), will be added - PyWeakref_CheckRef() will check for subclasses of weakref.ref This closes SF patch #983019. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1019 retrieving revision 1.1020 diff -C2 -d -r1.1019 -r1.1020 *** NEWS 2 Jul 2004 08:56:20 -0000 1.1019 --- NEWS 2 Jul 2004 18:57:42 -0000 1.1020 *************** *** 13,16 **** --- 13,21 ---- ----------------- + - weakref.ref is now the type object also known as + weakref.ReferenceType; it can be subclassed like any other new-style + class. There's less per-entry overhead in WeakValueDictionary + objects now (one object instead of three). + - Bug #951851: Python crashed when reading import table of certain Windows DLLs. From fdrake at users.sourceforge.net Fri Jul 2 14:57:46 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri Jul 2 14:57:54 2004 Subject: [Python-checkins] python/dist/src/Modules _weakref.c,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8493/Modules Modified Files: _weakref.c Log Message: Make weak references subclassable: - weakref.ref and weakref.ReferenceType will become aliases for each other - weakref.ref will be a modern, new-style class with proper __new__ and __init__ methods - weakref.WeakValueDictionary will have a lighter memory footprint, using a new weakref.ref subclass to associate the key with the value, allowing us to have only a single object of overhead for each dictionary entry (currently, there are 3 objects of overhead per entry: a weakref to the value, a weakref to the dictionary, and a function object used as a weakref callback; the weakref to the dictionary could be avoided without this change) - a new macro, PyWeakref_CheckRefExact(), will be added - PyWeakref_CheckRef() will check for subclasses of weakref.ref This closes SF patch #983019. Index: _weakref.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_weakref.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** _weakref.c 2 Aug 2002 20:23:40 -0000 1.18 --- _weakref.c 2 Jul 2004 18:57:43 -0000 1.19 *************** *** 58,81 **** - PyDoc_STRVAR(weakref_ref__doc__, - "ref(object[, callback]) -- create a weak reference to 'object';\n" - "when 'object' is finalized, 'callback' will be called and passed\n" - "a reference to the weak reference object when 'object' is about\n" - "to be finalized."); - - static PyObject * - weakref_ref(PyObject *self, PyObject *args) - { - PyObject *object; - PyObject *callback = NULL; - PyObject *result = NULL; - - if (PyArg_UnpackTuple(args, "ref", 1, 2, &object, &callback)) { - result = PyWeakref_NewRef(object, callback); - } - return result; - } - - PyDoc_STRVAR(weakref_proxy__doc__, "proxy(object[, callback]) -- create a proxy object that weakly\n" --- 58,61 ---- *************** *** 105,110 **** {"proxy", weakref_proxy, METH_VARARGS, weakref_proxy__doc__}, - {"ref", weakref_ref, METH_VARARGS, - weakref_ref__doc__}, {NULL, NULL, 0, NULL} }; --- 85,88 ---- *************** *** 120,123 **** --- 98,104 ---- if (m != NULL) { Py_INCREF(&_PyWeakref_RefType); + PyModule_AddObject(m, "ref", + (PyObject *) &_PyWeakref_RefType); + Py_INCREF(&_PyWeakref_RefType); PyModule_AddObject(m, "ReferenceType", (PyObject *) &_PyWeakref_RefType); From fdrake at users.sourceforge.net Fri Jul 2 14:57:47 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri Jul 2 14:57:58 2004 Subject: [Python-checkins] python/dist/src/Objects object.c, 2.218, 2.219 weakrefobject.c, 1.16, 1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8493/Objects Modified Files: object.c weakrefobject.c Log Message: Make weak references subclassable: - weakref.ref and weakref.ReferenceType will become aliases for each other - weakref.ref will be a modern, new-style class with proper __new__ and __init__ methods - weakref.WeakValueDictionary will have a lighter memory footprint, using a new weakref.ref subclass to associate the key with the value, allowing us to have only a single object of overhead for each dictionary entry (currently, there are 3 objects of overhead per entry: a weakref to the value, a weakref to the dictionary, and a function object used as a weakref callback; the weakref to the dictionary could be avoided without this change) - a new macro, PyWeakref_CheckRefExact(), will be added - PyWeakref_CheckRef() will check for subclasses of weakref.ref This closes SF patch #983019. Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.218 retrieving revision 2.219 diff -C2 -d -r2.218 -r2.219 *** object.c 2 Jul 2004 06:41:06 -0000 2.218 --- object.c 2 Jul 2004 18:57:44 -0000 2.219 *************** *** 1803,1806 **** --- 1803,1809 ---- Py_FatalError("Can't initialize 'type'"); + if (PyType_Ready(&_PyWeakref_RefType) < 0) + Py_FatalError("Can't initialize 'weakref'"); + if (PyType_Ready(&PyBool_Type) < 0) Py_FatalError("Can't initialize 'bool'"); Index: weakrefobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/weakrefobject.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** weakrefobject.c 4 Feb 2004 23:14:14 -0000 1.16 --- weakrefobject.c 2 Jul 2004 18:57:45 -0000 1.17 *************** *** 20,23 **** --- 20,32 ---- + static void + init_weakref(PyWeakReference *self, PyObject *ob, PyObject *callback) + { + self->hash = -1; + self->wr_object = ob; + Py_XINCREF(callback); + self->wr_callback = callback; + } + static PyWeakReference * new_weakref(PyObject *ob, PyObject *callback) *************** *** 27,34 **** result = PyObject_GC_New(PyWeakReference, &_PyWeakref_RefType); if (result) { ! result->hash = -1; ! result->wr_object = ob; ! Py_XINCREF(callback); ! result->wr_callback = callback; PyObject_GC_Track(result); } --- 36,40 ---- result = PyObject_GC_New(PyWeakReference, &_PyWeakref_RefType); if (result) { ! init_weakref(result, ob, callback); PyObject_GC_Track(result); } *************** *** 93,101 **** static void ! weakref_dealloc(PyWeakReference *self) { ! PyObject_GC_UnTrack((PyObject *)self); ! clear_weakref(self); ! PyObject_GC_Del(self); } --- 99,107 ---- static void ! weakref_dealloc(PyObject *self) { ! PyObject_GC_UnTrack(self); ! clear_weakref((PyWeakReference *) self); ! self->ob_type->tp_free(self); } *************** *** 194,197 **** --- 200,331 ---- } + /* Given the head of an object's list of weak references, extract the + * two callback-less refs (ref and proxy). Used to determine if the + * shared references exist and to determine the back link for newly + * inserted references. + */ + static void + get_basic_refs(PyWeakReference *head, + PyWeakReference **refp, PyWeakReference **proxyp) + { + *refp = NULL; + *proxyp = NULL; + + if (head != NULL && head->wr_callback == NULL) { + /* We need to be careful that the "basic refs" aren't + subclasses of the main types. That complicates this a + little. */ + if (PyWeakref_CheckRefExact(head)) { + *refp = head; + head = head->wr_next; + } + if (head != NULL + && head->wr_callback == NULL + && PyWeakref_CheckProxy(head)) { + *proxyp = head; + /* head = head->wr_next; */ + } + } + } + + /* Insert 'newref' in the list after 'prev'. Both must be non-NULL. */ + static void + insert_after(PyWeakReference *newref, PyWeakReference *prev) + { + newref->wr_prev = prev; + newref->wr_next = prev->wr_next; + if (prev->wr_next != NULL) + prev->wr_next->wr_prev = newref; + prev->wr_next = newref; + } + + /* Insert 'newref' at the head of the list; 'list' points to the variable + * that stores the head. + */ + static void + insert_head(PyWeakReference *newref, PyWeakReference **list) + { + PyWeakReference *next = *list; + + newref->wr_prev = NULL; + newref->wr_next = next; + if (next != NULL) + next->wr_prev = newref; + *list = newref; + } + + static int + parse_weakref_init_args(char *funcname, PyObject *args, PyObject *kwargs, + PyObject **obp, PyObject **callbackp) + { + /* XXX Should check that kwargs == NULL or is empty. */ + return PyArg_UnpackTuple(args, funcname, 1, 2, obp, callbackp); + } + + static PyObject * + weakref___new__(PyTypeObject *type, PyObject *args, PyObject *kwargs) + { + PyWeakReference *self = NULL; + PyObject *ob, *callback = NULL; + + if (parse_weakref_init_args("__new__", args, kwargs, &ob, &callback)) { + PyWeakReference *ref, *proxy; + PyWeakReference **list; + + if (!PyType_SUPPORTS_WEAKREFS(ob->ob_type)) { + PyErr_Format(PyExc_TypeError, + "cannot create weak reference to '%s' object", + ob->ob_type->tp_name); + return NULL; + } + if (callback == Py_None) + callback = NULL; + list = GET_WEAKREFS_LISTPTR(ob); + get_basic_refs(*list, &ref, &proxy); + if (callback == NULL && type == &_PyWeakref_RefType) { + if (ref != NULL) { + /* We can re-use an existing reference. */ + Py_INCREF(ref); + return (PyObject *)ref; + } + } + /* We have to create a new reference. */ + /* Note: the tp_alloc() can trigger cyclic GC, so the weakref + list on ob can be mutated. This means that the ref and + proxy pointers we got back earlier may have been collected, + so we need to compute these values again before we use + them. */ + self = (PyWeakReference *) (type->tp_alloc(type, 0)); + if (self != NULL) { + init_weakref(self, ob, callback); + if (callback == NULL && type == &_PyWeakref_RefType) { + insert_head(self, list); + } + else { + PyWeakReference *prev; + + get_basic_refs(*list, &ref, &proxy); + prev = (proxy == NULL) ? ref : proxy; + if (prev == NULL) + insert_head(self, list); + else + insert_after(self, prev); + } + } + } + return (PyObject *)self; + } + + static int + weakref___init__(PyObject *self, PyObject *args, PyObject *kwargs) + { + PyObject *tmp; + + if (parse_weakref_init_args("__init__", args, kwargs, &tmp, &tmp)) + return 0; + else + return 1; + } + PyTypeObject *************** *** 202,206 **** sizeof(PyWeakReference), 0, ! (destructor)weakref_dealloc,/*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ --- 336,340 ---- sizeof(PyWeakReference), 0, ! weakref_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ *************** *** 211,215 **** 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ ! (hashfunc)weakref_hash, /*tp_hash*/ (ternaryfunc)weakref_call, /*tp_call*/ 0, /*tp_str*/ --- 345,349 ---- 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ ! (hashfunc)weakref_hash, /*tp_hash*/ (ternaryfunc)weakref_call, /*tp_call*/ 0, /*tp_str*/ *************** *** 217,226 **** 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_RICHCOMPARE, 0, /*tp_doc*/ (traverseproc)gc_traverse, /*tp_traverse*/ (inquiry)gc_clear, /*tp_clear*/ (richcmpfunc)weakref_richcompare, /*tp_richcompare*/ ! 0, /*tp_weaklistoffset*/ }; --- 351,375 ---- 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_RICHCOMPARE ! | Py_TPFLAGS_BASETYPE, /*tp_flags*/ 0, /*tp_doc*/ (traverseproc)gc_traverse, /*tp_traverse*/ (inquiry)gc_clear, /*tp_clear*/ (richcmpfunc)weakref_richcompare, /*tp_richcompare*/ ! 0, /*tp_weaklistoffset*/ ! 0, /*tp_iter*/ ! 0, /*tp_iternext*/ ! 0, /*tp_methods*/ ! 0, /*tp_members*/ ! 0, /*tp_getset*/ ! 0, /*tp_base*/ ! 0, /*tp_dict*/ ! 0, /*tp_descr_get*/ ! 0, /*tp_descr_set*/ ! 0, /*tp_dictoffset*/ ! (initproc)weakref___init__, /*tp_init*/ ! PyType_GenericAlloc, /*tp_alloc*/ ! weakref___new__, /*tp_new*/ ! PyObject_GC_Del, /*tp_free*/ }; *************** *** 364,367 **** --- 513,525 ---- } + static void + proxy_dealloc(PyWeakReference *self) + { + if (self->wr_callback != NULL) + PyObject_GC_UnTrack((PyObject *)self); + clear_weakref(self); + PyObject_GC_Del(self); + } + /* sequence slots */ *************** *** 497,501 **** 0, /* methods */ ! (destructor)weakref_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ --- 655,659 ---- 0, /* methods */ ! (destructor)proxy_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ *************** *** 532,536 **** 0, /* methods */ ! (destructor)weakref_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ --- 690,694 ---- 0, /* methods */ ! (destructor)proxy_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ *************** *** 559,612 **** - /* Given the head of an object's list of weak references, extract the - * two callback-less refs (ref and proxy). Used to determine if the - * shared references exist and to determine the back link for newly - * inserted references. - */ - static void - get_basic_refs(PyWeakReference *head, - PyWeakReference **refp, PyWeakReference **proxyp) - { - *refp = NULL; - *proxyp = NULL; - - if (head != NULL && head->wr_callback == NULL) { - if (head->ob_type == &_PyWeakref_RefType) { - *refp = head; - head = head->wr_next; - } - if (head != NULL && head->wr_callback == NULL) { - *proxyp = head; - head = head->wr_next; - } - } - } - - /* Insert 'newref' in the list after 'prev'. Both must be non-NULL. */ - static void - insert_after(PyWeakReference *newref, PyWeakReference *prev) - { - newref->wr_prev = prev; - newref->wr_next = prev->wr_next; - if (prev->wr_next != NULL) - prev->wr_next->wr_prev = newref; - prev->wr_next = newref; - } - - /* Insert 'newref' at the head of the list; 'list' points to the variable - * that stores the head. - */ - static void - insert_head(PyWeakReference *newref, PyWeakReference **list) - { - PyWeakReference *next = *list; - - newref->wr_prev = NULL; - newref->wr_next = next; - if (next != NULL) - next->wr_prev = newref; - *list = newref; - } - PyObject * --- 717,720 ---- *************** *** 770,775 **** current->wr_callback = NULL; clear_weakref(current); ! handle_callback(current, callback); ! Py_DECREF(callback); } else { --- 878,885 ---- current->wr_callback = NULL; clear_weakref(current); ! if (callback != NULL) { ! handle_callback(current, callback); ! Py_DECREF(callback); ! } } else { *************** *** 788,795 **** } for (i = 0; i < count; ++i) { - PyObject *current = PyTuple_GET_ITEM(tuple, i * 2); PyObject *callback = PyTuple_GET_ITEM(tuple, i * 2 + 1); ! handle_callback((PyWeakReference *)current, callback); } Py_DECREF(tuple); --- 898,907 ---- } for (i = 0; i < count; ++i) { PyObject *callback = PyTuple_GET_ITEM(tuple, i * 2 + 1); ! if (callback != NULL) { ! PyObject *current = PyTuple_GET_ITEM(tuple, i * 2); ! handle_callback((PyWeakReference *)current, callback); ! } } Py_DECREF(tuple); From fdrake at users.sourceforge.net Fri Jul 2 14:58:19 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri Jul 2 14:58:23 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_weakref.py, 1.40, 1.41 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8493/Lib/test Modified Files: test_weakref.py Log Message: Make weak references subclassable: - weakref.ref and weakref.ReferenceType will become aliases for each other - weakref.ref will be a modern, new-style class with proper __new__ and __init__ methods - weakref.WeakValueDictionary will have a lighter memory footprint, using a new weakref.ref subclass to associate the key with the value, allowing us to have only a single object of overhead for each dictionary entry (currently, there are 3 objects of overhead per entry: a weakref to the value, a weakref to the dictionary, and a function object used as a weakref callback; the weakref to the dictionary could be avoided without this change) - a new macro, PyWeakref_CheckRefExact(), will be added - PyWeakref_CheckRef() will check for subclasses of weakref.ref This closes SF patch #983019. Index: test_weakref.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_weakref.py,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** test_weakref.py 2 Jun 2004 18:42:25 -0000 1.40 --- test_weakref.py 2 Jul 2004 18:57:42 -0000 1.41 *************** *** 624,627 **** --- 624,693 ---- gc.set_threshold(*thresholds) + + class SubclassableWeakrefTestCase(unittest.TestCase): + + def test_subclass_refs(self): + class MyRef(weakref.ref): + def __init__(self, ob, callback=None, value=42): + self.value = value + super(MyRef, self).__init__(ob, callback) + def __call__(self): + self.called = True + return super(MyRef, self).__call__() + o = Object("foo") + mr = MyRef(o, value=24) + self.assert_(mr() is o) + self.assert_(mr.called) + self.assertEqual(mr.value, 24) + del o + self.assert_(mr() is None) + self.assert_(mr.called) + + def test_subclass_refs_dont_replace_standard_refs(self): + class MyRef(weakref.ref): + pass + o = Object(42) + r1 = MyRef(o) + r2 = weakref.ref(o) + self.assert_(r1 is not r2) + self.assertEqual(weakref.getweakrefs(o), [r2, r1]) + self.assertEqual(weakref.getweakrefcount(o), 2) + r3 = MyRef(o) + self.assertEqual(weakref.getweakrefcount(o), 3) + refs = weakref.getweakrefs(o) + self.assertEqual(len(refs), 3) + self.assert_(r2 is refs[0]) + self.assert_(r1 in refs[1:]) + self.assert_(r3 in refs[1:]) + + def test_subclass_refs_dont_conflate_callbacks(self): + class MyRef(weakref.ref): + pass + o = Object(42) + r1 = MyRef(o, id) + r2 = MyRef(o, str) + self.assert_(r1 is not r2) + refs = weakref.getweakrefs(o) + self.assert_(r1 in refs) + self.assert_(r2 in refs) + + def test_subclass_refs_with_slots(self): + class MyRef(weakref.ref): + __slots__ = "slot1", "slot2" + def __new__(type, ob, callback, slot1, slot2): + return weakref.ref.__new__(type, ob, callback) + def __init__(self, ob, callback, slot1, slot2): + self.slot1 = slot1 + self.slot2 = slot2 + def meth(self): + return self.slot1 + self.slot2 + o = Object(42) + r = MyRef(o, None, "abc", "def") + self.assertEqual(r.slot1, "abc") + self.assertEqual(r.slot2, "def") + self.assertEqual(r.meth(), "abcdef") + self.failIf(hasattr(r, "__dict__")) + + class Object: def __init__(self, arg): From fdrake at users.sourceforge.net Fri Jul 2 14:58:19 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri Jul 2 14:58:26 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libweakref.tex,1.26,1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8493/Doc/lib Modified Files: libweakref.tex Log Message: Make weak references subclassable: - weakref.ref and weakref.ReferenceType will become aliases for each other - weakref.ref will be a modern, new-style class with proper __new__ and __init__ methods - weakref.WeakValueDictionary will have a lighter memory footprint, using a new weakref.ref subclass to associate the key with the value, allowing us to have only a single object of overhead for each dictionary entry (currently, there are 3 objects of overhead per entry: a weakref to the value, a weakref to the dictionary, and a function object used as a weakref callback; the weakref to the dictionary could be avoided without this change) - a new macro, PyWeakref_CheckRefExact(), will be added - PyWeakref_CheckRef() will check for subclasses of weakref.ref This closes SF patch #983019. Index: libweakref.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libweakref.tex,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** libweakref.tex 12 Jun 2004 06:56:44 -0000 1.26 --- libweakref.tex 2 Jul 2004 18:57:41 -0000 1.27 *************** *** 69,73 **** ! \begin{funcdesc}{ref}{object\optional{, callback}} Return a weak reference to \var{object}. The original object can be retrieved by calling the reference object if the referent is still --- 69,73 ---- ! \begin{classdesc}{ref}{object\optional{, callback}} Return a weak reference to \var{object}. The original object can be retrieved by calling the reference object if the referent is still *************** *** 101,105 **** references are equal only if the reference objects are the same object. ! \end{funcdesc} \begin{funcdesc}{proxy}{object\optional{, callback}} --- 101,109 ---- references are equal only if the reference objects are the same object. ! ! \versionchanged[This is now a subclassable type rather than a ! factory function; it derives from \class{object}] ! {2.4} ! \end{classdesc} \begin{funcdesc}{proxy}{object\optional{, callback}} *************** *** 237,240 **** --- 241,279 ---- single-threaded applications. + Specialized versions of \class{ref} objects can be created through + subclassing. This is used in the implementation of the + \class{WeakValueDictionary} to reduce the memory overhead for each + entry in the mapping. This may be most useful to associate additional + information with a reference, but could also be used to insert + additional processing on calls to retrieve the referent. + + This example shows how a subclass of \class{ref} can be used to store + additional information about an object and affect the value that's + returned when the referent is accessed: + + \begin{verbatim} + import weakref + + class ExtendedRef(weakref.ref): + def __new__(cls, ob, callback=None, **annotations): + weakref.ref.__new__(cls, ob, callback) + self.__counter = 0 + + def __init__(self, ob, callback=None, **annotations): + super(ExtendedRef, self).__init__(ob, callback) + for k, v in annotations: + setattr(self, k, v) + + def __call__(self): + """Return a pair containing the referent and the number of + times the reference has been called. + """ + ob = super(ExtendedRef, self)() + if ob is not None: + self.__counter += 1 + ob = (ob, self.__counter) + return ob + \end{verbatim} + \subsection{Example \label{weakref-example}} From fdrake at users.sourceforge.net Fri Jul 2 14:58:19 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri Jul 2 14:58:28 2004 Subject: [Python-checkins] python/dist/src/Include weakrefobject.h,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8493/Include Modified Files: weakrefobject.h Log Message: Make weak references subclassable: - weakref.ref and weakref.ReferenceType will become aliases for each other - weakref.ref will be a modern, new-style class with proper __new__ and __init__ methods - weakref.WeakValueDictionary will have a lighter memory footprint, using a new weakref.ref subclass to associate the key with the value, allowing us to have only a single object of overhead for each dictionary entry (currently, there are 3 objects of overhead per entry: a weakref to the value, a weakref to the dictionary, and a function object used as a weakref callback; the weakref to the dictionary could be avoided without this change) - a new macro, PyWeakref_CheckRefExact(), will be added - PyWeakref_CheckRef() will check for subclasses of weakref.ref This closes SF patch #983019. Index: weakrefobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/weakrefobject.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** weakrefobject.h 20 Nov 2003 21:21:45 -0000 1.4 --- weakrefobject.h 2 Jul 2004 18:57:42 -0000 1.5 *************** *** 23,31 **** PyAPI_DATA(PyTypeObject) _PyWeakref_CallableProxyType; ! #define PyWeakref_CheckRef(op) \ ((op)->ob_type == &_PyWeakref_RefType) #define PyWeakref_CheckProxy(op) \ (((op)->ob_type == &_PyWeakref_ProxyType) || \ ((op)->ob_type == &_PyWeakref_CallableProxyType)) #define PyWeakref_Check(op) \ (PyWeakref_CheckRef(op) || PyWeakref_CheckProxy(op)) --- 23,36 ---- PyAPI_DATA(PyTypeObject) _PyWeakref_CallableProxyType; ! #define PyWeakref_CheckRef(op) PyObject_TypeCheck(op, &_PyWeakref_RefType) ! #define PyWeakref_CheckRefExact(op) \ ((op)->ob_type == &_PyWeakref_RefType) #define PyWeakref_CheckProxy(op) \ (((op)->ob_type == &_PyWeakref_ProxyType) || \ ((op)->ob_type == &_PyWeakref_CallableProxyType)) + + /* This macro calls PyWeakref_CheckRef() last since that can involve a + function call; this makes it more likely that the function call + will be avoided. */ #define PyWeakref_Check(op) \ (PyWeakref_CheckRef(op) || PyWeakref_CheckProxy(op)) From fdrake at users.sourceforge.net Fri Jul 2 14:58:19 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri Jul 2 14:58:30 2004 Subject: [Python-checkins] python/dist/src/Lib weakref.py,1.22,1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8493/Lib Modified Files: weakref.py Log Message: Make weak references subclassable: - weakref.ref and weakref.ReferenceType will become aliases for each other - weakref.ref will be a modern, new-style class with proper __new__ and __init__ methods - weakref.WeakValueDictionary will have a lighter memory footprint, using a new weakref.ref subclass to associate the key with the value, allowing us to have only a single object of overhead for each dictionary entry (currently, there are 3 objects of overhead per entry: a weakref to the value, a weakref to the dictionary, and a function object used as a weakref callback; the weakref to the dictionary could be avoided without this change) - a new macro, PyWeakref_CheckRefExact(), will be added - PyWeakref_CheckRef() will check for subclasses of weakref.ref This closes SF patch #983019. Index: weakref.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/weakref.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** weakref.py 27 May 2004 18:16:25 -0000 1.22 --- weakref.py 2 Jul 2004 18:57:42 -0000 1.23 *************** *** 43,46 **** --- 43,54 ---- # way in). + def __init__(self, *args, **kw): + UserDict.UserDict.__init__(self, *args, **kw) + def remove(wr, selfref=ref(self)): + self = selfref() + if self is not None: + del self.data[wr.key] + self._remove = remove + def __getitem__(self, key): o = self.data[key]() *************** *** 54,58 **** def __setitem__(self, key, value): ! self.data[key] = ref(value, self.__makeremove(key)) def copy(self): --- 62,66 ---- def __setitem__(self, key, value): ! self.data[key] = KeyedRef(value, self._remove, key) def copy(self): *************** *** 118,122 **** wr = self.data[key] except KeyError: ! self.data[key] = ref(default, self.__makeremove(key)) return default else: --- 126,130 ---- wr = self.data[key] except KeyError: ! self.data[key] = KeyedRef(default, self._remove, key) return default else: *************** *** 129,133 **** dict = type({})(dict) for key, o in dict.items(): ! d[key] = ref(o, self.__makeremove(key)) if len(kwargs): self.update(kwargs) --- 137,141 ---- dict = type({})(dict) for key, o in dict.items(): ! d[key] = KeyedRef(o, self._remove, key) if len(kwargs): self.update(kwargs) *************** *** 141,150 **** return L ! def __makeremove(self, key): ! def remove(o, selfref=ref(self), key=key): ! self = selfref() ! if self is not None: ! del self.data[key] ! return remove --- 149,172 ---- return L ! ! class KeyedRef(ref): ! """Specialized reference that includes a key corresponding to the value. ! ! This is used in the WeakValueDictionary to avoid having to create ! a function object for each key stored in the mapping. A shared ! callback object can use the 'key' attribute of a KeyedRef instead ! of getting a reference to the key from an enclosing scope. ! ! """ ! ! __slots__ = "key", ! ! def __new__(type, ob, callback, key): ! self = ref.__new__(type, ob, callback) ! self.key = key ! return self ! ! def __init__(self, ob, callback, key): ! super(KeyedRef, self).__init__(ob, callback) *************** *** 299,312 **** class WeakValuedItemIterator(BaseIter): def __init__(self, weakdict): ! self._next = weakdict.data.iteritems().next def next(self): while 1: ! key, wr = self._next() value = wr() if value is not None: ! return key, value ! ! ! # no longer needed ! del UserDict --- 321,330 ---- class WeakValuedItemIterator(BaseIter): def __init__(self, weakdict): ! self._next = weakdict.data.itervalues().next def next(self): while 1: ! wr = self._next() value = wr() if value is not None: ! return wr.key, value From doerwalter at users.sourceforge.net Fri Jul 2 15:00:23 2004 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Fri Jul 2 15:00:26 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_calendar.py, 1.5, 1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8958/Lib/test Modified Files: test_calendar.py Log Message: Add tests that check the result of calendar.monthcalendar() for a set of corner cases. Index: test_calendar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_calendar.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_calendar.py 1 May 2003 17:45:34 -0000 1.5 --- test_calendar.py 2 Jul 2004 19:00:09 -0000 1.6 *************** *** 55,60 **** self.assertEqual(len(d), 13) def test_main(): ! test_support.run_unittest(CalendarTestCase) if __name__ == "__main__": --- 55,138 ---- self.assertEqual(len(d), 13) + + class MonthCalendarTestCase(unittest.TestCase): + def setUp(self): + self.oldfirstweekday = calendar.firstweekday() + calendar.setfirstweekday(self.firstweekday) + + def tearDown(self): + calendar.setfirstweekday(self.oldfirstweekday) + + def check_weeks(self, year, month, weeks): + cal = calendar.monthcalendar(year, month) + self.assertEqual(len(cal), len(weeks)) + for i in xrange(len(weeks)): + self.assertEqual(weeks[i], sum(day != 0 for day in cal[i])) + + + class MondayTestCase(MonthCalendarTestCase): + firstweekday = calendar.MONDAY + + def test_february(self): + # A 28-day february starting of monday (7+7+7+7 days) + self.check_weeks(1999, 2, (7, 7, 7, 7)) + + # A 28-day february starting of tuesday (6+7+7+7+1 days) + self.check_weeks(2005, 2, (6, 7, 7, 7, 1)) + + # A 28-day february starting of sunday (1+7+7+7+6 days) + self.check_weeks(1987, 2, (1, 7, 7, 7, 6)) + + # A 29-day february starting of monday (7+7+7+7+1 days) + self.check_weeks(1988, 2, (7, 7, 7, 7, 1)) + + # A 29-day february starting of tuesday (6+7+7+7+2 days) + self.check_weeks(1972, 2, (6, 7, 7, 7, 2)) + + # A 29-day february starting of sunday (1+7+7+7+7 days) + self.check_weeks(2004, 2, (1, 7, 7, 7, 7)) + + def test_april(self): + # A 30-day april starting of monday (7+7+7+7+2 days) + self.check_weeks(1935, 4, (7, 7, 7, 7, 2)) + + # A 30-day april starting of tuesday (6+7+7+7+3 days) + self.check_weeks(1975, 4, (6, 7, 7, 7, 3)) + + # A 30-day april starting of sunday (1+7+7+7+7+1 days) + self.check_weeks(1945, 4, (1, 7, 7, 7, 7, 1)) + + # A 30-day april starting of saturday (2+7+7+7+7 days) + self.check_weeks(1995, 4, (2, 7, 7, 7, 7)) + + # A 30-day april starting of friday (3+7+7+7+6 days) + self.check_weeks(1994, 4, (3, 7, 7, 7, 6)) + + def test_december(self): + # A 31-day december starting of monday (7+7+7+7+3 days) + self.check_weeks(1980, 12, (7, 7, 7, 7, 3)) + + # A 31-day december starting of tuesday (6+7+7+7+4 days) + self.check_weeks(1987, 12, (6, 7, 7, 7, 4)) + + # A 31-day december starting of sunday (1+7+7+7+7+2 days) + self.check_weeks(1968, 12, (1, 7, 7, 7, 7, 2)) + + # A 31-day december starting of thursday (4+7+7+7+6 days) + self.check_weeks(1988, 12, (4, 7, 7, 7, 6)) + + # A 31-day december starting of friday (3+7+7+7+7 days) + self.check_weeks(2017, 12, (3, 7, 7, 7, 7)) + + # A 31-day december starting of saturday (2+7+7+7+7+1 days) + self.check_weeks(2068, 12, (2, 7, 7, 7, 7, 1)) + + def test_main(): ! test_support.run_unittest( ! CalendarTestCase, ! MondayTestCase ! ) ! if __name__ == "__main__": From mhammond at users.sourceforge.net Fri Jul 2 19:53:19 2004 From: mhammond at users.sourceforge.net (mhammond@users.sourceforge.net) Date: Fri Jul 2 19:53:24 2004 Subject: [Python-checkins] python/dist/src/PC/bdist_wininst install.c, 1.5, 1.6 Message-ID: Update of /cvsroot/python/python/dist/src/PC/bdist_wininst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29805 Modified Files: install.c Log Message: Patch [ 983775 ] Allow bdist_wininst to install for non-admin users to address bugs: [ 555812 ] installing extension w/o admin rights [ 555810 ] removing extensions without admin rights * When enumerating the Python versions found, also remember the HKEY they were found under. * When installing, if Python was installed under HKCU, we will too. If Python was installed under HKLM, we check the permissions of the current user, and install where we can. * The "root" key we use is a global variable - all registry setting and delete functions use this global rather than a hardcoded HKLM. * A new entry is written to the install log, indicating the key we used. Uninstallation is based on this key. * 'tempnam()' is used rather than 'tmpnam()' - 'tmpnam' creates a temp file on the root of the current drive, and if this is readonly would explain the 'freopen' errors occasionally reported. 'tempnam' creates the temp file in the %TEMP% directory. Index: install.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/install.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** install.c 2 Jul 2004 08:02:40 -0000 1.5 --- install.c 2 Jul 2004 23:53:16 -0000 1.6 *************** *** 129,132 **** --- 129,135 ---- char pythondll[MAX_PATH]; BOOL pyc_compile, pyo_compile; + /* Either HKLM or HKCU, depending on where Python itself is registered, and + the permissions of the current user. */ + HKEY hkey_root = (HKEY)-1; BOOL success; /* Installation successfull? */ *************** *** 581,589 **** --- 584,600 ---- } + static PyObject *GetRootHKey(PyObject *self) + { + return g_Py_BuildValue("l", hkey_root); + } + #define METH_VARARGS 0x0001 + #define METH_NOARGS 0x0004 + typedef PyObject *(*PyCFunction)(PyObject *, PyObject *); PyMethodDef meth[] = { {"create_shortcut", CreateShortcut, METH_VARARGS, NULL}, {"get_special_folder_path", GetSpecialFolderPath, METH_VARARGS, NULL}, + {"get_root_hkey", (PyCFunction)GetRootHKey, METH_NOARGS, NULL}, {"file_created", FileCreated, METH_VARARGS, NULL}, {"directory_created", DirectoryCreated, METH_VARARGS, NULL}, *************** *** 728,732 **** char *tempname; HINSTANCE hPython; ! tempname = tmpnam(NULL); freopen(tempname, "a", stderr); freopen(tempname, "a", stdout); --- 739,743 ---- char *tempname; HINSTANCE hPython; ! tempname = tempnam(NULL, NULL); freopen(tempname, "a", stderr); freopen(tempname, "a", stdout); *************** *** 1321,1324 **** --- 1332,1340 ---- #endif /* USE_OTHER_PYTHON_VERSIONS */ + typedef struct _InstalledVersionInfo { + char prefix[MAX_PATH+1]; // sys.prefix directory. + HKEY hkey; // Is this Python in HKCU or HKLM? + } InstalledVersionInfo; + /* *************** *** 1343,1347 **** core_version, &bufsize, NULL, NULL, NULL, NULL)) { ! char subkey_name[80], vers_name[80], prefix_buf[MAX_PATH+1]; int itemindex; DWORD value_size; --- 1359,1363 ---- core_version, &bufsize, NULL, NULL, NULL, NULL)) { ! char subkey_name[80], vers_name[80]; int itemindex; DWORD value_size; *************** *** 1358,1369 **** "Software\\Python\\PythonCore\\%s\\InstallPath", core_version); - value_size = sizeof(subkey_name); if (ERROR_SUCCESS == RegOpenKeyEx(hkRoot, subkey_name, 0, KEY_READ, &hk)) { ! if (ERROR_SUCCESS == RegQueryValueEx(hk, NULL, NULL, NULL, prefix_buf, ! &value_size)) { itemindex = SendMessage(hwnd, LB_ADDSTRING, 0, ! (LPARAM)(LPSTR)vers_name); SendMessage(hwnd, LB_SETITEMDATA, itemindex, ! (LPARAM)(LPSTR)strdup(prefix_buf)); } RegCloseKey(hk); --- 1374,1389 ---- "Software\\Python\\PythonCore\\%s\\InstallPath", core_version); if (ERROR_SUCCESS == RegOpenKeyEx(hkRoot, subkey_name, 0, KEY_READ, &hk)) { ! InstalledVersionInfo *ivi = ! (InstalledVersionInfo *)malloc(sizeof(InstalledVersionInfo)); ! value_size = sizeof(ivi->prefix); ! if (ivi && ! ERROR_SUCCESS == RegQueryValueEx(hk, NULL, NULL, NULL, ! ivi->prefix, &value_size)) { itemindex = SendMessage(hwnd, LB_ADDSTRING, 0, ! (LPARAM)(LPSTR)vers_name); ! ivi->hkey = hkRoot; SendMessage(hwnd, LB_SETITEMDATA, itemindex, ! (LPARAM)(LPSTR)ivi); } RegCloseKey(hk); *************** *** 1374,1377 **** --- 1394,1441 ---- } + /* Determine if the current user can write to HKEY_LOCAL_MACHINE */ + BOOL HasLocalMachinePrivs() + { + HKEY hKey; + DWORD result; + static char KeyName[] = + "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; + + result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, + KeyName, + 0, + KEY_CREATE_SUB_KEY, + &hKey); + if (result==0) + RegCloseKey(hKey); + return result==0; + } + + // Check the root registry key to use - either HKLM or HKCU. + // If Python is installed in HKCU, then our extension also must be installed + // in HKCU - as Python won't be available for other users, we shouldn't either + // (and will fail if we are!) + // If Python is installed in HKLM, then we will also prefer to use HKLM, but + // this may not be possible - so we silently fall back to HKCU. + // + // We assume hkey_root is already set to where Python itself is installed. + void CheckRootKey(HWND hwnd) + { + if (hkey_root==HKEY_CURRENT_USER) { + ; // as above, always install ourself in HKCU too. + } else if (hkey_root==HKEY_LOCAL_MACHINE) { + // Python in HKLM, but we may or may not have permissions there. + // Open the uninstall key with 'create' permissions - if this fails, + // we don't have permission. + if (!HasLocalMachinePrivs()) + hkey_root = HKEY_CURRENT_USER; + } else { + MessageBox(hwnd, "Don't know Python's installation type", + "Strange", MB_OK | MB_ICONSTOP); + /* Default to wherever they can, but preferring HKLM */ + hkey_root = HasLocalMachinePrivs() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; + } + } + /* Return the installation scheme depending on Python version number */ SCHEME *GetScheme(int major, int minor) *************** *** 1448,1452 **** switch (HIWORD(wParam)) { int id; - char *cp; case LBN_SELCHANGE: UpdateInstallDir: --- 1512,1515 ---- *************** *** 1465,1477 **** char *pbuf; int result; PropSheet_SetWizButtons(GetParent(hwnd), PSWIZB_BACK | PSWIZB_NEXT); /* Get the python directory */ ! cp = (LPSTR)SendDlgItemMessage(hwnd, IDC_VERSIONS_LIST, LB_GETITEMDATA, id, 0); ! strcpy(python_dir, cp); SetDlgItemText(hwnd, IDC_PATH, python_dir); /* retrieve the python version and pythondll to use */ --- 1528,1543 ---- char *pbuf; int result; + InstalledVersionInfo *ivi; PropSheet_SetWizButtons(GetParent(hwnd), PSWIZB_BACK | PSWIZB_NEXT); /* Get the python directory */ ! ivi = (InstalledVersionInfo *) ! SendDlgItemMessage(hwnd, IDC_VERSIONS_LIST, LB_GETITEMDATA, id, 0); ! hkey_root = ivi->hkey; ! strcpy(python_dir, ivi->prefix); SetDlgItemText(hwnd, IDC_PATH, python_dir); /* retrieve the python version and pythondll to use */ *************** *** 1556,1568 **** static char KeyName[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; DWORD disposition; ! result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, KeyName, ! 0, ! KEY_CREATE_SUB_KEY, ! &hKey); if (result != ERROR_SUCCESS) { if (result == ERROR_ACCESS_DENIED) { MessageBox(GetFocus(), "You do not seem to have sufficient access rights\n" --- 1622,1647 ---- static char KeyName[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; + const char *root_name = (hkey_root==HKEY_LOCAL_MACHINE ? + "HKEY_LOCAL_MACHINE" : "HKEY_CURRENT_USER"); DWORD disposition; ! /* Use Create, as the Uninstall subkey may not exist under HKCU. ! Use CreateKeyEx, so we can specify a SAM specifying write access ! */ ! result = RegCreateKeyEx(hkey_root, KeyName, ! 0, /* reserved */ ! NULL, /* class */ ! 0, /* options */ ! KEY_CREATE_SUB_KEY, /* sam */ ! NULL, /* security */ ! &hKey, /* result key */ ! NULL); /* disposition */ if (result != ERROR_SUCCESS) { if (result == ERROR_ACCESS_DENIED) { + /* This should no longer be able to happen - we have already + checked if they have permissions in HKLM, and all users + should have write access to HKCU. + */ MessageBox(GetFocus(), "You do not seem to have sufficient access rights\n" *************** *** 1586,1589 **** --- 1665,1671 ---- fprintf(logfile, "Source: %s\n", modulename); + /* Root key must be first entry processed by uninstaller. */ + fprintf(logfile, "999 Root Key: %s\n", root_name); + sprintf(subkey_name, "%s-py%d.%d", meta_name, py_major, py_minor); *************** *** 1723,1726 **** --- 1805,1810 ---- /* Strip the trailing backslash again */ python_dir[strlen(python_dir)-1] = '\0'; + + CheckRootKey(hwnd); if (!OpenLogfile(python_dir)) *************** *** 1851,1855 **** fprintf(logfile, "300 Run Script: [%s]%s\n", pythondll, fname); ! tempname = tmpnam(NULL); if (!freopen(tempname, "a", stderr)) --- 1935,1939 ---- fprintf(logfile, "300 Run Script: [%s]%s\n", pythondll, fname); ! tempname = tempnam(NULL, NULL); if (!freopen(tempname, "a", stderr)) *************** *** 2101,2105 **** *delim = '\0'; ! result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyname, 0, --- 2185,2189 ---- *delim = '\0'; ! result = RegOpenKeyEx(hkey_root, keyname, 0, *************** *** 2144,2148 **** *value++ = '\0'; ! result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyname, 0, --- 2228,2232 ---- *value++ = '\0'; ! result = RegOpenKeyEx(hkey_root, keyname, 0, *************** *** 2210,2214 **** argv[0] = scriptname; ! tempname = tmpnam(NULL); if (!freopen(tempname, "a", stderr)) --- 2294,2298 ---- argv[0] = scriptname; ! tempname = tempnam(NULL, NULL); if (!freopen(tempname, "a", stderr)) *************** *** 2269,2294 **** } - { - DWORD result; - HKEY hKey; - static char KeyName[] = - "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; - - result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, - KeyName, - 0, - KEY_CREATE_SUB_KEY, - &hKey); - if (result == ERROR_ACCESS_DENIED) { - MessageBox(GetFocus(), - "You do not seem to have sufficient access rights\n" - "on this machine to uninstall this software", - NULL, - MB_OK | MB_ICONSTOP); - return 1; /* Error */ - } - RegCloseKey(hKey); - } - logfile = fopen(argv[2], "r"); if (!logfile) { --- 2353,2356 ---- *************** *** 2333,2336 **** --- 2395,2399 ---- return 0; + hkey_root = HKEY_LOCAL_MACHINE; cp = ""; for (i = 0; i < nLines; ++i) { *************** *** 2340,2344 **** cp = lines[i]; /* Parse the lines */ ! if (2 == sscanf(cp, "%d Made Dir: %s", &ign, &buffer)) { if (MyRemoveDirectory(cp)) ++nDirs; --- 2403,2421 ---- cp = lines[i]; /* Parse the lines */ ! if (2 == sscanf(cp, "%d Root Key: %s", &ign, &buffer)) { ! if (strcmp(buffer, "HKEY_CURRENT_USER")==0) ! hkey_root = HKEY_CURRENT_USER; ! else { ! // HKLM - check they have permissions. ! if (!HasLocalMachinePrivs()) { ! MessageBox(GetFocus(), ! "You do not seem to have sufficient access rights\n" ! "on this machine to uninstall this software", ! NULL, ! MB_OK | MB_ICONSTOP); ! return 1; /* Error */ ! } ! } ! } else if (2 == sscanf(cp, "%d Made Dir: %s", &ign, &buffer)) { if (MyRemoveDirectory(cp)) ++nDirs; From bcannon at users.sourceforge.net Fri Jul 2 23:52:38 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Fri Jul 2 23:52:41 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1020,1.1021 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30134/Misc Modified Files: NEWS Log Message: threading.Thread objects will now print a traceback for an exception raised during interpreter shutdown instead of masking it with another traceback about accessing a NoneType when trying to print the exception out in the first place. Closes bug #754449 (using patch #954922). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1020 retrieving revision 1.1021 diff -C2 -d -r1.1020 -r1.1021 *** NEWS 2 Jul 2004 18:57:42 -0000 1.1020 --- NEWS 3 Jul 2004 03:52:35 -0000 1.1021 *************** *** 361,364 **** --- 361,367 ---- ------- + - Bug #754449: threading.Thread objects will now print out a traceback even + when an exception is raised in a thread during interpreter shutdown. + - Added Decimal.py per PEP 327. From bcannon at users.sourceforge.net Fri Jul 2 23:52:37 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Fri Jul 2 23:52:43 2004 Subject: [Python-checkins] python/dist/src/Lib threading.py,1.41,1.42 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30134/Lib Modified Files: threading.py Log Message: threading.Thread objects will now print a traceback for an exception raised during interpreter shutdown instead of masking it with another traceback about accessing a NoneType when trying to print the exception out in the first place. Closes bug #754449 (using patch #954922). Index: threading.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/threading.py,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** threading.py 8 Mar 2004 22:18:57 -0000 1.41 --- threading.py 3 Jul 2004 03:52:35 -0000 1.42 *************** *** 368,371 **** --- 368,376 ---- __initialized = False + # Need to store a reference to sys.exc_info for printing + # out exceptions when a thread tries to use a global var. during interp. + # shutdown and thus raises an exception about trying to perform some + # operation on/with a NoneType + __exc_info = _sys.exc_info def __init__(self, group=None, target=None, name=None, *************** *** 382,385 **** --- 387,393 ---- self.__block = Condition(Lock()) self.__initialized = True + # sys.stderr is not stored in the class like + # sys.exc_info since it can be changed between instances + self.__stderr = _sys.stderr def _set_daemon(self): *************** *** 439,444 **** if __debug__: self._note("%s.__bootstrap(): unhandled exception", self) ! _sys.stderr.write("Exception in thread %s:\n%s\n" % ! (self.getName(), _format_exc())) else: if __debug__: --- 447,480 ---- if __debug__: self._note("%s.__bootstrap(): unhandled exception", self) ! # If sys.stderr is no more (most likely from interpreter ! # shutdown) use self.__stderr. Otherwise still use sys (as in ! # _sys) in case sys.stderr was redefined since the creation of ! # self. ! if _sys: ! _sys.stderr.write("Exception in thread %s:\n%s\n" % ! (self.getName(), _format_exc())) ! else: ! # Do the best job possible w/o a huge amt. of code to ! # approximate a traceback (code ideas from ! # Lib/traceback.py) ! exc_type, exc_value, exc_tb = self.__exc_info() ! try: ! print>>self.__stderr, ( ! "Exception in thread " + self.getName() + ! " (most likely raised during interpreter shutdown):") ! print>>self.__stderr, ( ! "Traceback (most recent call last):") ! while exc_tb: ! print>>self.__stderr, ( ! ' File "%s", line %s, in %s' % ! (exc_tb.tb_frame.f_code.co_filename, ! exc_tb.tb_lineno, ! exc_tb.tb_frame.f_code.co_name)) ! exc_tb = exc_tb.tb_next ! print>>self.__stderr, ("%s: %s" % (exc_type, exc_value)) ! # Make sure that exc_tb gets deleted since it is a memory ! # hog; deleting everything else is just for thoroughness ! finally: ! del exc_type, exc_value, exc_tb else: if __debug__: From bcannon at users.sourceforge.net Fri Jul 2 23:54:56 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Fri Jul 2 23:55:00 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1021,1.1022 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30727/Misc Modified Files: NEWS Log Message: Clarify last added comment (bug #754449). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1021 retrieving revision 1.1022 diff -C2 -d -r1.1021 -r1.1022 *** NEWS 3 Jul 2004 03:52:35 -0000 1.1021 --- NEWS 3 Jul 2004 03:54:54 -0000 1.1022 *************** *** 361,366 **** ------- ! - Bug #754449: threading.Thread objects will now print out a traceback even ! when an exception is raised in a thread during interpreter shutdown. - Added Decimal.py per PEP 327. --- 361,367 ---- ------- ! - Bug #754449: threading.Thread objects no longer mask exceptions raised during ! interpreter shutdown with another exception from attempting to handle the ! original exception. - Added Decimal.py per PEP 327. From rhettinger at users.sourceforge.net Sat Jul 3 06:02:30 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jul 3 06:02:35 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11112 Modified Files: decimal.py Log Message: Work through several open todos: * Added test for pickling contexts * Renamed ExceptionList to Signals (to match wording in the spec) * Simplified Context constructor by allowing flags=None to automatically generate a zeroed-out flags dictionary. * inlined _convertString() which was used only once * _rounding_decision is private, so excluded its contants from __all__. * added an XXX comment with concerns about subclassing signals results in a deviation from the spec (maybe important, maybe not). * Taught the test_suite to determine its own directory (modeled after code in regrtest.py). Enables it to be run when the current directory is not the test directory. * Added a clear_flags() method to the Context API to make it easier to do a common operation with flags. * Fixed the trap_enablers defaults in BasicDefaultContext to match the spec. Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** decimal.py 1 Jul 2004 14:28:36 -0000 1.2 --- decimal.py 3 Jul 2004 10:02:27 -0000 1.3 *************** *** 10,20 **** # Todo: - # Add deepcopy and pickle support for contexts - # Consider having a SimpleDecimal subclass implementing X3.274 semantics - # Improve the Context API - # Especially with respect to setting flags and traps - # Consider adding a clear_flags() method to Context # Provide a clean way of attaching monetary format representations ! # Review all exposed constants for utility vs. namespace clutter --- 10,15 ---- # Todo: # Provide a clean way of attaching monetary format representations ! # Make tests independent of DefaultContext.prec == 9 *************** *** 140,145 **** 'ROUND_DOWN', 'ROUND_HALF_UP', 'ROUND_HALF_EVEN', 'ROUND_CEILING', 'ROUND_FLOOR', 'ROUND_UP', 'ROUND_HALF_DOWN', ! 'NEVER_ROUND', 'ALWAYS_ROUND', ! 'ExceptionList', # <-- Used for building trap/flag dictionaries # Functions for manipulating contexts --- 135,139 ---- 'ROUND_DOWN', 'ROUND_HALF_UP', 'ROUND_HALF_EVEN', 'ROUND_CEILING', 'ROUND_FLOOR', 'ROUND_UP', 'ROUND_HALF_DOWN', ! 'Signals', # <-- Used for building trap/flag dictionaries # Functions for manipulating contexts *************** *** 245,248 **** --- 239,248 ---- return NaN + # XXX Is there a logic error in subclassing InvalidOperation? + # Setting the InvalidOperation trap to zero does not preclude ConversionSyntax. + # Also, incrementing Conversion syntax flag will not increment InvalidOperation. + # Both of these issues interfere with cross-language portability because + # code following the spec would not know about the Python subclasses. + class ConversionSyntax(InvalidOperation): """Trying to convert badly formed string. *************** *** 411,416 **** return False ! #ExceptionList holds the exceptions ! ExceptionList = filter(_filterfunc, globals().values()) del _filterfunc --- 411,416 ---- return False ! #Signals holds the exceptions ! Signals = filter(_filterfunc, globals().values()) del _filterfunc *************** *** 493,497 **** self._int = tuple(map(int, diag)) #Diagnostic info return ! self._convertString(value, context) return --- 493,500 ---- self._int = tuple(map(int, diag)) #Diagnostic info return ! try: ! self._sign, self._int, self._exp = _string2exact(value) ! except ValueError: ! self._sign, self._int, self._exp = context._raise_error(ConversionSyntax) return *************** *** 595,611 **** return 0 - def _convertString(self, value, context=None): - """Changes self's value to that in a string. - - A bad string causes a ConversionSyntax error. - """ - if context is None: - context = getcontext() - try: - self._sign, self._int, self._exp = _string2exact(value) - except ValueError: - self._sign, self._int, self._exp = context._raise_error(ConversionSyntax) - return - def __nonzero__(self): """Is the number non-zero? --- 598,601 ---- *************** *** 1434,1439 **** def __int__(self): """Converts self to a int, truncating if necessary.""" - # XXX This should be implemented in terms of tested - # functions in the standard if self._isnan(): context = getcontext() --- 1424,1427 ---- *************** *** 2116,2119 **** --- 2104,2109 ---- return self.__class__(str(self)) + ##### Context class ########################################### + # get rounding method function: *************** *** 2153,2156 **** --- 2143,2148 ---- capitals=1, _clamp=0, _ignored_flags=[]): + if flags is None: + flags = dict.fromkeys(Signals, 0) DefaultLock.acquire() for name, val in locals().items(): *************** *** 2162,2165 **** --- 2154,2162 ---- del self.self + def clear_flags(self): + """Reset all flags to zero""" + for flag in self.flags: + self.flag = 0 + def copy(self): """Returns a copy from self.""" *************** *** 2168,2172 **** self.capitals, self._clamp, self._ignored_flags) return nc - __copy__ = copy def _raise_error(self, error, explanation = None, *args): --- 2165,2168 ---- *************** *** 2193,2197 **** def _ignore_all_flags(self): """Ignore all flags, if they are raised""" ! return self._ignore_flags(*ExceptionList) def _ignore_flags(self, *flags): --- 2189,2193 ---- def _ignore_all_flags(self): """Ignore all flags, if they are raised""" ! return self._ignore_flags(*Signals) def _ignore_flags(self, *flags): *************** *** 2960,2969 **** ##### Setup Specific Contexts ################################ ! def _zero_exceptions(): ! "Helper function mapping all exceptions to zero." ! d = {} ! for exception in ExceptionList: ! d[exception] = 0 ! return d # The default context prototype used by Context() --- 2956,2961 ---- ##### Setup Specific Contexts ################################ ! _basic_traps = dict.fromkeys(Signals, 1) ! _basic_traps.update({Inexact:0, Rounded:0, Subnormal:0}) # The default context prototype used by Context() *************** *** 2972,2977 **** DefaultContext = Context( prec=SINGLE_PRECISION, rounding=ROUND_HALF_EVEN, ! trap_enablers=_zero_exceptions(), ! flags=_zero_exceptions(), _rounding_decision=ALWAYS_ROUND, ) --- 2964,2969 ---- DefaultContext = Context( prec=SINGLE_PRECISION, rounding=ROUND_HALF_EVEN, ! trap_enablers=dict.fromkeys(Signals, 0), ! flags=None, _rounding_decision=ALWAYS_ROUND, ) *************** *** 2982,2992 **** # of the spec. - _basic_traps = _zero_exceptions() - _basic_traps.update({Inexact:1, Rounded:1, Subnormal:1}) - BasicDefaultContext = Context( prec=9, rounding=ROUND_HALF_UP, trap_enablers=_basic_traps, ! flags=_zero_exceptions(), _rounding_decision=ALWAYS_ROUND, ) --- 2974,2981 ---- # of the spec. BasicDefaultContext = Context( prec=9, rounding=ROUND_HALF_UP, trap_enablers=_basic_traps, ! flags=None, _rounding_decision=ALWAYS_ROUND, ) *************** *** 2994,3004 **** ExtendedDefaultContext = Context( prec=SINGLE_PRECISION, rounding=ROUND_HALF_EVEN, ! trap_enablers=_zero_exceptions(), ! flags=_zero_exceptions(), _rounding_decision=ALWAYS_ROUND, ) ! ##### Useful Constants (internal use only###################### #Reusable defaults --- 2983,2993 ---- ExtendedDefaultContext = Context( prec=SINGLE_PRECISION, rounding=ROUND_HALF_EVEN, ! trap_enablers=dict.fromkeys(Signals, 0), ! flags=None, _rounding_decision=ALWAYS_ROUND, ) ! ##### Useful Constants (internal use only) #################### #Reusable defaults From rhettinger at users.sourceforge.net Sat Jul 3 06:02:30 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jul 3 06:02:37 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_decimal.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11112/test Modified Files: test_decimal.py Log Message: Work through several open todos: * Added test for pickling contexts * Renamed ExceptionList to Signals (to match wording in the spec) * Simplified Context constructor by allowing flags=None to automatically generate a zeroed-out flags dictionary. * inlined _convertString() which was used only once * _rounding_decision is private, so excluded its contants from __all__. * added an XXX comment with concerns about subclassing signals results in a deviation from the spec (maybe important, maybe not). * Taught the test_suite to determine its own directory (modeled after code in regrtest.py). Enables it to be run when the current directory is not the test directory. * Added a clear_flags() method to the Context API to make it easier to do a common operation with flags. * Fixed the trap_enablers defaults in BasicDefaultContext to match the spec. Index: test_decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decimal.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_decimal.py 1 Jul 2004 11:01:32 -0000 1.1 --- test_decimal.py 3 Jul 2004 10:02:28 -0000 1.2 *************** *** 36,40 **** TESTDATADIR = 'decimaltestdata' ! dir = os.curdir + os.sep + TESTDATADIR + os.sep skip_expected = not os.path.isdir(dir) --- 36,45 ---- TESTDATADIR = 'decimaltestdata' ! if __name__ == '__main__': ! file = sys.argv[0] ! else: ! file = __file__ ! testdir = os.path.dirname(file) or os.curdir ! dir = testdir + os.sep + TESTDATADIR + os.sep skip_expected = not os.path.isdir(dir) *************** *** 191,195 **** theirexceptions = [ErrorNames[x.lower()] for x in exceptions] ! for exception in ExceptionList: self.context.trap_enablers[exception] = 1 #Catch these bugs... for exception in theirexceptions: --- 196,200 ---- theirexceptions = [ErrorNames[x.lower()] for x in exceptions] ! for exception in Signals: self.context.trap_enablers[exception] = 1 #Catch these bugs... for exception in theirexceptions: *************** *** 213,217 **** except error: pass ! except ExceptionList, e: self.fail("Raised %s in %s when %s disabled" % \ (e, s, error)) --- 218,222 ---- except error: pass ! except Signals, e: self.fail("Raised %s in %s when %s disabled" % \ (e, s, error)) *************** *** 233,237 **** except error: pass ! except ExceptionList, e: self.fail("Raised %s in %s when %s disabled" % \ (e, s, error)) --- 238,242 ---- except error: pass ! except Signals, e: self.fail("Raised %s in %s when %s disabled" % \ (e, s, error)) *************** *** 243,247 **** if fname == 'same_quantum': result = str(int(eval(result))) # 'True', 'False' -> '1', '0' ! except ExceptionList, error: self.fail("Raised %s in %s" % (error, s)) except: #Catch any error long enough to state the test case. --- 248,252 ---- if fname == 'same_quantum': result = str(int(eval(result))) # 'True', 'False' -> '1', '0' ! except Signals, error: self.fail("Raised %s in %s" % (error, s)) except: #Catch any error long enough to state the test case. *************** *** 264,268 **** def getexceptions(self): L = [] ! for exception in ExceptionList: if self.context.flags[exception]: L.append(exception) --- 269,273 ---- def getexceptions(self): L = [] ! for exception in Signals: if self.context.flags[exception]: L.append(exception) *************** *** 270,274 **** def resetflags(self): ! for exception in ExceptionList: self.context.flags[exception] = 0 --- 275,279 ---- def resetflags(self): ! for exception in Signals: self.context.flags[exception] = 0 *************** *** 1047,1050 **** --- 1052,1065 ---- self.assertEqual(d, e) + class ContextAPItests(unittest.TestCase): + + def test_pickle(self): + c = Context() + e = pickle.loads(pickle.dumps(c)) + for k in vars(c): + v1 = vars(c)[k] + v2 = vars(e)[k] + self.assertEqual(v1, v2) + def test_main(arith=False, verbose=None): """ Execute the tests. *************** *** 1060,1063 **** --- 1075,1079 ---- DecimalUsabilityTest, DecimalPythonAPItests, + ContextAPItests, ] From vsajip at users.sourceforge.net Sat Jul 3 07:45:55 2004 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Sat Jul 3 07:45:59 2004 Subject: [Python-checkins] python/dist/src/Doc/lib liblogging.tex,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27326 Modified Files: liblogging.tex Log Message: Moved example section up to just after the section on Logger objects, and changed it to use the new basicConfig() API Index: liblogging.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liblogging.tex,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** liblogging.tex 15 Apr 2004 06:18:48 -0000 1.18 --- liblogging.tex 3 Jul 2004 11:45:53 -0000 1.19 *************** *** 201,206 **** then you get the corresponding string. If you have associated levels with names using \function{addLevelName()} then the name you have associated ! with \var{lvl} is returned. Otherwise, the string "Level \%s" \% lvl is ! returned. \end{funcdesc} --- 201,207 ---- then you get the corresponding string. If you have associated levels with names using \function{addLevelName()} then the name you have associated ! with \var{lvl} is returned. If a numeric value corresponding to one of the ! defined levels is passed in, the corresponding string representation is ! returned. Otherwise, the string "Level \%s" \% lvl is returned. \end{funcdesc} *************** *** 244,249 **** {This is the original source for the \module{logging} package. The version of the package available from this ! site is suitable for use with Python 2.1.x and 2.2.x, which ! do not include the \module{logging} package in the standard library.} \end{seealso} --- 245,250 ---- {This is the original source for the \module{logging} package. The version of the package available from this ! site is suitable for use with Python 1.5.2, 2.1.x and 2.2.x, ! which do not include the \module{logging} package in the standard library.} \end{seealso} *************** *** 364,367 **** --- 365,474 ---- \end{methoddesc} + \subsection{Basic example \label{minimal-example}} + + The \module{logging} package provides a lot of flexibility, and its + configuration can appear daunting. This section demonstrates that simple + use of the logging package is possible. + + The simplest example shows logging to the console: + + \begin{verbatim} + import logging + + logging.debug('A debug message') + logging.info('Some information') + logging.warning('A shot across the bows') + \end{verbatim} + + If you run the above script, you'll see this: + \begin{verbatim} + WARNING:root:A shot across the bows + \end{verbatim} + + Because no particular logger was specified, the system used the root logger. + The debug and info messages didn't appear because by default, the root + logger is configured to only handle messages with a severity of WARNING + or above. The message format is also a configuration default, as is the output + destination of the messages - \code{sys.stderr}. The severity level, + the message format and destination can be easily changed, as shown in + the example below: + + \begin{verbatim} + import logging + + logging.basicConfig(level=logging.DEBUG, + format='%(asctime)s %(levelname)s %(message)s', + filename='/tmp/myapp.log', + filemode='w') + logging.debug('A debug message') + logging.info('Some information') + logging.warning('A shot across the bows') + \end{verbatim} + + The \method{basicConfig()} method is used to change the configuration + defaults, which results in output (written to \code{/tmp/myapp.log}) + which should look something like the following: + + \begin{verbatim} + 2004-07-02 13:00:08,743 DEBUG A debug message + 2004-07-02 13:00:08,743 INFO Some information + 2004-07-02 13:00:08,743 WARNING A shot across the bows + \end{verbatim} + + This time, all messages with a severity of DEBUG or above were handled, + and the format of the messages was also changed, and output went to the + specified file rather than the console. + + Formatting uses standard Python string formatting - see section + \ref{typesseq-strings}. The format string takes the following + common specifiers. For a complete list of specifiers, consult the + \class{Formatter} documentation. + + \begin{tableii}{l|l}{code}{Format}{Description} + \lineii{\%(name)s} {Name of the logger (logging channel).} + \lineii{\%(levelname)s}{Text logging level for the message + (\code{'DEBUG'}, \code{'INFO'}, + \code{'WARNING'}, \code{'ERROR'}, + \code{'CRITICAL'}).} + \lineii{\%(asctime)s} {Human-readable time when the \class{LogRecord} + was created. By default this is of the form + ``2003-07-08 16:49:45,896'' (the numbers after the + comma are millisecond portion of the time).} + \lineii{\%(message)s} {The logged message.} + \end{tableii} + + To change the date/time format, you can pass an additional keyword parameter, + \var{datefmt}, as in the following: + + \begin{verbatim} + import logging + + logging.basicConfig(level=logging.DEBUG, + format='%(asctime)s %(levelname)-8s %(message)s', + datefmt='%a, %d %b %Y %H:%M:%S', + filename='/temp/myapp.log', + filemode='w') + logging.debug('A debug message') + logging.info('Some information') + logging.warning('A shot across the bows') + \end{verbatim} + + which would result in output like + + \begin{verbatim} + Fri, 02 Jul 2004 13:06:18 DEBUG A debug message + Fri, 02 Jul 2004 13:06:18 INFO Some information + Fri, 02 Jul 2004 13:06:18 WARNING A shot across the bows + \end{verbatim} + + The date format string follows the requirements of \function{strftime()} - + see the documentation for the \refmodule{time} module. + + If, instead of sending logging output to the console or a file, you'd rather + use a file-like object which you have created separately, you can pass it + to \function{basicConfig()} using the \var{stream} keyword argument. Note + that if both \var{stream} and \var{filename} keyword arguments are passed, + the \var{stream} argument is ignored. + \subsection{Handler Objects} *************** *** 430,441 **** \end{methoddesc} ! \begin{methoddesc}{handleError}{} This method should be called from handlers when an exception is ! encountered during an emit() call. By default it does nothing, which means that exceptions get silently ignored. This is what is mostly wanted for a logging system - most users will not care about errors in the logging system, they are more interested in application errors. You could, however, replace this with a custom ! handler if you wish. \end{methoddesc} --- 537,549 ---- \end{methoddesc} ! \begin{methoddesc}{handleError}{record} This method should be called from handlers when an exception is ! encountered during an \method{emit()} call. By default it does nothing, which means that exceptions get silently ignored. This is what is mostly wanted for a logging system - most users will not care about errors in the logging system, they are more interested in application errors. You could, however, replace this with a custom ! handler if you wish. The specified record is the one which was being ! processed when the exception occurred. \end{methoddesc} *************** *** 507,511 **** specified file is opened and used as the stream for logging. If \var{mode} is not specified, \code{'a'} is used. By default, the ! file grows indefinitely. You can use the \var{maxBytes} and --- 615,619 ---- specified file is opened and used as the stream for logging. If \var{mode} is not specified, \code{'a'} is used. By default, the ! file grows indefinitely. You can use the \var{maxBytes} and *************** *** 523,527 **** closed and renamed to \file{app.log.1}, and if files \file{app.log.1}, \file{app.log.2}, etc. exist, then they are renamed to \file{app.log.2}, ! \file{app.log.3} etc. respectively. \end{classdesc} --- 631,635 ---- closed and renamed to \file{app.log.1}, and if files \file{app.log.1}, \file{app.log.2}, etc. exist, then they are renamed to \file{app.log.2}, ! \file{app.log.3} etc. respectively. \end{classdesc} *************** *** 1052,1056 **** messages are \strong{not} propagated to handlers up the hierarchy. The \code{qualname} entry is the hierarchical channel name of the logger, ! for example, the name used by the application to get the logger. Sections which specify handler configuration are exemplified by the --- 1160,1164 ---- messages are \strong{not} propagated to handlers up the hierarchy. The \code{qualname} entry is the hierarchical channel name of the logger, ! that is to say the name used by the application to get the logger. Sections which specify handler configuration are exemplified by the *************** *** 1148,1191 **** result of using the above format string, with a comma separator. An example time in ISO8601 format is \code{2003-01-23 00:29:50,411}. - - \subsection{Using the logging package} - - \subsubsection{Basic example - log to a file} - - Here's a simple logging example that just logs to a file. In order, - it creates a \class{Logger} instance, then a \class{FileHandler} - and a \class{Formatter}. It attaches the \class{Formatter} to the - \class{FileHandler}, then the \class{FileHandler} to the \class{Logger}. - Finally, it sets a debug level for the logger. - - \begin{verbatim} - import logging - logger = logging.getLogger('myapp') - hdlr = logging.FileHandler('/var/tmp/myapp.log') - formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') - hdlr.setFormatter(formatter) - logger.addHandler(hdlr) - logger.setLevel(logging.WARNING) - \end{verbatim} - - We can use this logger object now to write entries to the log file: - - \begin{verbatim} - logger.error('We have a problem') - logger.info('While this is just chatty') - \end{verbatim} - - If we look in the file that was created, we'll see something like this: - \begin{verbatim} - 2003-07-08 16:49:45,896 ERROR We have a problem - \end{verbatim} - - The info message was not written to the file: we called the - \method{setLevel()} method to say we only wanted \constant{WARNING} or - worse, so the info message is discarded. - - The timestamp is of the form - ``year-month-day hour:minutes:seconds,milliseconds.'' - Note that despite the three digits of precision in the milliseconds field, - not all systems provide time with this much precision. - --- 1256,1257 ---- From vsajip at users.sourceforge.net Sat Jul 3 07:47:29 2004 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Sat Jul 3 07:47:32 2004 Subject: [Python-checkins] python/dist/src/Lib/logging __init__.py, 1.14, 1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/logging In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27566 Modified Files: __init__.py Log Message: Changed basicConfig() to add keyword arguments. Changes are backward-compatible. Added error checking to log() to check that level is an integer, and raise a TypeError if not (as long as raiseExceptions is set). Minor documentation corrections. Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/logging/__init__.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** __init__.py 28 Feb 2004 16:03:58 -0000 1.14 --- __init__.py 3 Jul 2004 11:47:26 -0000 1.15 *************** *** 37,42 **** __author__ = "Vinay Sajip " __status__ = "beta" ! __version__ = "0.4.9.2" ! __date__ = "28 February 2004" #--------------------------------------------------------------------------- --- 37,42 ---- __author__ = "Vinay Sajip " __status__ = "beta" ! __version__ = "0.4.9.3" ! __date__ = "03 July 2004" #--------------------------------------------------------------------------- *************** *** 114,119 **** INFO, DEBUG) then you get the corresponding string. If you have associated levels with names using addLevelName then the name you have ! associated with 'level' is returned. Otherwise, the string ! "Level %s" % level is returned. """ return _levelNames.get(level, ("Level %s" % level)) --- 114,123 ---- INFO, DEBUG) then you get the corresponding string. If you have associated levels with names using addLevelName then the name you have ! associated with 'level' is returned. ! ! If a numeric value corresponding to one of the defined levels is passed ! in, the corresponding string representation is returned. ! ! Otherwise, the string "Level %s" % level is returned. """ return _levelNames.get(level, ("Level %s" % level)) *************** *** 969,972 **** --- 973,981 ---- logger.log(level, "We have a %s", "mysterious problem", exc_info=1) """ + if type(level) != types.IntType: + if raiseExceptions: + raise TypeError, "level must be an integer" + else: + return if self.manager.disable >= level: return *************** *** 1107,1121 **** BASIC_FORMAT = "%(levelname)s:%(name)s:%(message)s" ! def basicConfig(): """ ! Do basic configuration for the logging system by creating a ! StreamHandler with a default Formatter and adding it to the ! root logger. """ if len(root.handlers) == 0: ! hdlr = StreamHandler() ! fmt = Formatter(BASIC_FORMAT) hdlr.setFormatter(fmt) root.addHandler(hdlr) #--------------------------------------------------------------------------- --- 1116,1167 ---- BASIC_FORMAT = "%(levelname)s:%(name)s:%(message)s" ! def basicConfig(**kwargs): """ ! Do basic configuration for the logging system. ! ! This function does nothing if the root logger already has handlers ! configured. It is a convenience method intended for use by simple scripts ! to do one-shot configuration of the logging package. ! ! The default behaviour is to create a StreamHandler which writes to ! sys.stderr, set a formatter using the BASIC_FORMAT format string, and ! add the handler to the root logger. ! ! A number of optional keyword arguments may be specified, which can alter ! the default behaviour. ! ! filename Specifies that a FileHandler be created, using the specified ! filename, rather than a StreamHandler. ! filemode Specifies the mode to open the file, if filename is specified ! (if filemode is unspecified, it defaults to "a"). ! format Use the specified format string for the handler. ! datefmt Use the specified date/time format. ! level Set the root logger level to the specified level. ! stream Use the specified stream to initialize the StreamHandler. Note ! that this argument is incompatible with 'filename' - if both ! are present, 'stream' is ignored. ! ! Note that you could specify a stream created using open(filename, mode) ! rather than passing the filename and mode in. However, it should be ! remembered that StreamHandler does not close its stream (since it may be ! using sys.stdout or sys.stderr), whereas FileHandler closes its stream ! when the handler is closed. """ if len(root.handlers) == 0: ! filename = kwargs.get("filename") ! if filename: ! mode = kwargs.get("filemode", "a") ! hdlr = FileHandler(filename, mode) ! else: ! stream = kwargs.get("stream") ! hdlr = StreamHandler(stream) ! fs = kwargs.get("format", BASIC_FORMAT) ! dfs = kwargs.get("datefmt", None) ! fmt = Formatter(fs, dfs) hdlr.setFormatter(fmt) root.addHandler(hdlr) + level = kwargs.get("level") + if level: + root.setLevel(level) #--------------------------------------------------------------------------- From vsajip at users.sourceforge.net Sat Jul 3 07:48:37 2004 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Sat Jul 3 07:48:41 2004 Subject: [Python-checkins] python/dist/src/Lib/logging handlers.py, 1.12, 1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/logging In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27656 Modified Files: handlers.py Log Message: Refactored RotatingFileHandler to create a base class for rotating handlers. Added TimedRotatingFileHandler. Index: handlers.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/logging/handlers.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** handlers.py 8 Mar 2004 16:57:19 -0000 1.12 --- handlers.py 3 Jul 2004 11:48:34 -0000 1.13 *************** *** 28,32 **** """ ! import sys, logging, socket, types, os, string, cPickle, struct, time # --- 28,32 ---- """ ! import sys, logging, socket, types, os, string, cPickle, struct, time, glob # *************** *** 40,45 **** SYSLOG_UDP_PORT = 514 ! class RotatingFileHandler(logging.FileHandler): def __init__(self, filename, mode="a", maxBytes=0, backupCount=0): """ --- 40,71 ---- SYSLOG_UDP_PORT = 514 + class BaseRotatingHandler(logging.FileHandler): + """ + Base class for handlers that rotate log files at a certain point. + Not meant to be instantiated directly. Instead, use RotatingFileHandler + or TimedRotatingFileHandler. + """ + def __init__(self, filename, mode): + """ + Use the specified filename for streamed logging + """ + logging.FileHandler.__init__(self, filename, mode) ! def emit(self, record): ! """ ! Emit a record. ! ! Output the record to the file, catering for rollover as described ! in doRollover(). ! """ ! if self.shouldRollover(record): ! self.doRollover() ! logging.FileHandler.emit(self, record) ! ! class RotatingFileHandler(BaseRotatingHandler): ! """ ! Handler for logging to a set of files, which switches from one file ! to the next when the current file reaches a certain size. ! """ def __init__(self, filename, mode="a", maxBytes=0, backupCount=0): """ *************** *** 63,71 **** If maxBytes is zero, rollover never occurs. """ ! logging.FileHandler.__init__(self, filename, mode) self.maxBytes = maxBytes self.backupCount = backupCount - if maxBytes > 0: - self.mode = "a" def doRollover(self): --- 89,98 ---- If maxBytes is zero, rollover never occurs. """ ! self.mode = mode ! if maxBytes > 0: ! self.mode = "a" # doesn't make sense otherwise! ! BaseRotatingHandler.__init__(self, filename, self.mode) self.maxBytes = maxBytes self.backupCount = backupCount def doRollover(self): *************** *** 91,100 **** self.stream = open(self.baseFilename, "w") ! def emit(self, record): """ ! Emit a record. ! Output the record to the file, catering for rollover as described ! in doRollover(). """ if self.maxBytes > 0: # are we rolling over? --- 118,127 ---- self.stream = open(self.baseFilename, "w") ! def shouldRollover(self, record): """ ! Determine if rollover should occur. ! Basically, see if the supplied record would cause the file to exceed ! the size limit we have. """ if self.maxBytes > 0: # are we rolling over? *************** *** 102,108 **** self.stream.seek(0, 2) #due to non-posix-compliant Windows feature if self.stream.tell() + len(msg) >= self.maxBytes: ! self.doRollover() ! logging.FileHandler.emit(self, record) class SocketHandler(logging.Handler): --- 129,264 ---- self.stream.seek(0, 2) #due to non-posix-compliant Windows feature if self.stream.tell() + len(msg) >= self.maxBytes: ! return 1 ! return 0 ! ! class TimedRotatingFileHandler(BaseRotatingHandler): ! """ ! Handler for logging to a file, rotating the log file at certain timed ! intervals. ! ! If backupCount is > 0, when rollover is done, no more than backupCount ! files are kept - the oldest ones are deleted. ! """ ! def __init__(self, filename, when='h', interval=1, backupCount=0): ! BaseRotatingHandler.__init__(self, filename, 'a') ! self.when = string.upper(when) ! self.backupCount = backupCount ! # Calculate the real rollover interval, which is just the number of ! # seconds between rollovers. Also set the filename suffix used when ! # a rollover occurs. Current 'when' events supported: ! # S - Seconds ! # M - Minutes ! # H - Hours ! # D - Days ! # midnight - roll over at midnight ! # W{0-6} - roll over on a certain day; 0 - Monday ! # ! # Case of the 'when' specifier is not important; lower or upper case ! # will work. ! currentTime = int(time.time()) ! if self.when == 'S': ! self.interval = 1 # one second ! self.suffix = "%Y-%m-%d_%H-%M-%S" ! elif self.when == 'M': ! self.interval = 60 # one minute ! self.suffix = "%Y-%m-%d_%H-%M" ! elif self.when == 'H': ! self.interval = 60 * 60 # one hour ! self.suffix = "%Y-%m-%d_%H" ! elif self.when == 'D' or self.when == 'MIDNIGHT': ! self.interval = 60 * 60 * 24 # one day ! self.suffix = "%Y-%m-%d" ! elif self.when.startswith('W'): ! self.interval = 60 * 60 * 24 * 7 # one week ! if len(self.when) != 2: ! raise ValueError("You must specify a day for weekly rollover from 0 to 6 (0 is Monday): %s" % self.when) ! if self.when[1] < '0' or self.when[1] > '6': ! raise ValueError("Invalid day specified for weekly rollover: %s" % self.when) ! self.dayOfWeek = int(self.when[1]) ! self.suffix = "%Y-%m-%d" ! else: ! raise ValueError("Invalid rollover interval specified: %s" % self.when) ! ! self.interval *= interval # multiply by units requested ! self.rolloverAt = currentTime + self.interval + # If we are rolling over at midnight or weekly, then the interval is already known. + # What we need to figure out is WHEN the next interval is. In other words, + # if you are rolling over at midnight, then your base interval is 1 day, + # but you want to start that one day clock at midnight, not now. So, we + # have to fudge the rolloverAt value in order to trigger the first rollover + # at the right time. After that, the regular interval will take care of + # the rest. Note that this code doesn't care about leap seconds. :) + if self.when == 'MIDNIGHT' or self.when.startswith('W'): + # This could be done with less code, but I wanted it to be clear + t = time.localtime(currentTime) + currentHour = t[3] + currentMinute = t[4] + currentSecond = t[5] + # r is the number of seconds left between now and midnight + r = (24 - currentHour) * 60 * 60 # number of hours in seconds + r += (59 - currentMinute) * 60 # plus the number of minutes (in secs) + r += (59 - currentSecond) # plus the number of seconds + self.rolloverAt = currentTime + r + # If we are rolling over on a certain day, add in the number of days until + # the next rollover, but offset by 1 since we just calculated the time + # until the next day starts. There are three cases: + # Case 1) The day to rollover is today; in this case, do nothing + # Case 2) The day to rollover is further in the interval (i.e., today is + # day 2 (Wednesday) and rollover is on day 6 (Sunday). Days to + # next rollover is simply 6 - 2 - 1, or 3. + # Case 3) The day to rollover is behind us in the interval (i.e., today + # is day 5 (Saturday) and rollover is on day 3 (Thursday). + # Days to rollover is 6 - 5 + 3, or 4. In this case, it's the + # number of days left in the current week (1) plus the number + # of days in the next week until the rollover day (3). + if when.startswith('W'): + day = t[6] # 0 is Monday + if day > self.dayOfWeek: + daysToWait = (day - self.dayOfWeek) - 1 + self.rolloverAt += (daysToWait * (60 * 60 * 24)) + if day < self.dayOfWeek: + daysToWait = (6 - self.dayOfWeek) + day + self.rolloverAt += (daysToWait * (60 * 60 * 24)) + + print "Will rollover at %d, %d seconds from now" % (self.rolloverAt, self.rolloverAt - currentTime) + + def shouldRollover(self, record): + """ + Determine if rollover should occur + + record is not used, as we are just comparing times, but it is needed so + the method siguratures are the same + """ + t = int(time.time()) + if t >= self.rolloverAt: + return 1 + print "No need to rollover: %d, %d" % (t, self.rolloverAt) + return 0 + + def doRollover(self): + """ + do a rollover; in this case, a date/time stamp is appended to the filename + when the rollover happens. However, you want the file to be named for the + start of the interval, not the current time. If there is a backup count, + then we have to get a list of matching filenames, sort them and remove + the one with the oldest suffix. + """ + self.stream.close() + # get the time that this sequence started at and make it a TimeTuple + t = self.rolloverAt - self.interval + timeTuple = time.localtime(t) + dfn = self.baseFilename + "." + time.strftime(self.suffix, timeTuple) + if os.path.exists(dfn): + os.remove(dfn) + os.rename(self.baseFilename, dfn) + if self.backupCount > 0: + # find the oldest log file and delete it + s = glob.glob(self.baseFilename + ".20*") + if len(s) > self.backupCount: + os.remove(s[0]) + print "%s -> %s" % (self.baseFilename, dfn) + self.stream = open(self.baseFilename, "w") + self.rolloverAt = int(time.time()) + self.interval class SocketHandler(logging.Handler): From rhettinger at users.sourceforge.net Sat Jul 3 08:26:24 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jul 3 08:26:29 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_decimal.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv519/test Modified Files: test_decimal.py Log Message: * Make the tests independent of the default precision. * Change the default precision to 28 (to match VB's decimal type). Index: test_decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decimal.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_decimal.py 3 Jul 2004 10:02:28 -0000 1.2 --- test_decimal.py 3 Jul 2004 12:26:21 -0000 1.3 *************** *** 35,38 **** --- 35,45 ---- import threading + # Tests are built around these assumed context defaults + DefaultContext.prec=9 + DefaultContext.rounding=ROUND_HALF_EVEN + DefaultContext.trap_enablers=dict.fromkeys(Signals, 0) + setcontext(DefaultContext) + + TESTDATADIR = 'decimaltestdata' if __name__ == '__main__': From rhettinger at users.sourceforge.net Sat Jul 3 08:26:24 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jul 3 08:26:31 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv519 Modified Files: decimal.py Log Message: * Make the tests independent of the default precision. * Change the default precision to 28 (to match VB's decimal type). Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** decimal.py 3 Jul 2004 10:02:27 -0000 1.3 --- decimal.py 3 Jul 2004 12:26:21 -0000 1.4 *************** *** 11,15 **** # Todo: # Provide a clean way of attaching monetary format representations - # Make tests independent of DefaultContext.prec == 9 --- 11,14 ---- *************** *** 42,45 **** --- 41,45 ---- >>> from decimal import * + >>> getcontext().prec=9 >>> Decimal(0) Decimal("0") *************** *** 130,134 **** # Module parameters ! 'SINGLE_PRECISION', 'DEFAULT_MAX_EXPONENT', 'DEFAULT_MIN_EXPONENT', # Constants for use in setting up contexts --- 130,134 ---- # Module parameters ! 'DEFAULT_MAX_EXPONENT', 'DEFAULT_MIN_EXPONENT', # Constants for use in setting up contexts *************** *** 150,156 **** xor = operator.xor - #Precision - SINGLE_PRECISION = 9 - #Exponent Range DEFAULT_MAX_EXPONENT = 999999999 --- 150,153 ---- *************** *** 426,429 **** --- 423,428 ---- def setcontext(context): """Set this thread's context to context.""" + if context == DefaultContext: + context = Context() threading.currentThread().__decimal_context__ = context *************** *** 2266,2276 **** the plus operation on the operand. ! >>> DefaultContext.abs(Decimal('2.1')) Decimal("2.1") ! >>> DefaultContext.abs(Decimal('-100')) Decimal("100") ! >>> DefaultContext.abs(Decimal('101.5')) Decimal("101.5") ! >>> DefaultContext.abs(Decimal('-101.5')) Decimal("101.5") """ --- 2265,2275 ---- the plus operation on the operand. ! >>> ExtendedDefaultContext.abs(Decimal('2.1')) Decimal("2.1") ! >>> ExtendedDefaultContext.abs(Decimal('-100')) Decimal("100") ! >>> ExtendedDefaultContext.abs(Decimal('101.5')) Decimal("101.5") ! >>> ExtendedDefaultContext.abs(Decimal('-101.5')) Decimal("101.5") """ *************** *** 2280,2286 **** """Return the sum of the two operands. ! >>> DefaultContext.add(Decimal('12'), Decimal('7.00')) Decimal("19.00") ! >>> DefaultContext.add(Decimal('1E+2'), Decimal('1.01E+4')) Decimal("1.02E+4") """ --- 2279,2285 ---- """Return the sum of the two operands. ! >>> ExtendedDefaultContext.add(Decimal('12'), Decimal('7.00')) Decimal("19.00") ! >>> ExtendedDefaultContext.add(Decimal('1E+2'), Decimal('1.01E+4')) Decimal("1.02E+4") """ *************** *** 2304,2318 **** zero or negative zero, or '1' if the result is greater than zero. ! >>> DefaultContext.compare(Decimal('2.1'), Decimal('3')) Decimal("-1") ! >>> DefaultContext.compare(Decimal('2.1'), Decimal('2.1')) Decimal("0") ! >>> DefaultContext.compare(Decimal('2.1'), Decimal('2.10')) Decimal("0") ! >>> DefaultContext.compare(Decimal('3'), Decimal('2.1')) Decimal("1") ! >>> DefaultContext.compare(Decimal('2.1'), Decimal('-3')) Decimal("1") ! >>> DefaultContext.compare(Decimal('-3'), Decimal('2.1')) Decimal("-1") """ --- 2303,2317 ---- zero or negative zero, or '1' if the result is greater than zero. ! >>> ExtendedDefaultContext.compare(Decimal('2.1'), Decimal('3')) Decimal("-1") ! >>> ExtendedDefaultContext.compare(Decimal('2.1'), Decimal('2.1')) Decimal("0") ! >>> ExtendedDefaultContext.compare(Decimal('2.1'), Decimal('2.10')) Decimal("0") ! >>> ExtendedDefaultContext.compare(Decimal('3'), Decimal('2.1')) Decimal("1") ! >>> ExtendedDefaultContext.compare(Decimal('2.1'), Decimal('-3')) Decimal("1") ! >>> ExtendedDefaultContext.compare(Decimal('-3'), Decimal('2.1')) Decimal("-1") """ *************** *** 2322,2344 **** """Decimal division in a specified context. ! >>> DefaultContext.divide(Decimal('1'), Decimal('3')) Decimal("0.333333333") ! >>> DefaultContext.divide(Decimal('2'), Decimal('3')) Decimal("0.666666667") ! >>> DefaultContext.divide(Decimal('5'), Decimal('2')) Decimal("2.5") ! >>> DefaultContext.divide(Decimal('1'), Decimal('10')) Decimal("0.1") ! >>> DefaultContext.divide(Decimal('12'), Decimal('12')) Decimal("1") ! >>> DefaultContext.divide(Decimal('8.00'), Decimal('2')) Decimal("4.00") ! >>> DefaultContext.divide(Decimal('2.400'), Decimal('2.0')) Decimal("1.20") ! >>> DefaultContext.divide(Decimal('1000'), Decimal('100')) Decimal("10") ! >>> DefaultContext.divide(Decimal('1000'), Decimal('1')) Decimal("1000") ! >>> DefaultContext.divide(Decimal('2.40E+6'), Decimal('2')) Decimal("1.20E+6") """ --- 2321,2343 ---- """Decimal division in a specified context. ! >>> ExtendedDefaultContext.divide(Decimal('1'), Decimal('3')) Decimal("0.333333333") ! >>> ExtendedDefaultContext.divide(Decimal('2'), Decimal('3')) Decimal("0.666666667") ! >>> ExtendedDefaultContext.divide(Decimal('5'), Decimal('2')) Decimal("2.5") ! >>> ExtendedDefaultContext.divide(Decimal('1'), Decimal('10')) Decimal("0.1") ! >>> ExtendedDefaultContext.divide(Decimal('12'), Decimal('12')) Decimal("1") ! >>> ExtendedDefaultContext.divide(Decimal('8.00'), Decimal('2')) Decimal("4.00") ! >>> ExtendedDefaultContext.divide(Decimal('2.400'), Decimal('2.0')) Decimal("1.20") ! >>> ExtendedDefaultContext.divide(Decimal('1000'), Decimal('100')) Decimal("10") ! >>> ExtendedDefaultContext.divide(Decimal('1000'), Decimal('1')) Decimal("1000") ! >>> ExtendedDefaultContext.divide(Decimal('2.40E+6'), Decimal('2')) Decimal("1.20E+6") """ *************** *** 2348,2356 **** """Divides two numbers and returns the integer part of the result. ! >>> DefaultContext.divide_int(Decimal('2'), Decimal('3')) Decimal("0") ! >>> DefaultContext.divide_int(Decimal('10'), Decimal('3')) Decimal("3") ! >>> DefaultContext.divide_int(Decimal('1'), Decimal('0.3')) Decimal("3") """ --- 2347,2355 ---- """Divides two numbers and returns the integer part of the result. ! >>> ExtendedDefaultContext.divide_int(Decimal('2'), Decimal('3')) Decimal("0") ! >>> ExtendedDefaultContext.divide_int(Decimal('10'), Decimal('3')) Decimal("3") ! >>> ExtendedDefaultContext.divide_int(Decimal('1'), Decimal('0.3')) Decimal("3") """ *************** *** 2369,2377 **** infinity) of the two operands is chosen as the result. ! >>> DefaultContext.max(Decimal('3'), Decimal('2')) Decimal("3") ! >>> DefaultContext.max(Decimal('-10'), Decimal('3')) Decimal("3") ! >>> DefaultContext.max(Decimal('1.0'), Decimal('1')) Decimal("1.0") """ --- 2368,2376 ---- infinity) of the two operands is chosen as the result. ! >>> ExtendedDefaultContext.max(Decimal('3'), Decimal('2')) Decimal("3") ! >>> ExtendedDefaultContext.max(Decimal('-10'), Decimal('3')) Decimal("3") ! >>> ExtendedDefaultContext.max(Decimal('1.0'), Decimal('1')) Decimal("1.0") """ *************** *** 2387,2395 **** infinity) of the two operands is chosen as the result. ! >>> DefaultContext.min(Decimal('3'), Decimal('2')) Decimal("2") ! >>> DefaultContext.min(Decimal('-10'), Decimal('3')) Decimal("-10") ! >>> DefaultContext.min(Decimal('1.0'), Decimal('1')) Decimal("1.0") """ --- 2386,2394 ---- infinity) of the two operands is chosen as the result. ! >>> ExtendedDefaultContext.min(Decimal('3'), Decimal('2')) Decimal("2") ! >>> ExtendedDefaultContext.min(Decimal('-10'), Decimal('3')) Decimal("-10") ! >>> ExtendedDefaultContext.min(Decimal('1.0'), Decimal('1')) Decimal("1.0") """ *************** *** 2403,2409 **** has the same exponent as the operand. ! >>> DefaultContext.minus(Decimal('1.3')) Decimal("-1.3") ! >>> DefaultContext.minus(Decimal('-1.3')) Decimal("1.3") """ --- 2402,2408 ---- has the same exponent as the operand. ! >>> ExtendedDefaultContext.minus(Decimal('1.3')) Decimal("-1.3") ! >>> ExtendedDefaultContext.minus(Decimal('-1.3')) Decimal("1.3") """ *************** *** 2418,2430 **** of the two operands. ! >>> DefaultContext.multiply(Decimal('1.20'), Decimal('3')) Decimal("3.60") ! >>> DefaultContext.multiply(Decimal('7'), Decimal('3')) Decimal("21") ! >>> DefaultContext.multiply(Decimal('0.9'), Decimal('0.8')) Decimal("0.72") ! >>> DefaultContext.multiply(Decimal('0.9'), Decimal('-0')) Decimal("-0.0") ! >>> DefaultContext.multiply(Decimal('654321'), Decimal('654321')) Decimal("4.28135971E+11") """ --- 2417,2429 ---- of the two operands. ! >>> ExtendedDefaultContext.multiply(Decimal('1.20'), Decimal('3')) Decimal("3.60") ! >>> ExtendedDefaultContext.multiply(Decimal('7'), Decimal('3')) Decimal("21") ! >>> ExtendedDefaultContext.multiply(Decimal('0.9'), Decimal('0.8')) Decimal("0.72") ! >>> ExtendedDefaultContext.multiply(Decimal('0.9'), Decimal('-0')) Decimal("-0.0") ! >>> ExtendedDefaultContext.multiply(Decimal('654321'), Decimal('654321')) Decimal("4.28135971E+11") """ *************** *** 2437,2451 **** result. ! >>> DefaultContext.normalize(Decimal('2.1')) Decimal("2.1") ! >>> DefaultContext.normalize(Decimal('-2.0')) Decimal("-2") ! >>> DefaultContext.normalize(Decimal('1.200')) Decimal("1.2") ! >>> DefaultContext.normalize(Decimal('-120')) Decimal("-1.2E+2") ! >>> DefaultContext.normalize(Decimal('120.00')) Decimal("1.2E+2") ! >>> DefaultContext.normalize(Decimal('0.00')) Decimal("0") """ --- 2436,2450 ---- result. ! >>> ExtendedDefaultContext.normalize(Decimal('2.1')) Decimal("2.1") ! >>> ExtendedDefaultContext.normalize(Decimal('-2.0')) Decimal("-2") ! >>> ExtendedDefaultContext.normalize(Decimal('1.200')) Decimal("1.2") ! >>> ExtendedDefaultContext.normalize(Decimal('-120')) Decimal("-1.2E+2") ! >>> ExtendedDefaultContext.normalize(Decimal('120.00')) Decimal("1.2E+2") ! >>> ExtendedDefaultContext.normalize(Decimal('0.00')) Decimal("0") """ *************** *** 2459,2465 **** has the same exponent as the operand. ! >>> DefaultContext.plus(Decimal('1.3')) Decimal("1.3") ! >>> DefaultContext.plus(Decimal('-1.3')) Decimal("-1.3") """ --- 2458,2464 ---- has the same exponent as the operand. ! >>> ExtendedDefaultContext.plus(Decimal('1.3')) Decimal("1.3") ! >>> ExtendedDefaultContext.plus(Decimal('-1.3')) Decimal("-1.3") """ *************** *** 2484,2514 **** continues. ! >>> DefaultContext.power(Decimal('2'), Decimal('3')) Decimal("8") ! >>> DefaultContext.power(Decimal('2'), Decimal('-3')) Decimal("0.125") ! >>> DefaultContext.power(Decimal('1.7'), Decimal('8')) Decimal("69.7575744") ! >>> DefaultContext.power(Decimal('Infinity'), Decimal('-2')) Decimal("0") ! >>> DefaultContext.power(Decimal('Infinity'), Decimal('-1')) Decimal("0") ! >>> DefaultContext.power(Decimal('Infinity'), Decimal('0')) Decimal("1") ! >>> DefaultContext.power(Decimal('Infinity'), Decimal('1')) Decimal("Infinity") ! >>> DefaultContext.power(Decimal('Infinity'), Decimal('2')) Decimal("Infinity") ! >>> DefaultContext.power(Decimal('-Infinity'), Decimal('-2')) Decimal("0") ! >>> DefaultContext.power(Decimal('-Infinity'), Decimal('-1')) Decimal("-0") ! >>> DefaultContext.power(Decimal('-Infinity'), Decimal('0')) Decimal("1") ! >>> DefaultContext.power(Decimal('-Infinity'), Decimal('1')) Decimal("-Infinity") ! >>> DefaultContext.power(Decimal('-Infinity'), Decimal('2')) Decimal("Infinity") ! >>> DefaultContext.power(Decimal('0'), Decimal('0')) Decimal("NaN") """ --- 2483,2513 ---- continues. ! >>> ExtendedDefaultContext.power(Decimal('2'), Decimal('3')) Decimal("8") ! >>> ExtendedDefaultContext.power(Decimal('2'), Decimal('-3')) Decimal("0.125") ! >>> ExtendedDefaultContext.power(Decimal('1.7'), Decimal('8')) Decimal("69.7575744") ! >>> ExtendedDefaultContext.power(Decimal('Infinity'), Decimal('-2')) Decimal("0") ! >>> ExtendedDefaultContext.power(Decimal('Infinity'), Decimal('-1')) Decimal("0") ! >>> ExtendedDefaultContext.power(Decimal('Infinity'), Decimal('0')) Decimal("1") ! >>> ExtendedDefaultContext.power(Decimal('Infinity'), Decimal('1')) Decimal("Infinity") ! >>> ExtendedDefaultContext.power(Decimal('Infinity'), Decimal('2')) Decimal("Infinity") ! >>> ExtendedDefaultContext.power(Decimal('-Infinity'), Decimal('-2')) Decimal("0") ! >>> ExtendedDefaultContext.power(Decimal('-Infinity'), Decimal('-1')) Decimal("-0") ! >>> ExtendedDefaultContext.power(Decimal('-Infinity'), Decimal('0')) Decimal("1") ! >>> ExtendedDefaultContext.power(Decimal('-Infinity'), Decimal('1')) Decimal("-Infinity") ! >>> ExtendedDefaultContext.power(Decimal('-Infinity'), Decimal('2')) Decimal("Infinity") ! >>> ExtendedDefaultContext.power(Decimal('0'), Decimal('0')) Decimal("NaN") """ *************** *** 2533,2565 **** if the result is subnormal and inexact. ! >>> DefaultContext.quantize(Decimal('2.17'), Decimal('0.001')) Decimal("2.170") ! >>> DefaultContext.quantize(Decimal('2.17'), Decimal('0.01')) Decimal("2.17") ! >>> DefaultContext.quantize(Decimal('2.17'), Decimal('0.1')) Decimal("2.2") ! >>> DefaultContext.quantize(Decimal('2.17'), Decimal('1e+0')) Decimal("2") ! >>> DefaultContext.quantize(Decimal('2.17'), Decimal('1e+1')) Decimal("0E+1") ! >>> DefaultContext.quantize(Decimal('-Inf'), Decimal('Infinity')) Decimal("-Infinity") ! >>> DefaultContext.quantize(Decimal('2'), Decimal('Infinity')) Decimal("NaN") ! >>> DefaultContext.quantize(Decimal('-0.1'), Decimal('1')) Decimal("-0") ! >>> DefaultContext.quantize(Decimal('-0'), Decimal('1e+5')) Decimal("-0E+5") ! >>> DefaultContext.quantize(Decimal('+35236450.6'), Decimal('1e-2')) Decimal("NaN") ! >>> DefaultContext.quantize(Decimal('-35236450.6'), Decimal('1e-2')) Decimal("NaN") ! >>> DefaultContext.quantize(Decimal('217'), Decimal('1e-1')) Decimal("217.0") ! >>> DefaultContext.quantize(Decimal('217'), Decimal('1e-0')) Decimal("217") ! >>> DefaultContext.quantize(Decimal('217'), Decimal('1e+1')) Decimal("2.2E+2") ! >>> DefaultContext.quantize(Decimal('217'), Decimal('1e+2')) Decimal("2E+2") """ --- 2532,2564 ---- if the result is subnormal and inexact. ! >>> ExtendedDefaultContext.quantize(Decimal('2.17'), Decimal('0.001')) Decimal("2.170") ! >>> ExtendedDefaultContext.quantize(Decimal('2.17'), Decimal('0.01')) Decimal("2.17") ! >>> ExtendedDefaultContext.quantize(Decimal('2.17'), Decimal('0.1')) Decimal("2.2") ! >>> ExtendedDefaultContext.quantize(Decimal('2.17'), Decimal('1e+0')) Decimal("2") ! >>> ExtendedDefaultContext.quantize(Decimal('2.17'), Decimal('1e+1')) Decimal("0E+1") ! >>> ExtendedDefaultContext.quantize(Decimal('-Inf'), Decimal('Infinity')) Decimal("-Infinity") ! >>> ExtendedDefaultContext.quantize(Decimal('2'), Decimal('Infinity')) Decimal("NaN") ! >>> ExtendedDefaultContext.quantize(Decimal('-0.1'), Decimal('1')) Decimal("-0") ! >>> ExtendedDefaultContext.quantize(Decimal('-0'), Decimal('1e+5')) Decimal("-0E+5") ! >>> ExtendedDefaultContext.quantize(Decimal('+35236450.6'), Decimal('1e-2')) Decimal("NaN") ! >>> ExtendedDefaultContext.quantize(Decimal('-35236450.6'), Decimal('1e-2')) Decimal("NaN") ! >>> ExtendedDefaultContext.quantize(Decimal('217'), Decimal('1e-1')) Decimal("217.0") ! >>> ExtendedDefaultContext.quantize(Decimal('217'), Decimal('1e-0')) Decimal("217") ! >>> ExtendedDefaultContext.quantize(Decimal('217'), Decimal('1e+1')) Decimal("2.2E+2") ! >>> ExtendedDefaultContext.quantize(Decimal('217'), Decimal('1e+2')) Decimal("2E+2") """ *************** *** 2578,2592 **** remainder cannot be calculated). ! >>> DefaultContext.remainder(Decimal('2.1'), Decimal('3')) Decimal("2.1") ! >>> DefaultContext.remainder(Decimal('10'), Decimal('3')) Decimal("1") ! >>> DefaultContext.remainder(Decimal('-10'), Decimal('3')) Decimal("-1") ! >>> DefaultContext.remainder(Decimal('10.2'), Decimal('1')) Decimal("0.2") ! >>> DefaultContext.remainder(Decimal('10'), Decimal('0.3')) Decimal("0.1") ! >>> DefaultContext.remainder(Decimal('3.6'), Decimal('1.3')) Decimal("1.0") """ --- 2577,2591 ---- remainder cannot be calculated). ! >>> ExtendedDefaultContext.remainder(Decimal('2.1'), Decimal('3')) Decimal("2.1") ! >>> ExtendedDefaultContext.remainder(Decimal('10'), Decimal('3')) Decimal("1") ! >>> ExtendedDefaultContext.remainder(Decimal('-10'), Decimal('3')) Decimal("-1") ! >>> ExtendedDefaultContext.remainder(Decimal('10.2'), Decimal('1')) Decimal("0.2") ! >>> ExtendedDefaultContext.remainder(Decimal('10'), Decimal('0.3')) Decimal("0.1") ! >>> ExtendedDefaultContext.remainder(Decimal('3.6'), Decimal('1.3')) Decimal("1.0") """ *************** *** 2603,2619 **** remainder cannot be calculated). ! >>> DefaultContext.remainder_near(Decimal('2.1'), Decimal('3')) Decimal("-0.9") ! >>> DefaultContext.remainder_near(Decimal('10'), Decimal('6')) Decimal("-2") ! >>> DefaultContext.remainder_near(Decimal('10'), Decimal('3')) Decimal("1") ! >>> DefaultContext.remainder_near(Decimal('-10'), Decimal('3')) Decimal("-1") ! >>> DefaultContext.remainder_near(Decimal('10.2'), Decimal('1')) Decimal("0.2") ! >>> DefaultContext.remainder_near(Decimal('10'), Decimal('0.3')) Decimal("0.1") ! >>> DefaultContext.remainder_near(Decimal('3.6'), Decimal('1.3')) Decimal("-0.3") """ --- 2602,2618 ---- remainder cannot be calculated). ! >>> ExtendedDefaultContext.remainder_near(Decimal('2.1'), Decimal('3')) Decimal("-0.9") ! >>> ExtendedDefaultContext.remainder_near(Decimal('10'), Decimal('6')) Decimal("-2") ! >>> ExtendedDefaultContext.remainder_near(Decimal('10'), Decimal('3')) Decimal("1") ! >>> ExtendedDefaultContext.remainder_near(Decimal('-10'), Decimal('3')) Decimal("-1") ! >>> ExtendedDefaultContext.remainder_near(Decimal('10.2'), Decimal('1')) Decimal("0.2") ! >>> ExtendedDefaultContext.remainder_near(Decimal('10'), Decimal('0.3')) Decimal("0.1") ! >>> ExtendedDefaultContext.remainder_near(Decimal('3.6'), Decimal('1.3')) Decimal("-0.3") """ *************** *** 2626,2636 **** either operand. ! >>> DefaultContext.same_quantum(Decimal('2.17'), Decimal('0.001')) False ! >>> DefaultContext.same_quantum(Decimal('2.17'), Decimal('0.01')) True ! >>> DefaultContext.same_quantum(Decimal('2.17'), Decimal('1')) False ! >>> DefaultContext.same_quantum(Decimal('Inf'), Decimal('-Inf')) True """ --- 2625,2635 ---- either operand. ! >>> ExtendedDefaultContext.same_quantum(Decimal('2.17'), Decimal('0.001')) False ! >>> ExtendedDefaultContext.same_quantum(Decimal('2.17'), Decimal('0.01')) True ! >>> ExtendedDefaultContext.same_quantum(Decimal('2.17'), Decimal('1')) False ! >>> ExtendedDefaultContext.same_quantum(Decimal('Inf'), Decimal('-Inf')) True """ *************** *** 2643,2664 **** algorithm. ! >>> DefaultContext.sqrt(Decimal('0')) Decimal("0") ! >>> DefaultContext.sqrt(Decimal('-0')) Decimal("-0") ! >>> DefaultContext.sqrt(Decimal('0.39')) Decimal("0.624499800") ! >>> DefaultContext.sqrt(Decimal('100')) Decimal("10") ! >>> DefaultContext.sqrt(Decimal('1')) Decimal("1") ! >>> DefaultContext.sqrt(Decimal('1.0')) Decimal("1.0") ! >>> DefaultContext.sqrt(Decimal('1.00')) Decimal("1.0") ! >>> DefaultContext.sqrt(Decimal('7')) Decimal("2.64575131") ! >>> DefaultContext.sqrt(Decimal('10')) Decimal("3.16227766") """ return a.sqrt(context=self) --- 2642,2665 ---- algorithm. ! >>> ExtendedDefaultContext.sqrt(Decimal('0')) Decimal("0") ! >>> ExtendedDefaultContext.sqrt(Decimal('-0')) Decimal("-0") ! >>> ExtendedDefaultContext.sqrt(Decimal('0.39')) Decimal("0.624499800") ! >>> ExtendedDefaultContext.sqrt(Decimal('100')) Decimal("10") ! >>> ExtendedDefaultContext.sqrt(Decimal('1')) Decimal("1") ! >>> ExtendedDefaultContext.sqrt(Decimal('1.0')) Decimal("1.0") ! >>> ExtendedDefaultContext.sqrt(Decimal('1.00')) Decimal("1.0") ! >>> ExtendedDefaultContext.sqrt(Decimal('7')) Decimal("2.64575131") ! >>> ExtendedDefaultContext.sqrt(Decimal('10')) Decimal("3.16227766") + >>> ExtendedDefaultContext.prec + 9 """ return a.sqrt(context=self) *************** *** 2667,2675 **** """Return the sum of the two operands. ! >>> DefaultContext.subtract(Decimal('1.3'), Decimal('1.07')) Decimal("0.23") ! >>> DefaultContext.subtract(Decimal('1.3'), Decimal('1.30')) Decimal("0.00") ! >>> DefaultContext.subtract(Decimal('1.3'), Decimal('2.07')) Decimal("-0.77") """ --- 2668,2676 ---- """Return the sum of the two operands. ! >>> ExtendedDefaultContext.subtract(Decimal('1.3'), Decimal('1.07')) Decimal("0.23") ! >>> ExtendedDefaultContext.subtract(Decimal('1.3'), Decimal('1.30')) Decimal("0.00") ! >>> ExtendedDefaultContext.subtract(Decimal('1.3'), Decimal('2.07')) Decimal("-0.77") """ *************** *** 2699,2717 **** be set. The rounding mode is taken from the context. ! >>> DefaultContext.to_integral(Decimal('2.1')) Decimal("2") ! >>> DefaultContext.to_integral(Decimal('100')) Decimal("100") ! >>> DefaultContext.to_integral(Decimal('100.0')) Decimal("100") ! >>> DefaultContext.to_integral(Decimal('101.5')) Decimal("102") ! >>> DefaultContext.to_integral(Decimal('-101.5')) Decimal("-102") ! >>> DefaultContext.to_integral(Decimal('10E+5')) Decimal("1.0E+6") ! >>> DefaultContext.to_integral(Decimal('7.89E+77')) Decimal("7.89E+77") ! >>> DefaultContext.to_integral(Decimal('-Inf')) Decimal("-Infinity") """ --- 2700,2718 ---- be set. The rounding mode is taken from the context. ! >>> ExtendedDefaultContext.to_integral(Decimal('2.1')) Decimal("2") ! >>> ExtendedDefaultContext.to_integral(Decimal('100')) Decimal("100") ! >>> ExtendedDefaultContext.to_integral(Decimal('100.0')) Decimal("100") ! >>> ExtendedDefaultContext.to_integral(Decimal('101.5')) Decimal("102") ! >>> ExtendedDefaultContext.to_integral(Decimal('-101.5')) Decimal("-102") ! >>> ExtendedDefaultContext.to_integral(Decimal('10E+5')) Decimal("1.0E+6") ! >>> ExtendedDefaultContext.to_integral(Decimal('7.89E+77')) Decimal("7.89E+77") ! >>> ExtendedDefaultContext.to_integral(Decimal('-Inf')) Decimal("-Infinity") """ *************** *** 2963,2967 **** DefaultContext = Context( ! prec=SINGLE_PRECISION, rounding=ROUND_HALF_EVEN, trap_enablers=dict.fromkeys(Signals, 0), flags=None, --- 2964,2968 ---- DefaultContext = Context( ! prec=28, rounding=ROUND_HALF_EVEN, trap_enablers=dict.fromkeys(Signals, 0), flags=None, *************** *** 2982,2986 **** ExtendedDefaultContext = Context( ! prec=SINGLE_PRECISION, rounding=ROUND_HALF_EVEN, trap_enablers=dict.fromkeys(Signals, 0), flags=None, --- 2983,2987 ---- ExtendedDefaultContext = Context( ! prec=9, rounding=ROUND_HALF_EVEN, trap_enablers=dict.fromkeys(Signals, 0), flags=None, From rhettinger at users.sourceforge.net Sat Jul 3 09:49:05 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jul 3 09:49:09 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13623 Modified Files: decimal.py Log Message: Namespace cleanups: * delete temporary globals immediately after use * move a global into a class variable * Rename BasicDefaultContext and ExtendedDefaultContext to BasicContext and ExtendedContext. Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** decimal.py 3 Jul 2004 12:26:21 -0000 1.4 --- decimal.py 3 Jul 2004 13:48:56 -0000 1.5 *************** *** 121,125 **** # Contexts ! 'DefaultContext', 'BasicDefaultContext', 'ExtendedDefaultContext', # Exceptions --- 121,125 ---- # Contexts ! 'DefaultContext', 'BasicContext', 'ExtendedContext', # Exceptions *************** *** 148,152 **** import math import operator - xor = operator.xor #Exponent Range --- 148,151 ---- *************** *** 163,167 **** ROUND_HALF_DOWN = 'half_down' ! #Rounding decision NEVER_ROUND = 'never' # Round in division (non-divmod), sqrt ONLY ALWAYS_ROUND = 'always' # Every operation rounds at end. --- 162,166 ---- ROUND_HALF_DOWN = 'half_down' ! #Rounding decision (not part of the public API) NEVER_ROUND = 'never' # Round in division (non-divmod), sqrt ONLY ALWAYS_ROUND = 'always' # Every operation rounds at end. *************** *** 1051,1055 **** return ans ! resultsign = xor(self._sign, other._sign) if self._isinfinity(): if not other: --- 1050,1054 ---- return ans ! resultsign = operator.xor(self._sign, other._sign) if self._isinfinity(): if not other: *************** *** 1145,1149 **** return ans ! sign = xor(self._sign, other._sign) if not self and not other: if divmod: --- 1144,1148 ---- return ans ! sign = operator.xor(self._sign, other._sign) if not self and not other: if divmod: *************** *** 2114,2118 **** Decimal._pick_rounding_function[val] = name ! DefaultLock = threading.Lock() class Context(object): --- 2113,2117 ---- Decimal._pick_rounding_function[val] = name ! del name, val, globalname, rounding_functions class Context(object): *************** *** 2136,2139 **** --- 2135,2141 ---- clamp - If 1, change exponents if too high (Default 0) """ + + DefaultLock = threading.Lock() + def __init__(self, prec=None, rounding=None, trap_enablers=None, flags=None, *************** *** 2144,2148 **** if flags is None: flags = dict.fromkeys(Signals, 0) ! DefaultLock.acquire() for name, val in locals().items(): if val is None: --- 2146,2150 ---- if flags is None: flags = dict.fromkeys(Signals, 0) ! self.DefaultLock.acquire() for name, val in locals().items(): if val is None: *************** *** 2150,2154 **** else: setattr(self, name, val) ! DefaultLock.release() del self.self --- 2152,2156 ---- else: setattr(self, name, val) ! self.DefaultLock.release() del self.self *************** *** 2164,2167 **** --- 2166,2170 ---- self.capitals, self._clamp, self._ignored_flags) return nc + __copy__ = copy def _raise_error(self, error, explanation = None, *args): *************** *** 2265,2275 **** the plus operation on the operand. ! >>> ExtendedDefaultContext.abs(Decimal('2.1')) Decimal("2.1") ! >>> ExtendedDefaultContext.abs(Decimal('-100')) Decimal("100") ! >>> ExtendedDefaultContext.abs(Decimal('101.5')) Decimal("101.5") ! >>> ExtendedDefaultContext.abs(Decimal('-101.5')) Decimal("101.5") """ --- 2268,2278 ---- the plus operation on the operand. ! >>> ExtendedContext.abs(Decimal('2.1')) Decimal("2.1") ! >>> ExtendedContext.abs(Decimal('-100')) Decimal("100") ! >>> ExtendedContext.abs(Decimal('101.5')) Decimal("101.5") ! >>> ExtendedContext.abs(Decimal('-101.5')) Decimal("101.5") """ *************** *** 2279,2285 **** """Return the sum of the two operands. ! >>> ExtendedDefaultContext.add(Decimal('12'), Decimal('7.00')) Decimal("19.00") ! >>> ExtendedDefaultContext.add(Decimal('1E+2'), Decimal('1.01E+4')) Decimal("1.02E+4") """ --- 2282,2288 ---- """Return the sum of the two operands. ! >>> ExtendedContext.add(Decimal('12'), Decimal('7.00')) Decimal("19.00") ! >>> ExtendedContext.add(Decimal('1E+2'), Decimal('1.01E+4')) Decimal("1.02E+4") """ *************** *** 2303,2317 **** zero or negative zero, or '1' if the result is greater than zero. ! >>> ExtendedDefaultContext.compare(Decimal('2.1'), Decimal('3')) Decimal("-1") ! >>> ExtendedDefaultContext.compare(Decimal('2.1'), Decimal('2.1')) Decimal("0") ! >>> ExtendedDefaultContext.compare(Decimal('2.1'), Decimal('2.10')) Decimal("0") ! >>> ExtendedDefaultContext.compare(Decimal('3'), Decimal('2.1')) Decimal("1") ! >>> ExtendedDefaultContext.compare(Decimal('2.1'), Decimal('-3')) Decimal("1") ! >>> ExtendedDefaultContext.compare(Decimal('-3'), Decimal('2.1')) Decimal("-1") """ --- 2306,2320 ---- zero or negative zero, or '1' if the result is greater than zero. ! >>> ExtendedContext.compare(Decimal('2.1'), Decimal('3')) Decimal("-1") ! >>> ExtendedContext.compare(Decimal('2.1'), Decimal('2.1')) Decimal("0") ! >>> ExtendedContext.compare(Decimal('2.1'), Decimal('2.10')) Decimal("0") ! >>> ExtendedContext.compare(Decimal('3'), Decimal('2.1')) Decimal("1") ! >>> ExtendedContext.compare(Decimal('2.1'), Decimal('-3')) Decimal("1") ! >>> ExtendedContext.compare(Decimal('-3'), Decimal('2.1')) Decimal("-1") """ *************** *** 2321,2343 **** """Decimal division in a specified context. ! >>> ExtendedDefaultContext.divide(Decimal('1'), Decimal('3')) Decimal("0.333333333") ! >>> ExtendedDefaultContext.divide(Decimal('2'), Decimal('3')) Decimal("0.666666667") ! >>> ExtendedDefaultContext.divide(Decimal('5'), Decimal('2')) Decimal("2.5") ! >>> ExtendedDefaultContext.divide(Decimal('1'), Decimal('10')) Decimal("0.1") ! >>> ExtendedDefaultContext.divide(Decimal('12'), Decimal('12')) Decimal("1") ! >>> ExtendedDefaultContext.divide(Decimal('8.00'), Decimal('2')) Decimal("4.00") ! >>> ExtendedDefaultContext.divide(Decimal('2.400'), Decimal('2.0')) Decimal("1.20") ! >>> ExtendedDefaultContext.divide(Decimal('1000'), Decimal('100')) Decimal("10") ! >>> ExtendedDefaultContext.divide(Decimal('1000'), Decimal('1')) Decimal("1000") ! >>> ExtendedDefaultContext.divide(Decimal('2.40E+6'), Decimal('2')) Decimal("1.20E+6") """ --- 2324,2346 ---- """Decimal division in a specified context. ! >>> ExtendedContext.divide(Decimal('1'), Decimal('3')) Decimal("0.333333333") ! >>> ExtendedContext.divide(Decimal('2'), Decimal('3')) Decimal("0.666666667") ! >>> ExtendedContext.divide(Decimal('5'), Decimal('2')) Decimal("2.5") ! >>> ExtendedContext.divide(Decimal('1'), Decimal('10')) Decimal("0.1") ! >>> ExtendedContext.divide(Decimal('12'), Decimal('12')) Decimal("1") ! >>> ExtendedContext.divide(Decimal('8.00'), Decimal('2')) Decimal("4.00") ! >>> ExtendedContext.divide(Decimal('2.400'), Decimal('2.0')) Decimal("1.20") ! >>> ExtendedContext.divide(Decimal('1000'), Decimal('100')) Decimal("10") ! >>> ExtendedContext.divide(Decimal('1000'), Decimal('1')) Decimal("1000") ! >>> ExtendedContext.divide(Decimal('2.40E+6'), Decimal('2')) Decimal("1.20E+6") """ *************** *** 2347,2355 **** """Divides two numbers and returns the integer part of the result. ! >>> ExtendedDefaultContext.divide_int(Decimal('2'), Decimal('3')) Decimal("0") ! >>> ExtendedDefaultContext.divide_int(Decimal('10'), Decimal('3')) Decimal("3") ! >>> ExtendedDefaultContext.divide_int(Decimal('1'), Decimal('0.3')) Decimal("3") """ --- 2350,2358 ---- """Divides two numbers and returns the integer part of the result. ! >>> ExtendedContext.divide_int(Decimal('2'), Decimal('3')) Decimal("0") ! >>> ExtendedContext.divide_int(Decimal('10'), Decimal('3')) Decimal("3") ! >>> ExtendedContext.divide_int(Decimal('1'), Decimal('0.3')) Decimal("3") """ *************** *** 2368,2376 **** infinity) of the two operands is chosen as the result. ! >>> ExtendedDefaultContext.max(Decimal('3'), Decimal('2')) Decimal("3") ! >>> ExtendedDefaultContext.max(Decimal('-10'), Decimal('3')) Decimal("3") ! >>> ExtendedDefaultContext.max(Decimal('1.0'), Decimal('1')) Decimal("1.0") """ --- 2371,2379 ---- infinity) of the two operands is chosen as the result. ! >>> ExtendedContext.max(Decimal('3'), Decimal('2')) Decimal("3") ! >>> ExtendedContext.max(Decimal('-10'), Decimal('3')) Decimal("3") ! >>> ExtendedContext.max(Decimal('1.0'), Decimal('1')) Decimal("1.0") """ *************** *** 2386,2394 **** infinity) of the two operands is chosen as the result. ! >>> ExtendedDefaultContext.min(Decimal('3'), Decimal('2')) Decimal("2") ! >>> ExtendedDefaultContext.min(Decimal('-10'), Decimal('3')) Decimal("-10") ! >>> ExtendedDefaultContext.min(Decimal('1.0'), Decimal('1')) Decimal("1.0") """ --- 2389,2397 ---- infinity) of the two operands is chosen as the result. ! >>> ExtendedContext.min(Decimal('3'), Decimal('2')) Decimal("2") ! >>> ExtendedContext.min(Decimal('-10'), Decimal('3')) Decimal("-10") ! >>> ExtendedContext.min(Decimal('1.0'), Decimal('1')) Decimal("1.0") """ *************** *** 2402,2408 **** has the same exponent as the operand. ! >>> ExtendedDefaultContext.minus(Decimal('1.3')) Decimal("-1.3") ! >>> ExtendedDefaultContext.minus(Decimal('-1.3')) Decimal("1.3") """ --- 2405,2411 ---- has the same exponent as the operand. ! >>> ExtendedContext.minus(Decimal('1.3')) Decimal("-1.3") ! >>> ExtendedContext.minus(Decimal('-1.3')) Decimal("1.3") """ *************** *** 2417,2429 **** of the two operands. ! >>> ExtendedDefaultContext.multiply(Decimal('1.20'), Decimal('3')) Decimal("3.60") ! >>> ExtendedDefaultContext.multiply(Decimal('7'), Decimal('3')) Decimal("21") ! >>> ExtendedDefaultContext.multiply(Decimal('0.9'), Decimal('0.8')) Decimal("0.72") ! >>> ExtendedDefaultContext.multiply(Decimal('0.9'), Decimal('-0')) Decimal("-0.0") ! >>> ExtendedDefaultContext.multiply(Decimal('654321'), Decimal('654321')) Decimal("4.28135971E+11") """ --- 2420,2432 ---- of the two operands. ! >>> ExtendedContext.multiply(Decimal('1.20'), Decimal('3')) Decimal("3.60") ! >>> ExtendedContext.multiply(Decimal('7'), Decimal('3')) Decimal("21") ! >>> ExtendedContext.multiply(Decimal('0.9'), Decimal('0.8')) Decimal("0.72") ! >>> ExtendedContext.multiply(Decimal('0.9'), Decimal('-0')) Decimal("-0.0") ! >>> ExtendedContext.multiply(Decimal('654321'), Decimal('654321')) Decimal("4.28135971E+11") """ *************** *** 2436,2450 **** result. ! >>> ExtendedDefaultContext.normalize(Decimal('2.1')) Decimal("2.1") ! >>> ExtendedDefaultContext.normalize(Decimal('-2.0')) Decimal("-2") ! >>> ExtendedDefaultContext.normalize(Decimal('1.200')) Decimal("1.2") ! >>> ExtendedDefaultContext.normalize(Decimal('-120')) Decimal("-1.2E+2") ! >>> ExtendedDefaultContext.normalize(Decimal('120.00')) Decimal("1.2E+2") ! >>> ExtendedDefaultContext.normalize(Decimal('0.00')) Decimal("0") """ --- 2439,2453 ---- result. ! >>> ExtendedContext.normalize(Decimal('2.1')) Decimal("2.1") ! >>> ExtendedContext.normalize(Decimal('-2.0')) Decimal("-2") ! >>> ExtendedContext.normalize(Decimal('1.200')) Decimal("1.2") ! >>> ExtendedContext.normalize(Decimal('-120')) Decimal("-1.2E+2") ! >>> ExtendedContext.normalize(Decimal('120.00')) Decimal("1.2E+2") ! >>> ExtendedContext.normalize(Decimal('0.00')) Decimal("0") """ *************** *** 2458,2464 **** has the same exponent as the operand. ! >>> ExtendedDefaultContext.plus(Decimal('1.3')) Decimal("1.3") ! >>> ExtendedDefaultContext.plus(Decimal('-1.3')) Decimal("-1.3") """ --- 2461,2467 ---- has the same exponent as the operand. ! >>> ExtendedContext.plus(Decimal('1.3')) Decimal("1.3") ! >>> ExtendedContext.plus(Decimal('-1.3')) Decimal("-1.3") """ *************** *** 2483,2513 **** continues. ! >>> ExtendedDefaultContext.power(Decimal('2'), Decimal('3')) Decimal("8") ! >>> ExtendedDefaultContext.power(Decimal('2'), Decimal('-3')) Decimal("0.125") ! >>> ExtendedDefaultContext.power(Decimal('1.7'), Decimal('8')) Decimal("69.7575744") ! >>> ExtendedDefaultContext.power(Decimal('Infinity'), Decimal('-2')) Decimal("0") ! >>> ExtendedDefaultContext.power(Decimal('Infinity'), Decimal('-1')) Decimal("0") ! >>> ExtendedDefaultContext.power(Decimal('Infinity'), Decimal('0')) Decimal("1") ! >>> ExtendedDefaultContext.power(Decimal('Infinity'), Decimal('1')) Decimal("Infinity") ! >>> ExtendedDefaultContext.power(Decimal('Infinity'), Decimal('2')) Decimal("Infinity") ! >>> ExtendedDefaultContext.power(Decimal('-Infinity'), Decimal('-2')) Decimal("0") ! >>> ExtendedDefaultContext.power(Decimal('-Infinity'), Decimal('-1')) Decimal("-0") ! >>> ExtendedDefaultContext.power(Decimal('-Infinity'), Decimal('0')) Decimal("1") ! >>> ExtendedDefaultContext.power(Decimal('-Infinity'), Decimal('1')) Decimal("-Infinity") ! >>> ExtendedDefaultContext.power(Decimal('-Infinity'), Decimal('2')) Decimal("Infinity") ! >>> ExtendedDefaultContext.power(Decimal('0'), Decimal('0')) Decimal("NaN") """ --- 2486,2516 ---- continues. ! >>> ExtendedContext.power(Decimal('2'), Decimal('3')) Decimal("8") ! >>> ExtendedContext.power(Decimal('2'), Decimal('-3')) Decimal("0.125") ! >>> ExtendedContext.power(Decimal('1.7'), Decimal('8')) Decimal("69.7575744") ! >>> ExtendedContext.power(Decimal('Infinity'), Decimal('-2')) Decimal("0") ! >>> ExtendedContext.power(Decimal('Infinity'), Decimal('-1')) Decimal("0") ! >>> ExtendedContext.power(Decimal('Infinity'), Decimal('0')) Decimal("1") ! >>> ExtendedContext.power(Decimal('Infinity'), Decimal('1')) Decimal("Infinity") ! >>> ExtendedContext.power(Decimal('Infinity'), Decimal('2')) Decimal("Infinity") ! >>> ExtendedContext.power(Decimal('-Infinity'), Decimal('-2')) Decimal("0") ! >>> ExtendedContext.power(Decimal('-Infinity'), Decimal('-1')) Decimal("-0") ! >>> ExtendedContext.power(Decimal('-Infinity'), Decimal('0')) Decimal("1") ! >>> ExtendedContext.power(Decimal('-Infinity'), Decimal('1')) Decimal("-Infinity") ! >>> ExtendedContext.power(Decimal('-Infinity'), Decimal('2')) Decimal("Infinity") ! >>> ExtendedContext.power(Decimal('0'), Decimal('0')) Decimal("NaN") """ *************** *** 2532,2564 **** if the result is subnormal and inexact. ! >>> ExtendedDefaultContext.quantize(Decimal('2.17'), Decimal('0.001')) Decimal("2.170") ! >>> ExtendedDefaultContext.quantize(Decimal('2.17'), Decimal('0.01')) Decimal("2.17") ! >>> ExtendedDefaultContext.quantize(Decimal('2.17'), Decimal('0.1')) Decimal("2.2") ! >>> ExtendedDefaultContext.quantize(Decimal('2.17'), Decimal('1e+0')) Decimal("2") ! >>> ExtendedDefaultContext.quantize(Decimal('2.17'), Decimal('1e+1')) Decimal("0E+1") ! >>> ExtendedDefaultContext.quantize(Decimal('-Inf'), Decimal('Infinity')) Decimal("-Infinity") ! >>> ExtendedDefaultContext.quantize(Decimal('2'), Decimal('Infinity')) Decimal("NaN") ! >>> ExtendedDefaultContext.quantize(Decimal('-0.1'), Decimal('1')) Decimal("-0") ! >>> ExtendedDefaultContext.quantize(Decimal('-0'), Decimal('1e+5')) Decimal("-0E+5") ! >>> ExtendedDefaultContext.quantize(Decimal('+35236450.6'), Decimal('1e-2')) Decimal("NaN") ! >>> ExtendedDefaultContext.quantize(Decimal('-35236450.6'), Decimal('1e-2')) Decimal("NaN") ! >>> ExtendedDefaultContext.quantize(Decimal('217'), Decimal('1e-1')) Decimal("217.0") ! >>> ExtendedDefaultContext.quantize(Decimal('217'), Decimal('1e-0')) Decimal("217") ! >>> ExtendedDefaultContext.quantize(Decimal('217'), Decimal('1e+1')) Decimal("2.2E+2") ! >>> ExtendedDefaultContext.quantize(Decimal('217'), Decimal('1e+2')) Decimal("2E+2") """ --- 2535,2567 ---- if the result is subnormal and inexact. ! >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.001')) Decimal("2.170") ! >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.01')) Decimal("2.17") ! >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.1')) Decimal("2.2") ! >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('1e+0')) Decimal("2") ! >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('1e+1')) Decimal("0E+1") ! >>> ExtendedContext.quantize(Decimal('-Inf'), Decimal('Infinity')) Decimal("-Infinity") ! >>> ExtendedContext.quantize(Decimal('2'), Decimal('Infinity')) Decimal("NaN") ! >>> ExtendedContext.quantize(Decimal('-0.1'), Decimal('1')) Decimal("-0") ! >>> ExtendedContext.quantize(Decimal('-0'), Decimal('1e+5')) Decimal("-0E+5") ! >>> ExtendedContext.quantize(Decimal('+35236450.6'), Decimal('1e-2')) Decimal("NaN") ! >>> ExtendedContext.quantize(Decimal('-35236450.6'), Decimal('1e-2')) Decimal("NaN") ! >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e-1')) Decimal("217.0") ! >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e-0')) Decimal("217") ! >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e+1')) Decimal("2.2E+2") ! >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e+2')) Decimal("2E+2") """ *************** *** 2577,2591 **** remainder cannot be calculated). ! >>> ExtendedDefaultContext.remainder(Decimal('2.1'), Decimal('3')) Decimal("2.1") ! >>> ExtendedDefaultContext.remainder(Decimal('10'), Decimal('3')) Decimal("1") ! >>> ExtendedDefaultContext.remainder(Decimal('-10'), Decimal('3')) Decimal("-1") ! >>> ExtendedDefaultContext.remainder(Decimal('10.2'), Decimal('1')) Decimal("0.2") ! >>> ExtendedDefaultContext.remainder(Decimal('10'), Decimal('0.3')) Decimal("0.1") ! >>> ExtendedDefaultContext.remainder(Decimal('3.6'), Decimal('1.3')) Decimal("1.0") """ --- 2580,2594 ---- remainder cannot be calculated). ! >>> ExtendedContext.remainder(Decimal('2.1'), Decimal('3')) Decimal("2.1") ! >>> ExtendedContext.remainder(Decimal('10'), Decimal('3')) Decimal("1") ! >>> ExtendedContext.remainder(Decimal('-10'), Decimal('3')) Decimal("-1") ! >>> ExtendedContext.remainder(Decimal('10.2'), Decimal('1')) Decimal("0.2") ! >>> ExtendedContext.remainder(Decimal('10'), Decimal('0.3')) Decimal("0.1") ! >>> ExtendedContext.remainder(Decimal('3.6'), Decimal('1.3')) Decimal("1.0") """ *************** *** 2602,2618 **** remainder cannot be calculated). ! >>> ExtendedDefaultContext.remainder_near(Decimal('2.1'), Decimal('3')) Decimal("-0.9") ! >>> ExtendedDefaultContext.remainder_near(Decimal('10'), Decimal('6')) Decimal("-2") ! >>> ExtendedDefaultContext.remainder_near(Decimal('10'), Decimal('3')) Decimal("1") ! >>> ExtendedDefaultContext.remainder_near(Decimal('-10'), Decimal('3')) Decimal("-1") ! >>> ExtendedDefaultContext.remainder_near(Decimal('10.2'), Decimal('1')) Decimal("0.2") ! >>> ExtendedDefaultContext.remainder_near(Decimal('10'), Decimal('0.3')) Decimal("0.1") ! >>> ExtendedDefaultContext.remainder_near(Decimal('3.6'), Decimal('1.3')) Decimal("-0.3") """ --- 2605,2621 ---- remainder cannot be calculated). ! >>> ExtendedContext.remainder_near(Decimal('2.1'), Decimal('3')) Decimal("-0.9") ! >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('6')) Decimal("-2") ! >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('3')) Decimal("1") ! >>> ExtendedContext.remainder_near(Decimal('-10'), Decimal('3')) Decimal("-1") ! >>> ExtendedContext.remainder_near(Decimal('10.2'), Decimal('1')) Decimal("0.2") ! >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('0.3')) Decimal("0.1") ! >>> ExtendedContext.remainder_near(Decimal('3.6'), Decimal('1.3')) Decimal("-0.3") """ *************** *** 2625,2635 **** either operand. ! >>> ExtendedDefaultContext.same_quantum(Decimal('2.17'), Decimal('0.001')) False ! >>> ExtendedDefaultContext.same_quantum(Decimal('2.17'), Decimal('0.01')) True ! >>> ExtendedDefaultContext.same_quantum(Decimal('2.17'), Decimal('1')) False ! >>> ExtendedDefaultContext.same_quantum(Decimal('Inf'), Decimal('-Inf')) True """ --- 2628,2638 ---- either operand. ! >>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('0.001')) False ! >>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('0.01')) True ! >>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('1')) False ! >>> ExtendedContext.same_quantum(Decimal('Inf'), Decimal('-Inf')) True """ *************** *** 2642,2664 **** algorithm. ! >>> ExtendedDefaultContext.sqrt(Decimal('0')) Decimal("0") ! >>> ExtendedDefaultContext.sqrt(Decimal('-0')) Decimal("-0") ! >>> ExtendedDefaultContext.sqrt(Decimal('0.39')) Decimal("0.624499800") ! >>> ExtendedDefaultContext.sqrt(Decimal('100')) Decimal("10") ! >>> ExtendedDefaultContext.sqrt(Decimal('1')) Decimal("1") ! >>> ExtendedDefaultContext.sqrt(Decimal('1.0')) Decimal("1.0") ! >>> ExtendedDefaultContext.sqrt(Decimal('1.00')) Decimal("1.0") ! >>> ExtendedDefaultContext.sqrt(Decimal('7')) Decimal("2.64575131") ! >>> ExtendedDefaultContext.sqrt(Decimal('10')) Decimal("3.16227766") ! >>> ExtendedDefaultContext.prec 9 """ --- 2645,2667 ---- algorithm. ! >>> ExtendedContext.sqrt(Decimal('0')) Decimal("0") ! >>> ExtendedContext.sqrt(Decimal('-0')) Decimal("-0") ! >>> ExtendedContext.sqrt(Decimal('0.39')) Decimal("0.624499800") ! >>> ExtendedContext.sqrt(Decimal('100')) Decimal("10") ! >>> ExtendedContext.sqrt(Decimal('1')) Decimal("1") ! >>> ExtendedContext.sqrt(Decimal('1.0')) Decimal("1.0") ! >>> ExtendedContext.sqrt(Decimal('1.00')) Decimal("1.0") ! >>> ExtendedContext.sqrt(Decimal('7')) Decimal("2.64575131") ! >>> ExtendedContext.sqrt(Decimal('10')) Decimal("3.16227766") ! >>> ExtendedContext.prec 9 """ *************** *** 2668,2676 **** """Return the sum of the two operands. ! >>> ExtendedDefaultContext.subtract(Decimal('1.3'), Decimal('1.07')) Decimal("0.23") ! >>> ExtendedDefaultContext.subtract(Decimal('1.3'), Decimal('1.30')) Decimal("0.00") ! >>> ExtendedDefaultContext.subtract(Decimal('1.3'), Decimal('2.07')) Decimal("-0.77") """ --- 2671,2679 ---- """Return the sum of the two operands. ! >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('1.07')) Decimal("0.23") ! >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('1.30')) Decimal("0.00") ! >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('2.07')) Decimal("-0.77") """ *************** *** 2700,2718 **** be set. The rounding mode is taken from the context. ! >>> ExtendedDefaultContext.to_integral(Decimal('2.1')) Decimal("2") ! >>> ExtendedDefaultContext.to_integral(Decimal('100')) Decimal("100") ! >>> ExtendedDefaultContext.to_integral(Decimal('100.0')) Decimal("100") ! >>> ExtendedDefaultContext.to_integral(Decimal('101.5')) Decimal("102") ! >>> ExtendedDefaultContext.to_integral(Decimal('-101.5')) Decimal("-102") ! >>> ExtendedDefaultContext.to_integral(Decimal('10E+5')) Decimal("1.0E+6") ! >>> ExtendedDefaultContext.to_integral(Decimal('7.89E+77')) Decimal("7.89E+77") ! >>> ExtendedDefaultContext.to_integral(Decimal('-Inf')) Decimal("-Infinity") """ --- 2703,2721 ---- be set. The rounding mode is taken from the context. ! >>> ExtendedContext.to_integral(Decimal('2.1')) Decimal("2") ! >>> ExtendedContext.to_integral(Decimal('100')) Decimal("100") ! >>> ExtendedContext.to_integral(Decimal('100.0')) Decimal("100") ! >>> ExtendedContext.to_integral(Decimal('101.5')) Decimal("102") ! >>> ExtendedContext.to_integral(Decimal('-101.5')) Decimal("-102") ! >>> ExtendedContext.to_integral(Decimal('10E+5')) Decimal("1.0E+6") ! >>> ExtendedContext.to_integral(Decimal('7.89E+77')) Decimal("7.89E+77") ! >>> ExtendedContext.to_integral(Decimal('-Inf')) Decimal("-Infinity") """ *************** *** 2975,2979 **** # of the spec. ! BasicDefaultContext = Context( prec=9, rounding=ROUND_HALF_UP, trap_enablers=_basic_traps, --- 2978,2982 ---- # of the spec. ! BasicContext = Context( prec=9, rounding=ROUND_HALF_UP, trap_enablers=_basic_traps, *************** *** 2982,2986 **** ) ! ExtendedDefaultContext = Context( prec=9, rounding=ROUND_HALF_EVEN, trap_enablers=dict.fromkeys(Signals, 0), --- 2985,2989 ---- ) ! ExtendedContext = Context( prec=9, rounding=ROUND_HALF_EVEN, trap_enablers=dict.fromkeys(Signals, 0), From haleythieleck at phat.co.nz Sun Jul 4 02:52:29 2004 From: haleythieleck at phat.co.nz (Israel Huddleston) Date: Sat Jul 3 10:53:24 2004 Subject: [Python-checkins] ch.ea.pest prices, no pre.scri.ption In-Reply-To: <20040330185343.081B3965@msn.com> Message-ID: Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/gif Size: 5978 bytes Desc: not available Url : http://mail.python.org/pipermail/python-checkins/attachments/20040703/bc858e0b/attachment-0001.gif From bcannon at users.sourceforge.net Sat Jul 3 15:59:00 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Jul 3 15:59:04 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.127, 1.831.4.128 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6118/Misc Modified Files: Tag: release23-maint NEWS Log Message: threading.Thread used to raise an exception about attempting to execute a NoneType if an exception in a thread was raised during interpreter shutdown. This led to a masking of the initial exception (not good). All fixed (good). Closes bug #754449 (using both patch #954922 and a backport of rev. 1.41 from HEAD). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.127 retrieving revision 1.831.4.128 diff -C2 -d -r1.831.4.127 -r1.831.4.128 *** NEWS 2 Jul 2004 08:40:28 -0000 1.831.4.127 --- NEWS 3 Jul 2004 19:58:58 -0000 1.831.4.128 *************** *** 41,44 **** --- 41,49 ---- ------- + - Bug #754449: threading.Thread will no longer mask exceptions raised during + interpreter shutdown with another exception caused by attempting to output + the initial exception. This fix also includes a backport of rev. 1.41 from + HEAD. + - Bug #982215: The Back and Next buttons in bdist_wininst installers are now disabled during file copy operations. From bcannon at users.sourceforge.net Sat Jul 3 15:59:00 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Jul 3 15:59:07 2004 Subject: [Python-checkins] python/dist/src/Lib threading.py,1.38,1.38.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6118/Lib Modified Files: Tag: release23-maint threading.py Log Message: threading.Thread used to raise an exception about attempting to execute a NoneType if an exception in a thread was raised during interpreter shutdown. This led to a masking of the initial exception (not good). All fixed (good). Closes bug #754449 (using both patch #954922 and a backport of rev. 1.41 from HEAD). Index: threading.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/threading.py,v retrieving revision 1.38 retrieving revision 1.38.6.1 diff -C2 -d -r1.38 -r1.38.6.1 *** threading.py 1 Jul 2003 20:01:55 -0000 1.38 --- threading.py 3 Jul 2004 19:58:57 -0000 1.38.6.1 *************** *** 194,198 **** def wait(self, timeout=None): - currentThread() # for side-effect assert self._is_owned(), "wait() of un-acquire()d lock" waiter = _allocate_lock() --- 194,197 ---- *************** *** 236,240 **** def notify(self, n=1): - currentThread() # for side-effect assert self._is_owned(), "notify() of un-acquire()d lock" __waiters = self.__waiters --- 235,238 ---- *************** *** 370,373 **** --- 368,376 ---- __initialized = False + # Need to store a reference to sys.exc_info for printing + # out exceptions when a thread tries to accept a global during interp. + # shutdown and thus raises an exception about trying to perform some + # operation on/with a NoneType + __exc_info = _sys.exc_info def __init__(self, group=None, target=None, name=None, *************** *** 384,387 **** --- 387,393 ---- self.__block = Condition(Lock()) self.__initialized = True + # sys.stderr is not stored in the class like + # sys.exc_info since it can be changed during execution + self.__stderr = _sys.stderr def _set_daemon(self): *************** *** 441,448 **** if __debug__: self._note("%s.__bootstrap(): unhandled exception", self) ! s = _StringIO() ! _print_exc(file=s) ! _sys.stderr.write("Exception in thread %s:\n%s\n" % ! (self.getName(), s.getvalue())) else: if __debug__: --- 447,478 ---- if __debug__: self._note("%s.__bootstrap(): unhandled exception", self) ! # If sys.stderr is no more (most likely from interpreter ! # shutdown) use self.__stderr. Otherwise still use sys (as in ! # _sys) in case sys.stderr was redefined. ! if _sys: ! _sys.stderr.write("Exception in thread %s:\n%s\n" % ! (self.getName(), _format_exc())) ! else: ! # Do the best job possible w/o a huge amt. of code to ! # approx. a traceback stack trace ! exc_type, exc_value, exc_tb = self.__exc_info() ! try: ! print>>self.__stderr, ( ! "Exception in thread " + self.getName() + ! " (most likely raised during interpreter shutdown):") ! print>>self.__stderr, ( ! "Traceback (most recent call last):") ! while exc_tb: ! print>>self.__stderr, ( ! ' File "%s", line %s, in %s' % ! (exc_tb.tb_frame.f_code.co_filename, ! exc_tb.tb_lineno, ! exc_tb.tb_frame.f_code.co_name)) ! exc_tb = exc_tb.tb_next ! print>>self.__stderr, ("%s: %s" % (exc_type, exc_value)) ! # Make sure that exc_tb gets deleted since it is a memory ! # hog; deleting everything else is just for thoroughness ! finally: ! del exc_type, exc_value, exc_tb else: if __debug__: From lilbooboo164 at aol.com Sat Jul 3 17:59:38 2004 From: lilbooboo164 at aol.com (lilbooboo164@aol.com) Date: Sat Jul 3 17:59:37 2004 Subject: [Python-checkins] =?iso-8859-1?q?=DFdo0=DFi4grjj40j09gjijgp=FCd?= =?iso-8859-1?q?=E9?= Message-ID: 9u049u89gh89fsdpokofkdpbm3?4i -------------- next part -------------- A non-text attachment was scrubbed... Name: id43342.zip Type: application/octet-stream Size: 29840 bytes Desc: not available Url : http://mail.python.org/pipermail/python-checkins/attachments/20040703/fd59e732/id43342.obj From akuchling at users.sourceforge.net Sat Jul 3 18:26:44 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 3 18:26:47 2004 Subject: [Python-checkins] python/nondist/peps pep-0289.txt,1.13,1.14 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30692 Modified Files: pep-0289.txt Log Message: Typo fixes Index: pep-0289.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0289.txt,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** pep-0289.txt 20 May 2004 22:57:01 -0000 1.13 --- pep-0289.txt 3 Jul 2004 22:26:41 -0000 1.14 *************** *** 34,38 **** sum([x*x for x in range(10)]) ! Memory is conserved by using an generator expession instead:: sum(x*x for x in range(10)) --- 34,38 ---- sum([x*x for x in range(10)]) ! Memory is conserved by using a generator expession instead:: sum(x*x for x in range(10)) *************** *** 163,167 **** 3. The loop variable (if it is a simple variable or a tuple of simple variables) is not exposed to the surrounding function. This ! facilates the implementation and makes typical use cases more reliable. In some future version of Python, list comprehensions will also hide the induction variable from the surrounding code --- 163,167 ---- 3. The loop variable (if it is a simple variable or a tuple of simple variables) is not exposed to the surrounding function. This ! facilitates the implementation and makes typical use cases more reliable. In some future version of Python, list comprehensions will also hide the induction variable from the surrounding code From kbk at users.sourceforge.net Sat Jul 3 21:25:59 2004 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Sat Jul 3 21:26:02 2004 Subject: [Python-checkins] python/dist/src/Lib/idlelib NEWS.txt, 1.35, 1.36 PyShell.py, 1.88, 1.89 ScriptBinding.py, 1.27, 1.28 run.py, 1.28, 1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22465 Modified Files: NEWS.txt PyShell.py ScriptBinding.py run.py Log Message: Redirect the warning stream to the shell during the ScriptBinding check of user code and format the warning similarly to an exception for both that check and for warnings raised in the subprocess. M NEWS.txt M Pyshell.py M ScriptBinding.py M run.py Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** NEWS.txt 6 Jun 2004 01:29:21 -0000 1.35 --- NEWS.txt 4 Jul 2004 01:25:56 -0000 1.36 *************** *** 4,7 **** --- 4,11 ---- *Release date: XX-XXX-2004* + - Redirect the warning stream to the shell during the ScriptBinding check of + user code and format the warning similarly to an exception for both that + check and for runtime warnings raised in the subprocess. + - CodeContext hint pane visibility state is now persistent across sessions. The pane no longer appears in the shell window. Added capability to limit Index: PyShell.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/PyShell.py,v retrieving revision 1.88 retrieving revision 1.89 diff -C2 -d -r1.88 -r1.89 *** PyShell.py 6 Jun 2004 01:29:21 -0000 1.88 --- PyShell.py 4 Jul 2004 01:25:56 -0000 1.89 *************** *** 45,49 **** SIGTERM = 15 ! # Change warnings module to write to sys.__stderr__ try: import warnings --- 45,54 ---- SIGTERM = 15 ! # Override warnings module to write to warning_stream. Initialize to send IDLE ! # internal warnings to the console. ScriptBinding.check_syntax() will ! # temporarily redirect the stream to the shell window to display warnings when ! # checking user's code. ! global warning_stream ! warning_stream = sys.__stderr__ try: import warnings *************** *** 52,58 **** else: def idle_showwarning(message, category, filename, lineno): ! file = sys.__stderr__ ! file.write(warnings.formatwarning(message, category, filename, lineno)) warnings.showwarning = idle_showwarning def extended_linecache_checkcache(orig_checkcache=linecache.checkcache): --- 57,76 ---- else: def idle_showwarning(message, category, filename, lineno): ! file = warning_stream ! try: ! file.write(warnings.formatwarning(message, category, filename, lineno)) ! except IOError: ! pass ## file (probably __stderr__) is invalid, warning dropped. warnings.showwarning = idle_showwarning + def idle_formatwarning(message, category, filename, lineno): + """Format warnings the IDLE way""" + s = "\nWarning (from warnings module):\n" + s += ' File \"%s\", line %s\n' % (filename, lineno) + line = linecache.getline(filename, lineno).strip() + if line: + s += " %s\n" % line + s += "%s: %s\n>>> " % (category.__name__, message) + return s + warnings.formatwarning = idle_formatwarning def extended_linecache_checkcache(orig_checkcache=linecache.checkcache): *************** *** 816,819 **** --- 834,844 ---- closing = False + def set_warning_stream(self, stream): + global warning_stream + warning_stream = stream + + def get_warning_stream(self): + return warning_stream + def toggle_debugger(self, event=None): if self.executing: Index: ScriptBinding.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/ScriptBinding.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** ScriptBinding.py 12 Feb 2004 17:35:09 -0000 1.27 --- ScriptBinding.py 4 Jul 2004 01:25:56 -0000 1.28 *************** *** 83,86 **** --- 83,89 ---- def checksyntax(self, filename): + self.shell = shell = self.flist.open_shell() + saved_stream = shell.get_warning_stream() + shell.set_warning_stream(shell.stderr) f = open(filename, 'r') source = f.read() *************** *** 93,110 **** text.tag_remove("ERROR", "1.0", "end") try: - # If successful, return the compiled code - return compile(source, filename, "exec") - except (SyntaxError, OverflowError), err: try: ! msg, (errorfilename, lineno, offset, line) = err ! if not errorfilename: ! err.args = msg, (filename, lineno, offset, line) ! err.filename = filename ! self.colorize_syntax_error(msg, lineno, offset) ! except: ! msg = "*** " + str(err) ! self.errorbox("Syntax error", ! "There's an error in your program:\n" + msg) ! return False def colorize_syntax_error(self, msg, lineno, offset): --- 96,116 ---- text.tag_remove("ERROR", "1.0", "end") try: try: ! # If successful, return the compiled code ! return compile(source, filename, "exec") ! except (SyntaxError, OverflowError), err: ! try: ! msg, (errorfilename, lineno, offset, line) = err ! if not errorfilename: ! err.args = msg, (filename, lineno, offset, line) ! err.filename = filename ! self.colorize_syntax_error(msg, lineno, offset) ! except: ! msg = "*** " + str(err) ! self.errorbox("Syntax error", ! "There's an error in your program:\n" + msg) ! return False ! finally: ! shell.set_warning_stream(saved_stream) def colorize_syntax_error(self, msg, lineno, offset): *************** *** 136,143 **** if not code: return ! flist = self.editwin.flist ! shell = flist.open_shell() ! if not shell: ! return # couldn't open the shell interp = shell.interp if PyShell.use_subprocess: --- 142,146 ---- if not code: return ! shell = self.shell interp = shell.interp if PyShell.use_subprocess: *************** *** 157,160 **** --- 160,166 ---- \n""" % (filename, dirname)) interp.prepend_syspath(filename) + # XXX KBK 03Jul04 When run w/o subprocess, runtime warnings still + # go to __stderr__. With subprocess, they go to the shell. + # Need to change streams in PyShell.ModifiedInterpreter. interp.runcode(code) Index: run.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/run.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** run.py 21 Jan 2004 18:54:30 -0000 1.28 --- run.py 4 Jul 2004 01:25:56 -0000 1.29 *************** *** 1,4 **** --- 1,5 ---- import sys import os + import linecache import time import socket *************** *** 18,21 **** --- 19,38 ---- LOCALHOST = '127.0.0.1' + try: + import warnings + except ImportError: + pass + else: + def idle_formatwarning_subproc(message, category, filename, lineno): + """Format warnings the IDLE way""" + s = "\nWarning (from warnings module):\n" + s += ' File \"%s\", line %s\n' % (filename, lineno) + line = linecache.getline(filename, lineno).strip() + if line: + s += " %s\n" % line + s += "%s: %s\n" % (category.__name__, message) + return s + warnings.formatwarning = idle_formatwarning_subproc + # Thread shared globals: Establish a queue between a subthread (which handles # the socket) and the main thread (which runs user code), plus global From akuchling at users.sourceforge.net Sat Jul 3 21:26:44 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 3 21:26:48 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.56, 1.57 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22881 Modified Files: whatsnew24.tex Log Message: Rewrite two sections Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** whatsnew24.tex 1 Jul 2004 11:52:15 -0000 1.56 --- whatsnew24.tex 4 Jul 2004 01:26:42 -0000 1.57 *************** *** 3,6 **** --- 3,10 ---- % $Id$ + % Don't write extensive text for new sections; I'll do that. + % Feel free to add commented-out reminders of things that need + % to be covered. --amk + \title{What's New in Python 2.4} \release{0.0} *************** *** 90,160 **** %====================================================================== ! \section{PEP 229: Generator Expressions} ! Now, simple generators can be coded succinctly as expressions using a syntax ! like list comprehensions but with parentheses instead of brackets. These ! expressions are designed for situations where the generator is used right ! away by an enclosing function. Generator expressions are more compact but ! less versatile than full generator definitions and they tend to be more memory ! friendly than equivalent list comprehensions. ! ! \begin{verbatim} ! g = (tgtexp for var1 in exp1 for var2 in exp2 if exp3) ! \end{verbatim} ! ! is equivalent to: \begin{verbatim} ! def __gen(exp): ! for var1 in exp: ! for var2 in exp2: ! if exp3: ! yield tgtexp ! g = __gen(iter(exp1)) ! del __gen \end{verbatim} ! The advantage over full generator definitions is in economy of ! expression. Their advantage over list comprehensions is in saving ! memory by creating data only when it is needed rather than forming ! a whole list is memory all at once. Applications using memory ! friendly generator expressions may scale-up to high volumes of data ! more readily than with list comprehensions. ! ! Generator expressions are best used in functions that consume their ! data all at once and would not benefit from having a full list instead ! of a generator as an input: \begin{verbatim} ! >>> sum(i*i for i in range(10)) ! 285 ! ! >>> sorted(set(i*i for i in xrange(-20, 20) if i%2==1)) # odd squares ! [1, 9, 25, 49, 81, 121, 169, 225, 289, 361] ! >>> from itertools import izip ! >>> xvec = [10, 20, 30] ! >>> yvec = [7, 5, 3] ! >>> sum(x*y for x,y in izip(xvec, yvec)) # dot product ! 260 ! >>> from math import pi, sin ! >>> sine_table = dict((x, sin(x*pi/180)) for x in xrange(0, 91)) ! >>> unique_words = set(word for line in page for word in line.split()) ! >>> valedictorian = max((student.gpa, student.name) for student in graduates) ! \end{verbatim} ! For more complex uses of generators, it is strongly recommended that ! the traditional full generator definitions be used instead. In a ! generator expression, the first for-loop expression is evaluated ! as soon as the expression is defined while the other expressions do ! not get evaluated until the generator is run. This nuance is never ! an issue when the generator is used immediately; however, if it is not ! used right away, a full generator definition would be much more clear ! about when the sub-expressions are evaluated and would be more obvious ! about the visibility and lifetime of the variables. \begin{seealso} --- 94,152 ---- %====================================================================== ! \section{PEP 289: Generator Expressions} ! The iterator feature introduced in Python 2.2 makes it easier to write ! programs that loop through large data sets without having the entire ! data set in memory at one time. Programmers can use iterators and the ! \module{itertools} module to write code in a fairly functional style. ! ! The fly in the ointment has been list comprehensions, because they ! produce a Python list object containing all of the items, unavoidably ! pulling them all into memory. When trying to write a program using the functional approach, it would be natural to write something like: \begin{verbatim} ! links = [link for link in get_all_links() if not link.followed] ! for link in links: ! ... \end{verbatim} ! instead of \begin{verbatim} ! for link in get_all_links(): ! if link.followed: ! continue ! ... ! \end{verbatim} ! The first form is more concise and perhaps more readable, but if ! you're dealing with a large number of link objects the second form ! would have to be used. ! Generator expressions work similarly to list comprehensions but don't ! materialize the entire list; instead they create a generator that will ! return elements one by one. The above example could be written as: ! \begin{verbatim} ! links = (link for link in get_all_links() if not link.followed) ! for link in links: ! ... ! \end{verbatim} ! Generator expressions always have to be written inside parentheses, as ! in the above example. The parentheses signalling a function call also ! count, so if you want to create a iterator that will be immediately ! passed to a function you could write: ! \begin{verbatim} ! print sum(obj.count for obj in list_all_objects()) ! \end{verbatim} ! There are some small differences from list comprehensions. Most ! notably, the loop variable (\var{obj} in the above example) is not ! accessible outside of the generator expression. List comprehensions ! leave the variable assigned to its last value; future versions of ! Python will change this, making list comprehensions match generator ! expressions in this respect. \begin{seealso} *************** *** 204,263 **** \section{PEP 327: Decimal Data Type} ! A new module, \module{decimal}, offers a \class{Decimal} data type for ! decimal floating point arithmetic. Compared to the built-in \class{float} ! type implemented with binary floating point, the new class is especially ! useful for financial applications and other uses which require exact ! decimal representation, control over precision, control over rounding ! to meet legal or regulatory requirements, tracking of significant ! decimal places, or for applications where the user expects the results ! to match hand calculations done the way they were taught in school. ! For example, calculating a 5% tax on a 70 cent phone charge gives ! different results in decimal floating point and binary floating point ! with the difference being significant when rounding to the nearest ! cent: \begin{verbatim} ! >>> from decimal import * ! >>> Decimal('0.70') * Decimal('1.05') ! Decimal("0.7350") ! >>> .70 * 1.05 ! 0.73499999999999999 \end{verbatim} ! Note that the \class{Decimal} result keeps a trailing zero, automatically ! inferring four place significance from two digit mulitiplicands. A key ! goal is to reproduce the mathematics we do by hand and avoid the tricky ! issues that arise when decimal numbers cannot be represented exactly in ! binary floating point. ! Exact representation enables the \class{Decimal} class to perform ! modulo calculations and equality tests that would fail in binary ! floating point: \begin{verbatim} ! >>> Decimal('1.00') % Decimal('.10') ! Decimal("0.00") ! >>> 1.00 % 0.10 ! 0.09999999999999995 ! ! >>> sum([Decimal('0.1')]*10) == Decimal('1.0') ! True ! >>> sum([0.1]*10) == 1.0 ! False \end{verbatim} ! The \module{decimal} module also allows arbitrarily large precisions to be ! set for calculation: \begin{verbatim} ! >>> getcontext().prec = 24 ! >>> Decimal(1) / Decimal(7) ! Decimal("0.142857142857142857142857") \end{verbatim} \begin{seealso} \seepep{327}{Decimal Data Type}{Written by Facundo Batista and implemented ! by Eric Price, Facundo Bastista, Raymond Hettinger, Aahz, and Tim Peters.} \end{seealso} --- 196,415 ---- \section{PEP 327: Decimal Data Type} ! Python has always supported floating-point (FP) numbers as a data ! type, based on the underlying C \ctype{double} type. However, while ! most programming languages provide a floating-point type, most people ! (even programmers) are unaware that computing with floating-point ! numbers entails certain unavoidable inaccuracies. The new decimal ! type provides a way to avoid these inaccuracies. ! \subsection{Why is Decimal needed?} + The limitations arise from the representation used for floating-point numbers. + FP numbers are made up of three components: + + \begin{itemize} + \item The sign, which is -1 or +1. + \item The mantissa, which is a single-digit binary number + followed by a fractional part. For example, \code{1.01} in base-2 notation + is \code{1 + 0/2 + 1/4}, or 1.25 in decimal notation. + \item The exponent, which tells where the decimal point is located in the number represented. + \end{itemize} + + For example, the number 1.25 has sign +1, mantissa 1.01 (in binary), + and exponent of 0 (the decimal point doesn't need to be shifted). The + number 5 has the same sign and mantissa, but the exponent is 2 + because the mantissa is multiplied by 4 (2 to the power of the exponent 2). + + Modern systems usually provide floating-point support that conforms to + a relevant standard called IEEE 754. C's \ctype{double} type is + usually implemented as a 64-bit IEEE 754 number, which uses 52 bits of + space for the mantissa. This means that numbers can only be specified + to 52 bits of precision. If you're trying to represent numbers whose + expansion repeats endlessly, the expansion is cut off after 52 bits. + Unfortunately, most software needs to produce output in base 10, and + base 10 often gives rise to such repeating decimals. For example, 1.1 + decimal is binary \code{1.0001100110011 ...}; .1 = 1/16 + 1/32 + 1/256 + plus an infinite number of additional terms. IEEE 754 has to chop off + that infinitely repeated decimal after 52 digits, so the + representation is slightly inaccurate. + + Sometimes you can see this inaccuracy when the number is printed: \begin{verbatim} ! >>> 1.1 ! 1.1000000000000001 \end{verbatim} ! The inaccuracy isn't always visible when you print the number because ! the FP-to-decimal-string conversion is provided by the C library, and ! most C libraries try to produce sensible output, but the inaccuracy is ! still there and subsequent operations can magnify the error. ! For many applications this doesn't matter. If I'm plotting points and ! displaying them on my monitor, the difference between 1.1 and ! 1.1000000000000001 is too small to be visible. Reports often limit ! output to a certain number of decimal places, and if you round the ! number to two or three or even eight decimal places, the error is ! never apparent. However, for applications where it does matter, ! it's a lot of work to implement your own custom arithmetic routines. ! ! \subsection{The \class{Decimal} type} ! ! A new module, \module{decimal}, was added to Python's standard library. ! It contains two classes, \class{Decimal} and \class{Context}. ! \class{Decimal} instances represent numbers, and ! \class{Context} instances are used to wrap up various settings such as the precision and default rounding mode. ! ! \class{Decimal} instances, like regular Python integers and FP numbers, are immutable; once they've been created, you can't change the value it represents. ! \class{Decimal} instances can be created from integers or strings: \begin{verbatim} ! >>> import decimal ! >>> decimal.Decimal(1972) ! Decimal("1972") ! >>> decimal.Decimal("1.1") ! Decimal("1.1") \end{verbatim} ! You can also provide tuples containing the sign, mantissa represented ! as a tuple of decimal digits, and exponent: \begin{verbatim} ! >>> decimal.Decimal((1, (1, 4, 7, 5), -2)) ! Decimal("-14.75") ! \end{verbatim} ! ! Cautionary note: the sign bit is a Boolean value, so 0 is positive and 1 is negative. ! ! Floating-point numbers posed a bit of a problem: should the FP number ! representing 1.1 turn into the decimal number for exactly 1.1, or for ! 1.1 plus whatever inaccuracies are introduced? The decision was to ! leave such a conversion out of the API. Instead, you should convert ! the floating-point number into a string using the desired precision and ! pass the string to the \class{Decimal} constructor: ! ! \begin{verbatim} ! >>> f = 1.1 ! >>> decimal.Decimal(str(f)) ! Decimal("1.1") ! >>> decimal.Decimal(repr(f)) ! Decimal("1.1000000000000001") ! \end{verbatim} ! ! Once you have \class{Decimal} instances, you can perform the usual ! mathematical operations on them. One limitation: exponentiation ! requires an integer exponent: ! ! \begin{verbatim} ! >>> a = decimal.Decimal('35.72') ! >>> b = decimal.Decimal('1.73') ! >>> a+b ! Decimal("37.45") ! >>> a-b ! Decimal("33.99") ! >>> a*b ! Decimal("61.7956") ! >>> a/b ! Decimal("20.6473988") ! >>> a ** 2 ! Decimal("1275.9184") ! >>> a ** b ! Decimal("NaN") ! \end{verbatim} ! ! You can combine \class{Decimal} instances with integers, but not with ! floating-point numbers: ! ! \begin{verbatim} ! >>> a + 4 ! Decimal("39.72") ! >>> a + 4.5 ! Traceback (most recent call last): ! ... ! TypeError: You can interact Decimal only with int, long or Decimal data types. ! >>> ! \end{verbatim} ! ! \class{Decimal} numbers can be used with the \module{math} and ! \module{cmath} modules, though you'll get back a regular ! floating-point number and not a \class{Decimal}. Instances also have a \method{sqrt()} method: ! ! \begin{verbatim} ! >>> import math, cmath ! >>> d = decimal.Decimal('123456789012.345') ! >>> math.sqrt(d) ! 351364.18288201344 ! >>> cmath.sqrt(-d) ! 351364.18288201344j ! >>> d.sqrt() ! Decimal(``351364.1828820134592177245001'') \end{verbatim} + + + \subsection{The \class{Context} type} + + Instances of the \class{Context} class encapsulate several settings for + decimal operations: + + \begin{itemize} + \item \member{prec} is the precision, the number of decimal places. + \item \member{rounding} specifies the rounding mode. The \module{decimal} + module has constants for the various possibilities: + \constant{ROUND_DOWN}, \constant{ROUND_CEILING}, \constant{ROUND_HALF_EVEN}, and various others. + \item \member{trap_enablers} is a dictionary specifying what happens on + encountering certain error conditions: either an exception is raised or + a value is returned. Some examples of error conditions are + division by zero, loss of precision, and overflow. + \end{itemize} + + There's a thread-local default context available by calling + \function{getcontext()}; you can change the properties of this context + to alter the default precision, rounding, or trap handling. + + \begin{verbatim} + >>> decimal.getcontext().prec + 28 + >>> decimal.Decimal(1) / decimal.Decimal(7) + Decimal(``0.1428571428571428571428571429'') + >>> decimal.getcontext().prec = 9 + >>> decimal.Decimal(1) / decimal.Decimal(7) + Decimal(``0.142857143'') + \end{verbatim} + + The default action for error conditions is to return a special value + such as infinity or not-a-number, but you can request that exceptions + be raised: + + \begin{verbatim} + >>> decimal.Decimal(1) / decimal.Decimal(0) + Decimal(``Infinity'') + >>> decimal.getcontext().trap_enablers[decimal.DivisionByZero] = True + >>> decimal.Decimal(1) / decimal.Decimal(0) + Traceback (most recent call last): + ... + decimal.DivisionByZero: x / 0 + >>> + \end{verbatim} + + The \class{Context} instance also has various methods for formatting + numbers such as \method{to_eng_string()} and \method{to_sci_string()}. + \begin{seealso} \seepep{327}{Decimal Data Type}{Written by Facundo Batista and implemented ! by Facundo Batista, Eric Price, Raymond Hettinger, Aahz, and Tim Peters.} ! ! \seeurl{http://research.microsoft.com/~hollasch/cgindex/coding/ieeefloat.html} ! {A more detailed overview of the IEEE-754 representation.} ! ! \seeurl{http://www.lahey.com/float.htm} ! {The article uses Fortran code to illustrate many of the problems ! that floating-point inaccuracy can cause.} ! ! \seeurl{http://www2.hursley.ibm.com/decimal/} ! {A description of a decimal-based representation. This representation ! is being proposed as a standard, and underlies the new Python decimal ! type. Much of this material was written by Mike Cowlishaw, designer of the ! REXX language.} ! \end{seealso} From akuchling at users.sourceforge.net Sat Jul 3 21:44:07 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Jul 3 21:44:09 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.57, 1.58 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25119 Modified Files: whatsnew24.tex Log Message: Write another section Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** whatsnew24.tex 4 Jul 2004 01:26:42 -0000 1.57 --- whatsnew24.tex 4 Jul 2004 01:44:04 -0000 1.58 *************** *** 91,95 **** \section{PEP 237: Unifying Long Integers and Integers} ! XXX write this. %====================================================================== --- 91,113 ---- \section{PEP 237: Unifying Long Integers and Integers} ! The lengthy transition process for the PEP, begun with Python 2.2, ! takes another step forward in Python 2.4. In 2.3, certain integer ! operations that would behave differently after int/long unification ! triggered \exception{FutureWarning} warnings and returned values ! limited to 32 or 64 bits. In 2.4, these expressions no longer produce ! a warning, but they now produce a different value that's a long ! integer. ! ! The problematic expressions are primarily left shifts and lengthy ! hexadecimal and octal constants. For example, \code{2 << 32} is one ! expression that results in a warning in 2.3, evaluating to 0 on 32-bit ! platforms. In Python 2.4, this expression now returns 8589934592. ! ! ! \begin{seealso} ! \seepep{237}{Unifying Long Integers and Integers}{Original PEP ! written by Moshe Zadka and Gvr. The changes for 2.4 were implemented by ! Kalle Svensson.} ! \end{seealso} %====================================================================== From rhettinger at users.sourceforge.net Sat Jul 3 21:55:56 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jul 3 21:56:00 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26705 Modified Files: decimal.py Log Message: Fix clear_flags(). Make a readable (not evalable) Context repr. Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** decimal.py 3 Jul 2004 13:48:56 -0000 1.5 --- decimal.py 4 Jul 2004 01:55:39 -0000 1.6 *************** *** 2155,2162 **** del self.self def clear_flags(self): """Reset all flags to zero""" for flag in self.flags: ! self.flag = 0 def copy(self): --- 2155,2170 ---- del self.self + def __repr__(self): + """Show the current context in readable form, not in a form for eval().""" + s = [] + s.append('Context(prec=%(prec)d, rounding=%(rounding)s, Emin=%(Emin)d, Emax=%(Emax)d' % vars(self)) + s.append('setflags=%r' % [f.__name__ for f, v in self.flags.items() if v]) + s.append('settraps=%r' % [t.__name__ for t, v in self.trap_enablers.items() if v]) + return ', '.join(s) + ')' + def clear_flags(self): """Reset all flags to zero""" for flag in self.flags: ! self.flags[flag] = 0 def copy(self): From mondragon at users.sourceforge.net Sun Jul 4 00:47:43 2004 From: mondragon at users.sourceforge.net (mondragon@users.sourceforge.net) Date: Sun Jul 4 00:47:49 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libpdb.tex,1.39,1.40 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16281/lib Modified Files: libpdb.tex Log Message: Textual change to make the doc reflect reality Index: libpdb.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpdb.tex,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** libpdb.tex 24 Mar 2004 21:57:08 -0000 1.39 --- libpdb.tex 4 Jul 2004 04:47:40 -0000 1.40 *************** *** 394,398 **** \item[\code{'c_call'}] A C function is about to be called. This may be an extension function ! or a builtin. \var{arg} is the C function name. \item[\code{'c_return'}] --- 394,398 ---- \item[\code{'c_call'}] A C function is about to be called. This may be an extension function ! or a builtin. \var{arg} is the C function object. \item[\code{'c_return'}] From rhettinger at users.sourceforge.net Sun Jul 4 02:27:07 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Jul 4 02:27:11 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal libdecimal.tex, NONE, 1.1 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27178 Added Files: libdecimal.tex Log Message: Module documentation. Part I --- NEW FILE: libdecimal.tex --- \section{\module{decimal} --- Decimal floating point arithmetic} \declaremodule{standard}{decimal} \modulesynopsis{Implementation of the General Decimal Arithmetic Specification.} \moduleauthor{Eric Price}{eprice at tjhsst.edu} \moduleauthor{Facundo Batista}{facundo at taniquetil.com.ar} \moduleauthor{Raymond Hettinger}{python at rcn.com} \moduleauthor{Aahz}{aahz at pobox.com} \moduleauthor{Tim Peters}{guido@python.org} \sectionauthor{Raymond D. Hettinger}{python at rcn.com} Eric Price # and Facundo Batista # and Raymond Hettinger # and Aahz # and Tim Peters \versionadded{2.4} The decimal \module{module} provides support for decimal floating point arithmetic. It offers several advantages over the \class{float()} data type. Decimal numbers can be represented exactly. In contrast, numbers like \constant{1.1} do not have an exact reprentations in binary floating point. End users typically wound not expect \constant{1.1} to display as \constant{1.1000000000000001} as it does with binary floating point. The exactness carries over to arithmetic. In decimal floating point, \code{0.1 + 0.1 + 0.1 - 0.3} is exactly equal to zero. In binary floating point, result is \constant{5.5511151231257827e-017}. While near to zero, the differences prevent reliable equality testing and differences can accumulate. For this reason, decimal would be preferred in accounting applications which have strict equality invariants. The decimal module incorporates notion signficant places so that \code{1.30 + 1.20} is \constant{2.50}. The trailing zero is kept to indicate significance. This is a customary presentation for monetary applications. For multiplication, a ``schoolbook'' approach uses all the figures in the multiplicands. For instance, \code{1.3 * 1.2} gives \constant{1.56} while \code{1.30 * 1.20} gives \constant{1.5600}. * Unlike hardware based binary floating point, the decimal module has a user settable precision (defaulting to 28 places) which can as large as needed for a given problem: \begin{verbatim} >>> Decimal(1) / Decimal(7) Decimal("0.142857") >>> getcontext().prec = 28 >>> Decimal(1) / Decimal(7) Decimal("0.1428571428571428571428571429") \end{verbatim} * Both binary and decimal floating point are implemented in terms of published standards. The builtin float type exposes only a modest portion of its capabilities. In contrast, the decimal module exposes all required parts of the standard. When needed, the programmer has full control over rounding and handling signals from the underlying implementation. The module design is centered around three concepts: the decimal number, the context for arithmetic, and signals. A decimal number is immutable. It has a sign, coefficient digits, and an exponent. To preserve significance, the coefficient digits do not truncate trailings zeros. Decimals also include special values such as \constant{Infinity} (the result of \code{1 / 0}), \constant{-Infinity}, (the result of \code{-1 / 0}), and \constant{NaN} (the result of \code{0 / 0}). The context for arithmetic is an environment specifying precision, rounding rules, limits on exponents, flags the indicate the results of operations, and trap enablers which determine whether signals are to be treated as exceptions. Rounding options include \constant{ROUND_CEILING}, \constant{ROUND_DOWN}, \constant{ROUND_FLOOR}, \constant{ROUND_HALF_DOWN}, \constant{ROUND_HALF_EVEN}, \constant{ROUND_HALF_UP}, and \constant{ROUND_UP}. Signals are types of information that arise during the course of a computation. Depending on the needs of the application, some signals may be ignored, considered as informational, or treated as exceptions. The signals in the decimal module are: \constant{Clamped}, \constant{InvalidOperation}, \constant{ConversionSyntax}, \constant{DivisionByZero}, \constant{DivisionImpossible}, \constant{DivisionUndefined}, \constant{Inexact}, \constant{InvalidContext}, \constant{Rounded}, \constant{Subnormal}, \constant{Overflow}, \constant{Underflow}. For each there is a flag and a trap enabler. When a signal is encountered, its flag incremented from zero and, then, if the trap enabler is set to one, then the signal will raise an exception. \begin{seealso} \seetext{IBM's General Decimal Arithmetic Specification, \citetitle[http://www2.hursley.ibm.com/decimal/decarith.html] {The General Decimal Arithmetic Specification}.} \seetext{IEEE standard 854-1987, \citetitle[http://www.cs.berkeley.edu/~ejr/projects/754/private/drafts/854-1987/dir.html] {Unofficial IEEE 854 Text}.} \end{seealso} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Quick-start Tutorial \label{decimal-tutorial}} \begin{verbatim} >>> getcontext() Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, setflags=[], settraps=[]) >>> Decimal(5) / Decimal(0) Decimal("Infinity") >>> getcontext() Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, setflags=['DivisionByZero'], settraps=[]) \end{verbatim} The division by zero, set a flag indicating that the signal occurred. Since no trap was set, the computation continued without raising an exception. \begin{verbatim} >>> getcontext().clear_flags() >>> getcontext() >>> getcontext().trap_enablers[DivisionByZero] = 1 >>> Decimal(5) / Decimal(0) Traceback (most recent call last): File "", line 1, in -toplevel- Decimal(5) / Decimal(0) DivisionByZero: x / 0 \end{verbatim} This time, with the DivisionByZero trap enabled, the computation raises an exception. The trap enablers and flags provide the programmer with fine control over what is considered to be an exception, what is information, and what can be ignored. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Decimal objects \label{decimal-decimal}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Context objects \label{decimal-decimal}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Signals \label{decimal-signals}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Working with threads \label{decimal-threads}} From t-meyer at ihug.co.nz Sun Jul 4 02:35:42 2004 From: t-meyer at ihug.co.nz (Tony Meyer) Date: Sun Jul 4 02:35:52 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal libdecimal.tex, NONE, 1.1 In-Reply-To: <1ED4ECF91CDED24C8D012BCF2B034F1306FA0895@its-xchg4.massey.ac.nz> Message-ID: <1ED4ECF91CDED24C8D012BCF2B034F130467807B@its-xchg4.massey.ac.nz> [...] > \moduleauthor{Tim Peters}{guido@python.org} [...] Is this correct? (I guess it could be, but it does look odd). =Tony Meyer From rhettinger at users.sourceforge.net Sun Jul 4 02:52:05 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Jul 4 02:52:09 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal libdecimal.tex, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30142 Modified Files: libdecimal.tex Log Message: Fix nits. Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/libdecimal.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** libdecimal.tex 4 Jul 2004 06:27:04 -0000 1.1 --- libdecimal.tex 4 Jul 2004 06:52:03 -0000 1.2 *************** *** 10,14 **** \moduleauthor{Raymond Hettinger}{python at rcn.com} \moduleauthor{Aahz}{aahz at pobox.com} ! \moduleauthor{Tim Peters}{guido@python.org} \sectionauthor{Raymond D. Hettinger}{python at rcn.com} --- 10,14 ---- \moduleauthor{Raymond Hettinger}{python at rcn.com} \moduleauthor{Aahz}{aahz at pobox.com} ! \moduleauthor{Tim Peters}{tim.one at comcast.net} \sectionauthor{Raymond D. Hettinger}{python at rcn.com} *************** *** 24,35 **** The decimal \module{module} provides support for decimal floating point ! arithmetic. It offers several advantages over the \class{float()} data type. ! Decimal numbers can be represented exactly. In contrast, numbers like ! \constant{1.1} do not have an exact reprentations in binary floating point. End users typically wound not expect \constant{1.1} to display as \constant{1.1000000000000001} as it does with binary floating point. ! The exactness carries over to arithmetic. In decimal floating point, \code{0.1 + 0.1 + 0.1 - 0.3} is exactly equal to zero. In binary floating point, result is \constant{5.5511151231257827e-017}. While near to zero, the --- 24,37 ---- The decimal \module{module} provides support for decimal floating point ! arithmetic. It offers several advantages over the \class{float()} data type: ! \begin{itemize} ! ! \item Decimal numbers can be represented exactly. In contrast, numbers like ! \constant{1.1} do not have an exact representations in binary floating point. End users typically wound not expect \constant{1.1} to display as \constant{1.1000000000000001} as it does with binary floating point. ! \item The exactness carries over to arithmetic. In decimal floating point, \code{0.1 + 0.1 + 0.1 - 0.3} is exactly equal to zero. In binary floating point, result is \constant{5.5511151231257827e-017}. While near to zero, the *************** *** 38,50 **** have strict equality invariants. ! The decimal module incorporates notion signficant places so that \code{1.30 + 1.20} is \constant{2.50}. The trailing zero is kept to indicate significance. This is a customary presentation for monetary applications. For ! multiplication, a ``schoolbook'' approach uses all the figures in the multiplicands. For instance, \code{1.3 * 1.2} gives \constant{1.56} while \code{1.30 * 1.20} gives \constant{1.5600}. ! * Unlike hardware based binary floating point, the decimal module has a user ! settable precision (defaulting to 28 places) which can as large as needed for a given problem: --- 40,52 ---- have strict equality invariants. ! \item The decimal module incorporates notion of significant places so that \code{1.30 + 1.20} is \constant{2.50}. The trailing zero is kept to indicate significance. This is a customary presentation for monetary applications. For ! multiplication, the ``schoolbook'' approach uses all the figures in the multiplicands. For instance, \code{1.3 * 1.2} gives \constant{1.56} while \code{1.30 * 1.20} gives \constant{1.5600}. ! \item Unlike hardware based binary floating point, the decimal module has a user ! settable precision (defaulting to 28 places) which can be as large as needed for a given problem: *************** *** 57,65 **** \end{verbatim} ! * Both binary and decimal floating point are implemented in terms of published ! standards. The builtin float type exposes only a modest portion of its ! capabilities. In contrast, the decimal module exposes all required parts of ! the standard. When needed, the programmer has full control over rounding and ! handling signals from the underlying implementation. The module design is centered around three concepts: the decimal number, the --- 59,69 ---- \end{verbatim} ! \item Both binary and decimal floating point are implemented in terms of published ! standards. While the built-in float type exposes only a modest portion of its ! capabilities, the decimal module exposes all required parts of the standard. ! When needed, the programmer has full control over rounding and signal handling. ! ! \end{itemize} ! The module design is centered around three concepts: the decimal number, the *************** *** 68,78 **** A decimal number is immutable. It has a sign, coefficient digits, and an exponent. To preserve significance, the coefficient digits do not truncate ! trailings zeros. Decimals also include special values such as \constant{Infinity} (the result of \code{1 / 0}), \constant{-Infinity}, (the result of \code{-1 / 0}), and \constant{NaN} (the result of ! \code{0 / 0}). The context for arithmetic is an environment specifying precision, rounding ! rules, limits on exponents, flags the indicate the results of operations, and trap enablers which determine whether signals are to be treated as exceptions. Rounding options include \constant{ROUND_CEILING}, --- 72,83 ---- A decimal number is immutable. It has a sign, coefficient digits, and an exponent. To preserve significance, the coefficient digits do not truncate ! trailing zeroes. Decimals also include special values such as \constant{Infinity} (the result of \code{1 / 0}), \constant{-Infinity}, (the result of \code{-1 / 0}), and \constant{NaN} (the result of ! \code{0 / 0}). The standard also differentiates \constant{-0} from ! \constant{+0}. The context for arithmetic is an environment specifying precision, rounding ! rules, limits on exponents, flags that indicate the results of operations, and trap enablers which determine whether signals are to be treated as exceptions. Rounding options include \constant{ROUND_CEILING}, *************** *** 87,95 **** \constant{DivisionImpossible}, \constant{DivisionUndefined}, \constant{Inexact}, \constant{InvalidContext}, \constant{Rounded}, ! \constant{Subnormal}, \constant{Overflow}, \constant{Underflow}. ! For each there is a flag and a trap enabler. When a signal is encountered, ! its flag incremented from zero and, then, if the trap enabler is set to ! one, then the signal will raise an exception. --- 92,100 ---- \constant{DivisionImpossible}, \constant{DivisionUndefined}, \constant{Inexact}, \constant{InvalidContext}, \constant{Rounded}, ! \constant{Subnormal}, \constant{Overflow}, and \constant{Underflow}. ! For each signal there is a flag and a trap enabler. When a signal is ! encountered, its flag incremented from zero and, then, if the trap enabler ! is set to one, an exception is raised. From rhettinger at users.sourceforge.net Sun Jul 4 03:42:45 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Jul 4 03:42:50 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal libdecimal.tex, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4871 Modified Files: libdecimal.tex Log Message: Add the threading section Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/libdecimal.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** libdecimal.tex 4 Jul 2004 06:52:03 -0000 1.2 --- libdecimal.tex 4 Jul 2004 07:42:41 -0000 1.3 *************** *** 157,158 **** --- 157,198 ---- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Working with threads \label{decimal-threads}} + + The \function{getcontext()} function accesses a different \class{Context} + object for each thread. Having separate contexts means that threads may make + changes (such as \code{getcontext.prec=10}) without interfering with other + threads and without needing mutexes. + + Likewise, the \function{setcontext()} function automatically assigns its target + to the current thread. + + If \function{setcontext()} has not been called before \function{getcontext()}, + then \function{getcontext()} will automatically create a new context for use + in the current thread. + + The new context is copied from a prototype context called \var{DefaultContext}. + To control the defaults so that each thread will use the same values + throughout the application, directly modify the \var{DefaultContext} object. + This should be done \emph{before} any threads are started so that there won't + be a race condition with threads calling \function{getcontext()}. For example: + + \begin{verbatim} + # Set application wide defaults for all threads about to be launched + DefaultContext.prec=12 + DefaultContext.rounding=ROUND_DOWN + DefaultContext.trap_enablers=dict.fromkeys(Signals, 0) + setcontext(DefaultContext) + + # Now start all of the threads + t1.start() + t2.start() + t3.start() + . . . + \end{verbatim} + + + + + + + + From rhettinger at users.sourceforge.net Sun Jul 4 04:55:47 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Jul 4 04:55:53 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal libdecimal.tex, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14446 Modified Files: libdecimal.tex Log Message: Add the signals section Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/libdecimal.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** libdecimal.tex 4 Jul 2004 07:42:41 -0000 1.3 --- libdecimal.tex 4 Jul 2004 08:55:42 -0000 1.4 *************** *** 155,158 **** --- 155,296 ---- \subsection{Signals \label{decimal-signals}} + Signals represent conditions that arise during computation. + Each corresponds to one context flag and one context trap enabler. + + The context flag is incremented whenever the condition is encountered. + After the computation, flags may be checked for informational + purposed (for instance, to determine whether a computation was exact). + After checking the flags, be sure to clear all flags before starting + the next computation. + + If the context's trap enable is set for the signal, then the condition + causes a Python exception to be raised. For example, if the + \class{DivisionByZero} trap is set, the a \exception{DivisionByZero} + exception is raised upon encountering the condition. + + + + \begin{classdesc*}{Clamped} + Altered an exponent to fit representation constraints. + + Typically, clamping occurs when an exponent falls outside the context's + \member{Emin} and \member{Emax} limits. If possible, the exponent is + reduced to fit by adding zeroes to the coefficient. + \end{classdesc*} + + + \begin{classdesc*}{ConversionSyntax} + Trying to convert a mal-formed string such as: \code{Decimal('jump')}. + + Decimal converts only strings conforming to the numeric string + syntax. If this signal is not trapped, returns \constant{NaN}. + \end{classdesc*} + + + \begin{classdesc*}{DecimalException} + Base class for other signals. + \end{classdesc*} + + + \begin{classdesc*}{DivisionByZero} + Signals the division of a non-infinite number by zero. + + Can occur with division, modulo division, or when raising a number to + a negative power. If this signal is not trapped, return + \constant{Infinity} or \constant{-Infinity} with sign determined by + the inputs to the calculation. + \end{classdesc*} + + + \begin{classdesc*}{DivisionImpossible} + Error performing a division operation. Caused when an intermediate result + has more digits that the allowed by the current precision. If not trapped, + returns \constant{NaN}. + \end{classdesc*} + + + \begin{classdesc*}{DivisionUndefined} + This is a subclass of \class{DivisionByZero}. + + It occurs only in the context of division operations. + \end{classdesc*} + + + \begin{classdesc*}{Inexact} + Indicates that rounding occurred and the result is not exact. + + Signals whenever non-zero digits were discarded during rounding. + The rounded result is returned. The signal flag or trap is used + to detect when results are inexact. + \end{classdesc*} + + + \begin{classdesc*}{InvalidContext} + This is a subclass of \class{InvalidOperation}. + + Indicates an error within the Context object such as an unknown + rounding operation. If not trapped, returns \constant{NaN}. + \end{classdesc*} + + + \begin{classdesc*}{InvalidOperation} + An invalid operation was performed. + + Indicates that an operation was requested that does not make sense. + If not trapped, returns \constant{NaN}. Possible causes include: + + \begin{verbatim} + Infinity - Infinity + 0 * Infinity + Infinity / Infinity + x % 0 + Infinity % x + x._rescale( non-integer ) + sqrt(-x) and x > 0 + 0 ** 0 + x ** (non-integer) + x ** Infinity + \end{verbatim} + \end{classdesc*} + + + \begin{classdesc*}{Overflow} + Numerical overflow. + + Indicates the exponent is larger than \member{Emax} after rounding has + occurred. If not trapped, the result depends on the rounding mode, either + pulling inward to the largest representable finite number or rounding + outward to \constant{Infinity}. In either case, \class{Inexact} and + \class{Rounded} are also signaled. + \end{classdesc*} + + + \begin{classdesc*}{Rounded} + Rounding occurred though possibly not information was lost. + + Signaled whenever rounding discards digits; even if those digits are + zero (such as rounding \constant{5.00} to \constant{5.0}). If not + trapped, returns the result unchanged. This signal is used to detect + loss of significant digits. + \end{classdesc*} + + + \begin{classdesc*}{Subnormal} + Exponent was lower than \member{Emin} prior to rounding. + + Occurs when an operation result is subnormal (the exponent is too small). + If not trapped, returns the result unchanged. + \end{classdesc*} + + + \begin{classdesc*}{Underflow} + Numerical underflow with result rounded to zero. + + Occurs when a subnormal result is pushed to zero by rounding. + \class{Inexact} and \class{Subnormal} are also signaled. + \end{classdesc*} + + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Working with threads \label{decimal-threads}} From rhettinger at users.sourceforge.net Sun Jul 4 06:52:19 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Jul 4 06:52:23 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal libdecimal.tex, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29793 Modified Files: libdecimal.tex Log Message: Add the tutorial section Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/libdecimal.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** libdecimal.tex 4 Jul 2004 08:55:42 -0000 1.4 --- libdecimal.tex 4 Jul 2004 10:52:14 -0000 1.5 *************** *** 34,38 **** \item The exactness carries over to arithmetic. In decimal floating point, ! \code{0.1 + 0.1 + 0.1 - 0.3} is exactly equal to zero. In binary floating point, result is \constant{5.5511151231257827e-017}. While near to zero, the differences prevent reliable equality testing and differences can accumulate. --- 34,38 ---- \item The exactness carries over to arithmetic. In decimal floating point, ! \samp{0.1 + 0.1 + 0.1 - 0.3} is exactly equal to zero. In binary floating point, result is \constant{5.5511151231257827e-017}. While near to zero, the differences prevent reliable equality testing and differences can accumulate. *************** *** 41,49 **** \item The decimal module incorporates notion of significant places so that ! \code{1.30 + 1.20} is \constant{2.50}. The trailing zero is kept to indicate significance. This is a customary presentation for monetary applications. For multiplication, the ``schoolbook'' approach uses all the figures in the ! multiplicands. For instance, \code{1.3 * 1.2} gives \constant{1.56} while ! \code{1.30 * 1.20} gives \constant{1.5600}. \item Unlike hardware based binary floating point, the decimal module has a user --- 41,49 ---- \item The decimal module incorporates notion of significant places so that ! \samp{1.30 + 1.20} is \constant{2.50}. The trailing zero is kept to indicate significance. This is a customary presentation for monetary applications. For multiplication, the ``schoolbook'' approach uses all the figures in the ! multiplicands. For instance, \samp{1.3 * 1.2} gives \constant{1.56} while ! \samp{1.30 * 1.20} gives \constant{1.5600}. \item Unlike hardware based binary floating point, the decimal module has a user *************** *** 73,79 **** exponent. To preserve significance, the coefficient digits do not truncate trailing zeroes. Decimals also include special values such as ! \constant{Infinity} (the result of \code{1 / 0}), \constant{-Infinity}, ! (the result of \code{-1 / 0}), and \constant{NaN} (the result of ! \code{0 / 0}). The standard also differentiates \constant{-0} from \constant{+0}. --- 73,79 ---- exponent. To preserve significance, the coefficient digits do not truncate trailing zeroes. Decimals also include special values such as ! \constant{Infinity} (the result of \samp{1 / 0}), \constant{-Infinity}, ! (the result of \samp{-1 / 0}), and \constant{NaN} (the result of ! \samp{0 / 0}). The standard also differentiates \constant{-0} from \constant{+0}. *************** *** 114,147 **** \subsection{Quick-start Tutorial \label{decimal-tutorial}} \begin{verbatim} >>> getcontext() Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, setflags=[], settraps=[]) ! >>> Decimal(5) / Decimal(0) Decimal("Infinity") ! >>> getcontext() ! Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, ! setflags=['DivisionByZero'], settraps=[]) \end{verbatim} ! The division by zero, set a flag indicating that the signal occurred. Since ! no trap was set, the computation continued without raising an exception. \begin{verbatim} >>> getcontext().clear_flags() >>> getcontext() >>> getcontext().trap_enablers[DivisionByZero] = 1 ! >>> Decimal(5) / Decimal(0) Traceback (most recent call last): ! File "", line 1, in -toplevel- ! Decimal(5) / Decimal(0) DivisionByZero: x / 0 \end{verbatim} ! This time, with the DivisionByZero trap enabled, the computation raises an ! exception. The trap enablers and flags provide the programmer with fine ! control over what is considered to be an exception, what is information, ! and what can be ignored. --- 114,293 ---- \subsection{Quick-start Tutorial \label{decimal-tutorial}} + The normal start to using decimals is to import the module, and then use + \function{getcontext()} to view the context and, if necessary, set the context + precision, rounding, or trap enablers: + \begin{verbatim} + >>> from decimal import * >>> getcontext() Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, setflags=[], settraps=[]) ! ! >>> getcontext().prec = 7 ! \end{verbatim} ! ! Decimal instances can be constructed from integers or strings. To create a ! Decimal from a \class{float}, first convert it to a string. This serves as an ! explicit reminder of the details of the conversion (including representation ! error). Malformed strings signal \constant{ConversionSyntax} and return a ! special kind of Decimal called a \constant{NaN} which stands for ``Not a ! number''. Positive and negative \constant{Infinity} is yet another special ! kind of Decimal. ! ! \begin{verbatim} ! >>> Decimal(10) ! Decimal("10") ! >>> Decimal('3.14') ! Decimal("3.14") ! >>> Decimal(str(2.0 ** 0.5)) ! Decimal("1.41421356237") ! >>> Decimal('Mickey Mouse') ! Decimal("NaN") ! >>> Decimal('-Infinity') ! Decimal("-Infinity") ! \end{verbatim} ! ! Creating decimals is unaffected by context precision. Their level of ! significance is completely determined by the number of digits input. It is ! the arithmetic operations that are governed by the context. ! ! \begin{verbatim} ! >>> getcontext().prec = 6 ! >>> Decimal('3.0000') ! Decimal("3.0000") ! >>> Decimal('3.0') ! Decimal("3.0") ! >>> Decimal('3.1415926535') ! Decimal("3.1415926535") ! >>> Decimal('3.1415926535') + Decimal('2.7182818285') ! Decimal("5.85987") ! >>> getcontext().rounding = ROUND_UP ! >>> Decimal('3.1415926535') + Decimal('2.7182818285') ! Decimal("5.85988") ! \end{verbatim} ! ! Decimals interact well with much of the rest of python. Here is a small ! flying circus of work with decimal floating point: ! ! \begin{verbatim} ! >>> data = map(Decimal, '1.34 1.87 3.45 2.35 1.00 0.03 9.25'.split()) ! >>> max(data) ! Decimal("9.25") ! >>> min(data) ! Decimal("0.03") ! >>> sorted(data) ! [Decimal("0.03"), Decimal("1.00"), Decimal("1.34"), Decimal("1.87"), ! Decimal("2.35"), Decimal("3.45"), Decimal("9.25")] ! >>> sum(data) ! Decimal("19.29") ! >>> a,b,c = data[:3] ! >>> str(a) ! '1.34' ! >>> float(a) ! 1.3400000000000001 ! >>> round(a, 1) ! 1.3 ! >>> int(a) ! 1 ! >>> a * 5 ! Decimal("6.70") ! >>> a * b ! Decimal("2.5058") ! >>> c % a ! Decimal("0.77") ! \end{verbatim} ! ! The \function{getcontext()} function accesses the current context. This one ! context is sufficient for many applications; however, for more advanced work, ! multiple contexts can be created using the Context() constructor. To make a ! new context active, use the \function{setcontext()} function. ! ! In accordance with the standard, the \module{Decimal} module provides two ! ready to use standard contexts, \constant{BasicContext} and ! \constant{ExtendedContext}. The former is especially useful for debugging ! because many of the traps are enabled: ! ! \begin{verbatim} ! >>> myothercontext = Context(prec=60, rounding=ROUND_HALF_DOWN) ! >>> myothercontext ! Context(prec=60, rounding=ROUND_HALF_DOWN, Emin=-999999999, Emax=999999999, ! setflags=[], settraps=[]) ! >>> ExtendedContext ! Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, ! setflags=[], settraps=[]) ! >>> setcontext(myothercontext) ! >>> Decimal(1) / Decimal(7) ! Decimal("0.142857142857142857142857142857142857142857142857142857142857") ! >>> setcontext(ExtendedContext) ! >>> Decimal(1) / Decimal(7) ! Decimal("0.142857143") ! >>> Decimal(42) / Decimal(0) Decimal("Infinity") ! >>> setcontext(BasicContext) ! >>> Decimal(42) / Decimal(0) ! Traceback (most recent call last): ! File "", line 1, in -toplevel- ! Decimal(42) / Decimal(0) ! DivisionByZero: x / 0 \end{verbatim} ! Besides using contexts to control precision, rounding, and trapping signals, ! they can be used to monitor flags which give information collected during ! computation. The flags remain set until explicitly cleared, so it is best to ! clear the flags before each set of monitored computations by using the ! \method{clear_flags()} method. \begin{verbatim} + >>> setcontext(ExtendedContext) >>> getcontext().clear_flags() + >>> Decimal(355) / Decimal(113) + Decimal("3.14159292") >>> getcontext() + Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, + setflags=['Inexact', 'Rounded'], settraps=[]) + \end{verbatim} + + The \var{setflags} entry shows that the rational approximation to + \constant{Pi} was rounded (digits beyond the context precision were thrown + away) and that the result is inexact (some of the discarded digits were + non-zero). + + Individual traps are set using the dictionary in the \member{trap_enablers} + field of a context: + + \begin{verbatim} + >>> Decimal(1) / Decimal(0) + Decimal("Infinity") >>> getcontext().trap_enablers[DivisionByZero] = 1 ! >>> Decimal(1) / Decimal(0) Traceback (most recent call last): ! File "", line 1, in -toplevel- ! Decimal(1) / Decimal(0) DivisionByZero: x / 0 \end{verbatim} ! To turn all the traps on or off all at once, use a loop. Also, the ! \method{dict.update()} method is useful for changing a few particular values. ! ! \begin{verbatim} ! >>> getcontext.clear_flags() ! >>> for sig in getcontext().trap_enablers: ! ... getcontext().trap_enablers[sig] = 1 ! ! >>> getcontext().trap_enablers.update({Rounded:0, Inexact:0, Subnormal:0}) ! >>> getcontext() ! Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, ! setflags=[], settraps=['Underflow', 'DecimalException', 'Clamped', ! 'InvalidContext', 'InvalidOperation', 'ConversionSyntax', ! 'DivisionByZero', 'DivisionImpossible', 'DivisionUndefined', ! 'Overflow']) ! \end{verbatim} ! ! Applications typically set the context once at the beginning of a program ! and no further changes are needed. For many applications, the data resides ! in a resource external to the program and is converted to \class{Decimal} with ! a single cast inside a loop. Afterwards, decimals are as easily manipulated ! as other Python numeric types. From rhettinger at users.sourceforge.net Sun Jul 4 09:53:36 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Jul 4 09:53:41 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30580 Modified Files: decimal.py Log Message: Changed the rounding constant values to match their variable names. This serves to made the context representation more useful (the names in match the names out). Removed the link to ReXX. That document did not shed add anything to information already in the spec. Further tighten the public API to improve usability: * Emax and Emin are set through Context(). Their defaults are set in the DefaultContext, so there is no need to expose DEFAULT_MAX_EXPONENT and DEFAULT_MIN_EXPONENT. * The string functions isnan() and isinfinity() were only used internal to the module and were not among the test cases. External use cases are served by the Decimal constructor. So, made these private. Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** decimal.py 4 Jul 2004 01:55:39 -0000 1.6 --- decimal.py 4 Jul 2004 13:53:24 -0000 1.7 *************** *** 19,31 **** www2.hursley.ibm.com/decimal/decarith.html ! IEEE standard 854-1987: www.cs.berkeley.edu/~ejr/projects/754/private/drafts/854-1987/dir.html - and ANSI standard X3.274-1996: - - www.rexxla.org/Standards/ansi.html - - Decimal floating point has finite precision with arbitrarily large bounds. --- 19,26 ---- www2.hursley.ibm.com/decimal/decarith.html ! and IEEE standard 854-1987: www.cs.berkeley.edu/~ejr/projects/754/private/drafts/854-1987/dir.html Decimal floating point has finite precision with arbitrarily large bounds. *************** *** 129,135 **** 'Underflow', - # Module parameters - 'DEFAULT_MAX_EXPONENT', 'DEFAULT_MIN_EXPONENT', - # Constants for use in setting up contexts 'ROUND_DOWN', 'ROUND_HALF_UP', 'ROUND_HALF_EVEN', 'ROUND_CEILING', --- 124,127 ---- *************** *** 138,145 **** # Functions for manipulating contexts ! 'setcontext', 'getcontext', ! ! # Functions for working with decimals ! 'isinfinity', 'isnan', ] --- 130,134 ---- # Functions for manipulating contexts ! 'setcontext', 'getcontext' ] *************** *** 154,168 **** #Rounding ! ROUND_DOWN = 'down' ! ROUND_HALF_UP = 'half_up' ! ROUND_HALF_EVEN = 'half_even' ! ROUND_CEILING = 'ceiling' ! ROUND_FLOOR = 'floor' ! ROUND_UP = 'up' ! ROUND_HALF_DOWN = 'half_down' #Rounding decision (not part of the public API) ! NEVER_ROUND = 'never' # Round in division (non-divmod), sqrt ONLY ! ALWAYS_ROUND = 'always' # Every operation rounds at end. #Errors --- 143,157 ---- #Rounding ! ROUND_DOWN = 'ROUND_DOWN' ! ROUND_HALF_UP = 'ROUND_HALF_UP' ! ROUND_HALF_EVEN = 'ROUND_HALF_EVEN' ! ROUND_CEILING = 'ROUND_CEILING' ! ROUND_FLOOR = 'ROUND_FLOOR' ! ROUND_UP = 'ROUND_UP' ! ROUND_HALF_DOWN = 'ROUND_HALF_DOWN' #Rounding decision (not part of the public API) ! NEVER_ROUND = 'NEVER_ROUND' # Round in division (non-divmod), sqrt ONLY ! ALWAYS_ROUND = 'ALWAYS_ROUND' # Every operation rounds at end. #Errors *************** *** 469,476 **** # REs insist on real strings, so we can too. if isinstance(value, basestring): ! if isinfinity(value): self._exp = 'F' self._int = (0,) ! sign = isinfinity(value) if sign == 1: self._sign = 0 --- 458,465 ---- # REs insist on real strings, so we can too. if isinstance(value, basestring): ! if _isinfinity(value): self._exp = 'F' self._int = (0,) ! sign = _isinfinity(value) if sign == 1: self._sign = 0 *************** *** 478,483 **** self._sign = 1 return ! if isnan(value): ! sig, sign, diag = isnan(value) if len(diag) > context.prec: #Diagnostic info too long self._sign, self._int, self._exp = \ --- 467,472 ---- self._sign = 1 return ! if _isnan(value): ! sig, sign, diag = _isnan(value) if len(diag) > context.prec: #Diagnostic info too long self._sign, self._int, self._exp = \ *************** *** 2128,2133 **** (Whether or not the trap_enabler is set) Should be reset by user of Decimal instance. ! Emin - Minimum exponent (defaults to -999999999) ! Emax - Maximum exponent (defaults to 999999999) capitals - If 1, 1*10^1 is printed as 1E+1. If 0, printed as 1e1 --- 2117,2122 ---- (Whether or not the trap_enabler is set) Should be reset by user of Decimal instance. ! Emin - Minimum exponent ! Emax - Maximum exponent capitals - If 1, 1*10^1 is printed as 1E+1. If 0, printed as 1e1 *************** *** 2141,2145 **** trap_enablers=None, flags=None, _rounding_decision=None, ! Emin=DEFAULT_MIN_EXPONENT, Emax=DEFAULT_MAX_EXPONENT, capitals=1, _clamp=0, _ignored_flags=[]): --- 2130,2134 ---- trap_enablers=None, flags=None, _rounding_decision=None, ! Emin=None, Emax=None, capitals=1, _clamp=0, _ignored_flags=[]): *************** *** 2928,2940 **** } ! def isinfinity(num): """Determines whether a string or float is infinity. ! +1 for positive infinity; 0 for finite ; +1 for positive infinity """ num = str(num).lower() return _infinity_map.get(num, 0) ! def isnan(num): """Determines whether a string or float is NaN --- 2917,2929 ---- } ! def _isinfinity(num): """Determines whether a string or float is infinity. ! +1 for negative infinity; 0 for finite ; +1 for positive infinity """ num = str(num).lower() return _infinity_map.get(num, 0) ! def _isnan(num): """Determines whether a string or float is NaN *************** *** 2979,2982 **** --- 2968,2973 ---- flags=None, _rounding_decision=ALWAYS_ROUND, + Emax=DEFAULT_MAX_EXPONENT, + Emin=DEFAULT_MIN_EXPONENT ) From rhettinger at users.sourceforge.net Sun Jul 4 10:04:08 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Jul 4 10:04:12 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal libdecimal.tex, 1.5, 1.6 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv308 Modified Files: libdecimal.tex Log Message: Add the section for Decimal objects. Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/libdecimal.tex,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** libdecimal.tex 4 Jul 2004 10:52:14 -0000 1.5 --- libdecimal.tex 4 Jul 2004 14:03:59 -0000 1.6 *************** *** 1,3 **** ! \section{\module{decimal} --- Decimal floating point arithmetic} --- 1,3 ---- ! \section{\module{decimal} --- Decimal floating point arithmetic} *************** *** 295,301 **** --- 295,434 ---- \subsection{Decimal objects \label{decimal-decimal}} + \begin{classdesc}{Decimal}{\optional{value \optional{, context}}} + Constructs a new \class{Decimal} object based from the \var{value}. + + \var{value} can be an integer, string, or another \class{Decimal} object. + If no \var{value} is given, returns \code{Decimal("0")}. If \var{value} is + a string, it should conform to the decimal numeric string syntax: + + \begin{verbatim} + sign ::= ’+’ | ’-’ + digit ::= ’0’ | ’1’ | ’2’ | ’3’ | ’4’ | ’5’ | ’6’ | ’7’ | ’8’ | ’9’ + indicator ::= ’e’ | ’E’ + digits ::= digit [digit]... + decimal-part ::= digits ’.’ [digits] | [’.’] digits + exponent-part ::= indicator [sign] digits + infinity ::= ’Infinity’ | ’Inf’ + nan ::= ’NaN’ [digits] | ’sNaN’ [digits] + numeric-value ::= decimal-part [exponent-part] | infinity + numeric-string ::= [sign] numeric-value | [sign] nan + \end{verbatim} + + The supplied \var{context} or, if not specified, the current context + governs only the handling of mal-formed strings not conforming to the + numeric string syntax. If the context traps \constant{ConversionSyntax}, + an exception is raised; otherwise, the constructor returns a new Decimal + with the value of \constant{NaN}. + + The context serves no other purpose. The number of significant digits + recorded is determined solely by the \var{value} and the var{context} + precision is not a factor. For example, \samp{Decimal("3.0000")} records + all four zeroes even if the context precision is only three. + + Once constructed, \class{Decimal} objects are immutable. + \end{classdesc} + + Decimal floating point objects share many properties with the other builtin + numeric types such as \class{float} and \class{int}. All of the usual + math operations and special methods apply. Likewise, decimal objects can + be copied, pickled, printed, used as dictionary keys, used as set elements, + compared, sorted, or coerced to another type (such as \class{float} + or \class{long}). + + In addition to the standard numeric properties, decimal floating point objects + have a number of more specialized methods: + + \begin{methoddesc}{adjusted}{} + Return the number's adjusted exponent that results from shifting out the + coefficients rightmost digits until only the lead digit remains: + \code{Decimal("321e+5").adjusted()} returns seven. Used for determining + the place value of the most significant digit. + \end{methoddesc} + + \begin{methoddesc}{as_tuple}{} + Returns a tuple representation of the number: + \samp{(sign, digittuple, exponent)}. + \end{methoddesc} + + \begin{methoddesc}{compare}{other\optional{, context}} + Compares like \method{__cmp__()} but returns a decimal instance: + \begin{verbatim} + a or b is a NaN ==> Decimal("NaN") + a < b ==> Decimal("-1") + a == b ==> Decimal("0") + a > b ==> Decimal("1") + \end{verbatim} + \end{methoddesc} + + \begin{methoddesc}{max}{other\optional{, context}} + Like \samp{max(self, other)} but returns \constant{NaN} if either is a + \constant{NaN}. Applies the context rounding rule before returning. + \end{methoddesc} + + \begin{methoddesc}{min}{other\optional{, context}} + Like \samp{min(self, other)} but returns \constant{NaN} if either is a + \constant{NaN}. Applies the context rounding rule before returning. + \end{methoddesc} + + \begin{methoddesc}{normalize}{\optional{context}} + Normalize the number by striping the rightmost trailing zeroes and + converting any result equal to \constant{Decimal("0")} to Decimal("0e0"). + Used for producing a canonical value for members of an equivalence class. + For example, \code{Decimal("32.100")} and \code{Decimal("0.321000e+2")} + both normalize to the equivalent value \code{Decimal("32.1")} + \end{methoddesc} + + \begin{methoddesc}{quantize} + {\optional{exp \optional{, rounding\optional{, context\optional{, watchexp}}}}} + Quantize to make the exponent the same as \var{exp}. Searches for a + rounding method in \var{rounding}, then in \var{context}, and then + in the current context. + + Of \var{watchexp} is set (default), then an error is returned if + the resulting exponent is greater than \member{Emax} or less than + \member{Etiny}. + \end{methoddesc} + + \begin{methoddesc}{remainder_near}{other\optional{, context}} + Computed the modulo as either a positive or negative value depending + on which is closest to zero. For instance, + \samp{Decimal(10).remainder_near(6)} returns \code{Decimal("-2")} + which is closer to zero than \code{Decimal("4")}. + + If both are equally close, the one chosen will have the same sign + as \var{self}. + \end{methoddesc} + + \begin{methoddesc}{same_quantum{other\optional{, context}}} + Test whether self and other have the same exponent or whether both + are \constant{NaN}. + \end{methoddesc} + + \begin{methoddesc}{sqrt}{\optional{context}} + Return the square root to full precision. + \end{methoddesc} + + \begin{methoddesc}{to_eng_string}{\optional{context}} + Convert to engineering-type string. + + Engineering notation has an exponent which is a multiple of 3, so there + are up to 3 digits left of the decimal place. For example, converts + \code{Decimal('123E+1')} to \code{Decimal("1.23E+3")} + \end{methoddesc} + + \begin{methoddesc}{to_integral}{\optional{rounding\optional{, context}}} + Rounds to the nearest integer, without signaling \constant{Inexact} + or \constant{Rounded}. If given, applies \var{rounding}; otherwise, + uses the rounding method in either the supplied \var{context} or the + current context. + \end{methoddesc} + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Context objects \label{decimal-decimal}} + + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Signals \label{decimal-signals}} *************** *** 310,314 **** the next computation. ! If the context's trap enable is set for the signal, then the condition causes a Python exception to be raised. For example, if the \class{DivisionByZero} trap is set, the a \exception{DivisionByZero} --- 443,447 ---- the next computation. ! If the context's trap enabler is set for the signal, then the condition causes a Python exception to be raised. For example, if the \class{DivisionByZero} trap is set, the a \exception{DivisionByZero} *************** *** 316,320 **** - \begin{classdesc*}{Clamped} Altered an exponent to fit representation constraints. --- 449,452 ---- *************** *** 438,441 **** --- 570,591 ---- + The following table summarizes the hierarchy of signals: + + \begin{verbatim} + exceptions.ArithmeticError(exceptions.StandardError) + DecimalException + Clamped + DivisionByZero(DecimalException, exceptions.ZeroDivisionError) + Inexact + Overflow(Inexact, Rounded) + Underflow(Inexact, Rounded, Subnormal) + InvalidOperation + ConversionSyntax + DivisionImpossible + DivisionUndefined(InvalidOperation, exceptions.ZeroDivisionError) + InvalidContext + Rounded + Subnormal + \end{verbatim} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% From rhettinger at users.sourceforge.net Sun Jul 4 10:11:42 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Jul 4 10:11:49 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal libdecimal.tex, 1.6, 1.7 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1346 Modified Files: libdecimal.tex Log Message: Fix non-ascii single quotes Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/libdecimal.tex,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** libdecimal.tex 4 Jul 2004 14:03:59 -0000 1.6 --- libdecimal.tex 4 Jul 2004 14:11:30 -0000 1.7 *************** *** 1,3 **** ! \section{\module{decimal} --- Decimal floating point arithmetic} --- 1,3 ---- ! \section{\module{decimal} --- Decimal floating point arithmetic} *************** *** 303,314 **** \begin{verbatim} ! sign ::= ’+’ | ’-’ ! digit ::= ’0’ | ’1’ | ’2’ | ’3’ | ’4’ | ’5’ | ’6’ | ’7’ | ’8’ | ’9’ ! indicator ::= ’e’ | ’E’ digits ::= digit [digit]... ! decimal-part ::= digits ’.’ [digits] | [’.’] digits exponent-part ::= indicator [sign] digits ! infinity ::= ’Infinity’ | ’Inf’ ! nan ::= ’NaN’ [digits] | ’sNaN’ [digits] numeric-value ::= decimal-part [exponent-part] | infinity numeric-string ::= [sign] numeric-value | [sign] nan --- 303,314 ---- \begin{verbatim} ! sign ::= '+' | '-' ! digit ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' ! indicator ::= 'e' | 'E' digits ::= digit [digit]... ! decimal-part ::= digits '.' [digits] | ['.'] digits exponent-part ::= indicator [sign] digits ! infinity ::= 'Infinity' | 'Inf' ! nan ::= 'NaN' [digits] | 'sNaN' [digits] numeric-value ::= decimal-part [exponent-part] | infinity numeric-string ::= [sign] numeric-value | [sign] nan From akuchling at users.sourceforge.net Sun Jul 4 11:35:35 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sun Jul 4 11:35:45 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.58, 1.59 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14023 Modified Files: whatsnew24.tex Log Message: More additions Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** whatsnew24.tex 4 Jul 2004 01:44:04 -0000 1.58 --- whatsnew24.tex 4 Jul 2004 15:35:00 -0000 1.59 *************** *** 7,10 **** --- 7,13 ---- % to be covered. --amk + % XXX pydoc can display links to module docs -- but when? + % + \title{What's New in Python 2.4} \release{0.0} *************** *** 443,447 **** \item The \method{dict.update()} method now accepts the same argument forms as the \class{dict} constructor. This includes any ! mapping, any iterable of key/value pairs, and/or keyword arguments. \item The string methods, \method{ljust()}, \method{rjust()}, and --- 446,450 ---- \item The \method{dict.update()} method now accepts the same argument forms as the \class{dict} constructor. This includes any ! mapping, any iterable of key/value pairs, and keyword arguments. \item The string methods, \method{ljust()}, \method{rjust()}, and *************** *** 548,551 **** --- 551,558 ---- \end{verbatim} + \item The \function{eval(\var{expr}, \var{globals}, \var{locals})} + function now accepts any mapping type for the \var{locals} argument. + Previously this had to be a regular Python dictionary. + \item The \function{zip()} built-in function and \function{itertools.izip()} now return an empty list instead of raising a \exception{TypeError} *************** *** 625,628 **** --- 632,640 ---- \begin{itemize} + \item The \module{asyncore} module's \function{loop()} now has a + \var{count} parameter that lets you perform a limited number + of passes through the polling loop. The default is still to loop + forever. + \item The \module{curses} modules now supports the ncurses extension \function{use_default_colors()}. On platforms where the terminal *************** *** 684,688 **** high volumes of data. In addition, the module has two new functions \function{nlargest()} and \function{nsmallest()} that use heaps to ! find the largest or smallest n values in a dataset without the expense of a full sort. --- 696,700 ---- high volumes of data. In addition, the module has two new functions \function{nlargest()} and \function{nsmallest()} that use heaps to ! find the N largest or smallest values in a dataset without the expense of a full sort. *************** *** 761,768 **** bookmarking, windowing, or lookahead iterators. - \item A new \function{getsid()} function was added to the - \module{posix} module that underlies the \module{os} module. - (Contributed by J. Raynor.) - \item The \module{operator} module gained two new functions, \function{attrgetter(\var{attr})} and \function{itemgetter(\var{index})}. --- 773,776 ---- *************** *** 782,785 **** --- 790,802 ---- \end{verbatim} + \item A new \function{getsid()} function was added to the + \module{posix} module that underlies the \module{os} module. + (Contributed by J. Raynor.) + + \item The \module{poplib} module now supports POP over SSL. + + \item The \module{profile} module can now profile C extension functions. + % XXX more to say about this? + \item The \module{random} module has a new method called \method{getrandbits(N)} which returns an N-bit long integer. This method supports the existing *************** *** 798,801 **** --- 815,821 ---- including Python functions, class instances, sets, frozensets, deques, arrays, files, sockets, and regular expression pattern objects. + + \item The \module{xmlrpclib} module now supports a multi-call extension for + tranmitting multiple XML-RPC calls in a single HTTP operation. \end{itemize} *************** *** 847,851 **** defined in slots to co-exist with a PyCFunction having the same name. This can halve the access to time to a method such as ! \method{set.__contains__()} \end{itemize} --- 867,880 ---- defined in slots to co-exist with a PyCFunction having the same name. This can halve the access to time to a method such as ! \method{set.__contains__()}. ! ! \item Python can now be built with additional profiling for the interpreter ! itself, useful if you're working on the Python core. ! Providing \longprogramopt{--enable-profiling} to the ! \program{configure} script will let you profile the interpreter with ! \program{gprof}, and providing the \longprogramopt{--with-tsc} switch ! enables profiling using the Pentium's Time-Stamp-Counter. ! ! \item The \ctype{tracebackobject} type has been renamed to \ctype{PyTracebackObject}. \end{itemize} From akuchling at users.sourceforge.net Sun Jul 4 11:42:29 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sun Jul 4 11:42:36 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1022,1.1023 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14840 Modified Files: NEWS Log Message: Typo fixes Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1022 retrieving revision 1.1023 diff -C2 -d -r1.1022 -r1.1023 *** NEWS 3 Jul 2004 03:54:54 -0000 1.1022 --- NEWS 4 Jul 2004 15:41:59 -0000 1.1023 *************** *** 50,54 **** - Enabled the profiling of C extension functions (and builtins) - check ! new documentation and modified profiler and bdb modules for more details - Set file.name to the object passed to open (instead of a new string) --- 50,54 ---- - Enabled the profiling of C extension functions (and builtins) - check ! new documentation and modified profile and bdb modules for more details - Set file.name to the object passed to open (instead of a new string) *************** *** 222,226 **** will now just hit the recursion limit. See SF patch 825639. ! - str and unicode builtin types now have rsplit() method that is same as split() except that it scans the string from the end working towards the beginning. See SF feature request 801847. --- 222,226 ---- will now just hit the recursion limit. See SF patch 825639. ! - str and unicode builtin types now have an rsplit() method that is same as split() except that it scans the string from the end working towards the beginning. See SF feature request 801847. *************** *** 266,274 **** socket.error to the socket module's C API. ! - Bug #920575: A problem that _locale module segfaults on nl_langinfo(ERA) caused by GNU libc's illegal NULL return is fixed. - array objects now support the copy module. Also, their resizing ! scheme has been updated the same as for list objects. The improves the performance (speed and memory usage) of append() operations. Also, array.extend() now accepts any iterable argument for repeated --- 266,274 ---- socket.error to the socket module's C API. ! - Bug #920575: A problem where the _locale module segfaults on nl_langinfo(ERA) caused by GNU libc's illegal NULL return is fixed. - array objects now support the copy module. Also, their resizing ! scheme has been updated to match that used for list objects. This improves the performance (speed and memory usage) of append() operations. Also, array.extend() now accepts any iterable argument for repeated *************** *** 349,353 **** the Unix uniq filter. ! - itertools now has a new function, tee() which produces two independent iterators from a single iterable. --- 349,353 ---- the Unix uniq filter. ! - itertools now has a new tee() function which produces two independent iterators from a single iterable. *************** *** 433,437 **** - Support non-anonymous ftp URLs in urllib2. ! - The encodings package will now applies codec name aliases first before starting to try the import of the codec module. This simplifies overriding built-in codecs with external --- 433,437 ---- - Support non-anonymous ftp URLs in urllib2. ! - The encodings package will now apply codec name aliases first before starting to try the import of the codec module. This simplifies overriding built-in codecs with external From akuchling at users.sourceforge.net Sun Jul 4 12:39:57 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sun Jul 4 12:40:01 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.59, 1.60 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23572 Modified Files: whatsnew24.tex Log Message: Bump version #; write introductory para Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** whatsnew24.tex 4 Jul 2004 15:35:00 -0000 1.59 --- whatsnew24.tex 4 Jul 2004 16:39:40 -0000 1.60 *************** *** 11,15 **** \title{What's New in Python 2.4} ! \release{0.0} \author{A.M.\ Kuchling} \authoraddress{ --- 11,15 ---- \title{What's New in Python 2.4} ! \release{0.1} \author{A.M.\ Kuchling} \authoraddress{ *************** *** 22,39 **** \tableofcontents ! This article explains the new features in Python 2.4. The release ! date is expected to be around September 2004. ! While Python 2.3 was primarily a library development release, Python ! 2.4 may extend the core language and interpreter in ! as-yet-undetermined ways. This article doesn't attempt to provide a complete specification of ! the new features, but instead provides a convenient overview. For ! full details, you should refer to the documentation for Python 2.4, ! such as the \citetitle[../lib/lib.html]{Python Library Reference} and ! the \citetitle[../ref/ref.html]{Python Reference Manual}. ! If you want to understand the complete implementation and design ! rationale, refer to the PEP for a particular new feature. --- 22,42 ---- \tableofcontents ! This article explains the new features in Python 2.4 alpha1, to be released in early July 2004 The final version of Python 2.4 ! is expected to be around September 2004. ! Python 2.4 is a middle-sized release. It doesn't introduce as many ! changes as the radical Python 2.2, but introduces more features than ! the conservative 2.3 release did. The most significant new language ! feature (as of this writing) is the addition of generator expressions; ! most of the changes are to the standard library. This article doesn't attempt to provide a complete specification of ! every single new feature, but instead provides a convenient overview. ! For full details, you should refer to the documentation for Python ! 2.4, such as the \citetitle[../lib/lib.html]{Python Library Reference} ! and the \citetitle[../ref/ref.html]{Python Reference Manual}. If you ! want to understand the complete implementation and design rationale, ! refer to the PEP for a particular new feature or to the module ! documentation. From bcannon at users.sourceforge.net Sun Jul 4 14:36:45 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Jul 4 14:36:53 2004 Subject: [Python-checkins] python/dist/src/Lib threading.py, 1.38.6.1, 1.38.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9557/Lib Modified Files: Tag: release23-maint threading.py Log Message: Fix bug introduced by previous backport. Index: threading.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/threading.py,v retrieving revision 1.38.6.1 retrieving revision 1.38.6.2 diff -C2 -d -r1.38.6.1 -r1.38.6.2 *** threading.py 3 Jul 2004 19:58:57 -0000 1.38.6.1 --- threading.py 4 Jul 2004 18:35:56 -0000 1.38.6.2 *************** *** 451,456 **** # _sys) in case sys.stderr was redefined. if _sys: ! _sys.stderr.write("Exception in thread %s:\n%s\n" % ! (self.getName(), _format_exc())) else: # Do the best job possible w/o a huge amt. of code to --- 451,457 ---- # _sys) in case sys.stderr was redefined. if _sys: ! _sys.stderr.write("Exception in thread %s:" % ! self.getName()) ! _print_exc(file=_sys.stderr) else: # Do the best job possible w/o a huge amt. of code to From akuchling at users.sourceforge.net Sun Jul 4 21:37:18 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sun Jul 4 21:37:23 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.60, 1.61 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8107 Modified Files: whatsnew24.tex Log Message: Various edits Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** whatsnew24.tex 4 Jul 2004 16:39:40 -0000 1.60 --- whatsnew24.tex 5 Jul 2004 01:37:07 -0000 1.61 *************** *** 22,33 **** \tableofcontents ! This article explains the new features in Python 2.4 alpha1, to be released in early July 2004 The final version of Python 2.4 ! is expected to be around September 2004. ! Python 2.4 is a middle-sized release. It doesn't introduce as many changes as the radical Python 2.2, but introduces more features than the conservative 2.3 release did. The most significant new language feature (as of this writing) is the addition of generator expressions; ! most of the changes are to the standard library. This article doesn't attempt to provide a complete specification of --- 22,34 ---- \tableofcontents ! This article explains the new features in Python 2.4 alpha1, scheduled ! for release in early July 2004. The final version of Python 2.4 is ! expected to be released around September 2004. ! Python 2.4 is a medium-sized release. It doesn't introduce as many changes as the radical Python 2.2, but introduces more features than the conservative 2.3 release did. The most significant new language feature (as of this writing) is the addition of generator expressions; ! most other changes are to the standard library. This article doesn't attempt to provide a complete specification of *************** *** 44,52 **** \section{PEP 218: Built-In Set Objects} ! Two new built-in types, \function{set(\var{iterable})} and ! \function{frozenset(\var{iterable})} provide high speed data types for ! membership testing, for eliminating duplicates from sequences, and ! for mathematical operations like unions, intersections, differences, ! and symmetric differences. \begin{verbatim} --- 45,55 ---- \section{PEP 218: Built-In Set Objects} ! Python 2.3 introduced the \module{sets} module. C implementations of ! set data types have now been added to the Python core as two new ! built-in types, \function{set(\var{iterable})} and ! \function{frozenset(\var{iterable})}. They provide high speed ! operations for membership testing, for eliminating duplicates from ! sequences, and for mathematical operations like unions, intersections, ! differences, and symmetric differences. \begin{verbatim} *************** *** 78,91 **** \end{verbatim} ! The type \function{frozenset()} is an immutable version of \function{set()}. Since it is immutable and hashable, it may be used as a dictionary key or ! as a member of another set. Accordingly, it does not have methods ! like \method{add()} and \method{remove()} which could alter its contents. ! % XXX what happens to the sets module? ! % The current thinking is that the sets module will be left alone. ! % That way, existing code will continue to run without alteration. ! % Also, the module provides an autoconversion feature not supported by set() ! % and frozenset(). \begin{seealso} --- 81,91 ---- \end{verbatim} ! The \function{frozenset} type is an immutable version of \function{set}. Since it is immutable and hashable, it may be used as a dictionary key or ! as a member of another set. ! The \module{sets} module remains in the standard library, and may be ! useful if you wish to subclass the \class{Set} or \class{ImmutableSet} ! classes. There are currently no plans to deprecate the module. \begin{seealso} *************** *** 97,117 **** \section{PEP 237: Unifying Long Integers and Integers} ! The lengthy transition process for the PEP, begun with Python 2.2, takes another step forward in Python 2.4. In 2.3, certain integer operations that would behave differently after int/long unification triggered \exception{FutureWarning} warnings and returned values ! limited to 32 or 64 bits. In 2.4, these expressions no longer produce ! a warning, but they now produce a different value that's a long ! integer. The problematic expressions are primarily left shifts and lengthy ! hexadecimal and octal constants. For example, \code{2 << 32} is one ! expression that results in a warning in 2.3, evaluating to 0 on 32-bit ! platforms. In Python 2.4, this expression now returns 8589934592. ! \begin{seealso} \seepep{237}{Unifying Long Integers and Integers}{Original PEP ! written by Moshe Zadka and Gvr. The changes for 2.4 were implemented by Kalle Svensson.} \end{seealso} --- 97,116 ---- \section{PEP 237: Unifying Long Integers and Integers} ! The lengthy transition process for this PEP, begun in Python 2.2, takes another step forward in Python 2.4. In 2.3, certain integer operations that would behave differently after int/long unification triggered \exception{FutureWarning} warnings and returned values ! limited to 32 or 64 bits (depending on your platform). In 2.4, these ! expressions no longer produce a warning and instead produce a ! different result that's usually a long integer. The problematic expressions are primarily left shifts and lengthy ! hexadecimal and octal constants. For example, \code{2 << 32} results ! in a warning in 2.3, evaluating to 0 on 32-bit platforms. In Python ! 2.4, this expression now returns the correct answer, 8589934592. \begin{seealso} \seepep{237}{Unifying Long Integers and Integers}{Original PEP ! written by Moshe Zadka and GvR. The changes for 2.4 were implemented by Kalle Svensson.} \end{seealso} *************** *** 125,131 **** \module{itertools} module to write code in a fairly functional style. ! The fly in the ointment has been list comprehensions, because they produce a Python list object containing all of the items, unavoidably ! pulling them all into memory. When trying to write a program using the functional approach, it would be natural to write something like: \begin{verbatim} --- 124,133 ---- \module{itertools} module to write code in a fairly functional style. ! % XXX avoid metaphor ! List comprehensions have been the fly in the ointment because they produce a Python list object containing all of the items, unavoidably ! pulling them all into memory. When trying to write a ! functionally-styled program, it would be natural to write something ! like: \begin{verbatim} *************** *** 167,176 **** \end{verbatim} ! There are some small differences from list comprehensions. Most ! notably, the loop variable (\var{obj} in the above example) is not ! accessible outside of the generator expression. List comprehensions ! leave the variable assigned to its last value; future versions of ! Python will change this, making list comprehensions match generator ! expressions in this respect. \begin{seealso} --- 169,178 ---- \end{verbatim} ! Generator expressions differ from list comprehensions in various small ! ways. Most notably, the loop variable (\var{obj} in the above ! example) is not accessible outside of the generator expression. List ! comprehensions leave the variable assigned to its last value; future ! versions of Python will change this, making list comprehensions match ! generator expressions in this respect. \begin{seealso} *************** *** 183,187 **** A new built-in function, \function{reversed(\var{seq})}, takes a sequence ! and returns an iterator that returns the elements of the sequence in reverse order. --- 185,189 ---- A new built-in function, \function{reversed(\var{seq})}, takes a sequence ! and returns an iterator that loops over the elements of the sequence in reverse order. *************** *** 195,200 **** \end{verbatim} ! Compared to extended slicing, \code{range(1,4)[::-1]}, \function{reversed()} ! is easier to read, runs faster, and uses substantially less memory. Note that \function{reversed()} only accepts sequences, not arbitrary --- 197,203 ---- \end{verbatim} ! Compared to extended slicing, such as \code{range(1,4)[::-1]}, ! \function{reversed()} is easier to read, runs faster, and uses ! substantially less memory. Note that \function{reversed()} only accepts sequences, not arbitrary *************** *** 451,455 **** mapping, any iterable of key/value pairs, and keyword arguments. ! \item The string methods, \method{ljust()}, \method{rjust()}, and \method{center()} now take an optional argument for specifying a fill character other than a space. --- 454,458 ---- mapping, any iterable of key/value pairs, and keyword arguments. ! \item The string methods \method{ljust()}, \method{rjust()}, and \method{center()} now take an optional argument for specifying a fill character other than a space. *************** *** 467,471 **** \item The \method{sort()} method of lists gained three keyword ! arguments, \var{cmp}, \var{key}, and \var{reverse}. These arguments make some common usages of \method{sort()} simpler. All are optional. --- 470,474 ---- \item The \method{sort()} method of lists gained three keyword ! arguments: \var{cmp}, \var{key}, and \var{reverse}. These arguments make some common usages of \method{sort()} simpler. All are optional. *************** *** 497,501 **** using a \var{key} parameter. Using \var{key} results in calling the \method{lower()} method once for each element in the list while using ! \var{cmp} will call the method twice for each comparison. For simple key functions and comparison functions, it is often --- 500,504 ---- using a \var{key} parameter. Using \var{key} results in calling the \method{lower()} method once for each element in the list while using ! \var{cmp} will call it twice for each comparison. For simple key functions and comparison functions, it is often *************** *** 510,517 **** \end{verbatim} ! The \var{reverse} parameter should have a Boolean value. If the value is ! \constant{True}, the list will be sorted into reverse order. Instead ! of \code{L.sort(lambda x,y: cmp(y.score, x.score))}, you can now write: ! \code{L.sort(key = lambda x: x.score, reverse=True)}. The results of sorting are now guaranteed to be stable. This means --- 513,521 ---- \end{verbatim} ! The \var{reverse} parameter should have a Boolean value. If the value ! is \constant{True}, the list will be sorted into reverse order. ! Instead of \code{L.sort(lambda x,y: cmp(x.score, y.score)) ; ! L.reverse()}, you can now write: \code{L.sort(key = lambda x: x.score, ! reverse=True)}. The results of sorting are now guaranteed to be stable. This means *************** *** 523,527 **** \item There is a new built-in function \function{sorted(\var{iterable})} that works like the in-place ! \method{list.sort()} method but has been made suitable for use in expressions. The differences are: \begin{itemize} --- 527,531 ---- \item There is a new built-in function \function{sorted(\var{iterable})} that works like the in-place ! \method{list.sort()} method but can be used in expressions. The differences are: \begin{itemize} *************** *** 551,555 **** red 1 yellow 5 - \end{verbatim} --- 555,558 ---- *************** *** 559,564 **** \item The \function{zip()} built-in function and \function{itertools.izip()} ! now return an empty list instead of raising a \exception{TypeError} ! exception if called with no arguments. This makes them more suitable for use with variable length argument lists: --- 562,568 ---- \item The \function{zip()} built-in function and \function{itertools.izip()} ! now return an empty list if called with no arguments. ! Previously they raised a \exception{TypeError} ! exception. This makes them more suitable for use with variable length argument lists: *************** *** 581,606 **** \begin{itemize} ! \item The inner loops for \class{list} and \class{tuple} slicing were optimized and now run about one-third faster. The inner ! loops were also optimized for \class{dict} with performance boosts to \method{keys()}, \method{values()}, \method{items()}, \method{iterkeys()}, \method{itervalues()}, and \method{iteritems()}. ! \item The machinery for growing and shrinking lists was optimized ! for speed and for space efficiency. Small lists (under eight elements) ! never over-allocate by more than three elements. Large lists do not ! over-allocate by more than 1/8th. Appending and popping from lists ! now runs faster due to more efficient code paths and less frequent ! use of the underlying system realloc(). List comprehensions also ! benefit. The amount of improvement varies between systems and shows ! the greatest improvement on systems with poor realloc() implementations. ! \method{list.extend()} was also optimized and no longer converts its ! argument into a temporary list prior to extending the base list. \item \function{list()}, \function{tuple()}, \function{map()}, \function{filter()}, and \function{zip()} now run several times faster with non-sequence arguments that supply a \method{__len__()} ! method. Previously, the pre-sizing optimization only applied to ! sequence arguments. \item The methods \method{list.__getitem__()}, --- 585,606 ---- \begin{itemize} ! \item The inner loops for list and tupleslicing were optimized and now run about one-third faster. The inner ! loops were also optimized for dictionaries with performance boosts to \method{keys()}, \method{values()}, \method{items()}, \method{iterkeys()}, \method{itervalues()}, and \method{iteritems()}. ! \item The machinery for growing and shrinking lists was optimized for ! speed and for space efficiency. Appending and popping from lists now ! runs faster due to more efficient code paths and less frequent use of ! the underlying system \cfunction{realloc()}. List comprehensions ! also benefit. \method{list.extend()} was also optimized and no ! longer converts its argument into a temporary list before extending ! the base list. \item \function{list()}, \function{tuple()}, \function{map()}, \function{filter()}, and \function{zip()} now run several times faster with non-sequence arguments that supply a \method{__len__()} ! method. \item The methods \method{list.__getitem__()}, *************** *** 686,691 **** Several modules now take advantage of \class{collections.deque} for ! improved performance: \module{Queue}, \module{mutex}, \module{shlex} ! \module{threading}, and \module{pydoc}. \item The \module{ConfigParser} classes have been enhanced slightly. --- 686,691 ---- Several modules now take advantage of \class{collections.deque} for ! improved performance, such as the \module{Queue} and ! \module{threading} modules. \item The \module{ConfigParser} classes have been enhanced slightly. *************** *** 706,711 **** \item The \module{itertools} module gained a ! \function{groupby(\var{iterable}\optional{, \var{func}})} function, ! inspired by the GROUP BY clause from SQL. \var{iterable} returns a succession of elements, and the optional \var{func} is a function that takes an element and returns a key --- 706,710 ---- \item The \module{itertools} module gained a ! \function{groupby(\var{iterable}\optional{, \var{func}})} function. \var{iterable} returns a succession of elements, and the optional \var{func} is a function that takes an element and returns a key *************** *** 733,740 **** \end{verbatim} ! Like its SQL counterpart, \function{groupby()} is typically used with ! sorted input. The logic for \function{groupby()} is similar to the ! \UNIX{} \code{uniq} filter which makes it handy for eliminating, ! counting, or identifying duplicate elements: \begin{verbatim} --- 732,739 ---- \end{verbatim} ! \function{groupby()} is typically used with sorted input. The logic ! for \function{groupby()} is similar to the \UNIX{} \code{uniq} filter ! which makes it handy for eliminating, counting, or identifying ! duplicate elements: \begin{verbatim} *************** *** 743,752 **** >>> letters ['a', 'a', 'a', 'a', 'a', 'b', 'b', 'c', 'd', 'r', 'r'] ! >>> [k for k, g in groupby(letters)] # List unique letters ['a', 'b', 'c', 'd', 'r'] ! >>> [(k, len(list(g))) for k, g in groupby(letters)] # Count letter occurences [('a', 5), ('b', 2), ('c', 1), ('d', 1), ('r', 2)] - >>> [k for k, g in groupby(letters) if len(list(g)) > 1] # List duplicated letters - ['a', 'b', 'r'] \end{verbatim} --- 742,759 ---- >>> letters ['a', 'a', 'a', 'a', 'a', 'b', 'b', 'c', 'd', 'r', 'r'] ! >>> for k, g in itertools.groupby(letters): ! ... print k, list(g) ! ... ! a ['a', 'a', 'a', 'a', 'a'] ! b ['b', 'b'] ! c ['c'] ! d ['d'] ! r ['r', 'r'] ! >>> # List unique letters ! >>> [k for k, g in groupby(letters)] ['a', 'b', 'c', 'd', 'r'] ! >>> # Count letter occurences ! >>> [(k, len(list(g))) for k, g in groupby(letters)] [('a', 5), ('b', 2), ('c', 1), ('d', 1), ('r', 2)] \end{verbatim} *************** *** 771,775 **** This should therefore be used carefully if the leading iterator can run far ahead of the trailing iterator in a long stream of inputs. ! If the separation is large, then it becomes preferable to use \function{list()} instead. When the iterators track closely with one another, \function{tee()} is ideal. Possible applications include --- 778,782 ---- This should therefore be used carefully if the leading iterator can run far ahead of the trailing iterator in a long stream of inputs. ! If the separation is large, then you might as well use \function{list()} instead. When the iterators track closely with one another, \function{tee()} is ideal. Possible applications include From akuchling at users.sourceforge.net Sun Jul 4 21:40:35 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sun Jul 4 21:40:40 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.61, 1.62 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8396 Modified Files: whatsnew24.tex Log Message: Various edits Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** whatsnew24.tex 5 Jul 2004 01:37:07 -0000 1.61 --- whatsnew24.tex 5 Jul 2004 01:40:07 -0000 1.62 *************** *** 839,844 **** The \module{cookielib} library supports client-side handling for HTTP cookies, just as the \module{Cookie} provides server-side cookie ! support in CGI scripts. This library manages cookies in a way similar ! to web browsers. Cookies are stored in cookie jars; the library transparently stores cookies offered by the web server in the cookie jar, and fetches the cookie from the jar when connecting to the --- 839,843 ---- The \module{cookielib} library supports client-side handling for HTTP cookies, just as the \module{Cookie} provides server-side cookie ! support in CGI scripts. Cookies are stored in cookie jars; the library transparently stores cookies offered by the web server in the cookie jar, and fetches the cookie from the jar when connecting to the *************** *** 875,888 **** \item A new method flag, \constant{METH_COEXISTS}, allows a function ! defined in slots to co-exist with a PyCFunction having the same name. ! This can halve the access to time to a method such as \method{set.__contains__()}. \item Python can now be built with additional profiling for the interpreter ! itself, useful if you're working on the Python core. Providing \longprogramopt{--enable-profiling} to the \program{configure} script will let you profile the interpreter with \program{gprof}, and providing the \longprogramopt{--with-tsc} switch ! enables profiling using the Pentium's Time-Stamp-Counter. \item The \ctype{tracebackobject} type has been renamed to \ctype{PyTracebackObject}. --- 874,887 ---- \item A new method flag, \constant{METH_COEXISTS}, allows a function ! defined in slots to co-exist with a \ctype{PyCFunction} having the ! same name. This can halve the access time for a method such as \method{set.__contains__()}. \item Python can now be built with additional profiling for the interpreter ! itself. This is intended for people developing on the Python core. Providing \longprogramopt{--enable-profiling} to the \program{configure} script will let you profile the interpreter with \program{gprof}, and providing the \longprogramopt{--with-tsc} switch ! enables profiling using the Pentium's Time-Stamp-Counter register. \item The \ctype{tracebackobject} type has been renamed to \ctype{PyTracebackObject}. *************** *** 940,949 **** instead of returning empty lists. ! \item \function{LexicalHandler.startDTD()} used to receive public and ! system ID in the wrong order. This has been corrected; applications relying on the wrong order need to be fixed. ! \item \function{fcntl.ioctl} now warns if the mutate arg is omitted ! and relevant. \end{itemize} --- 939,948 ---- instead of returning empty lists. ! \item \function{LexicalHandler.startDTD()} used to receive the public and ! system IDs in the wrong order. This has been corrected; applications relying on the wrong order need to be fixed. ! \item \function{fcntl.ioctl} now warns if the \var{mutate} ! argument is omitted and relevant. \end{itemize} From rhettinger at users.sourceforge.net Mon Jul 5 01:03:26 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Jul 5 01:03:34 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal libdecimal.tex, 1.7, 1.8 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31513 Modified Files: libdecimal.tex Log Message: Add a Context object section. Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/libdecimal.tex,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** libdecimal.tex 4 Jul 2004 14:11:30 -0000 1.7 --- libdecimal.tex 5 Jul 2004 05:02:58 -0000 1.8 *************** *** 381,385 **** \begin{methoddesc}{quantize} {\optional{exp \optional{, rounding\optional{, context\optional{, watchexp}}}}} ! Quantize to make the exponent the same as \var{exp}. Searches for a rounding method in \var{rounding}, then in \var{context}, and then in the current context. --- 381,385 ---- \begin{methoddesc}{quantize} {\optional{exp \optional{, rounding\optional{, context\optional{, watchexp}}}}} ! Quantize makes the exponent the same as \var{exp}. Searches for a rounding method in \var{rounding}, then in \var{context}, and then in the current context. *************** *** 428,431 **** --- 428,686 ---- \subsection{Context objects \label{decimal-decimal}} + Contexts are environments for arithmetic operations. They govern the precision, + rules for rounding, determine which signals are treated as exceptions, and set limits + on the range for exponents. + + Each thread has its own current context which is accessed or changed using + the \function{getcontext()} and \function{setcontext()} functions: + + \begin{funcdesc}{getcontext}{} + Return the current context for the active thread. + \end{funcdesc} + + \begin{funcdesc}{setcontext}{c} + Set the current context for the active thread to \var{c}. + \end{funcdesc} + + New contexts can formed using the \class{Context} constructor described below. + In addition, the module provides three pre-made contexts: + + + \begin{classdesc*}{BasicContext} + This is a standard context defined by the General Decimal Arithmetic + Specification. Precision is set to nine. Rounding is set to + \constant{ROUND_HALF_UP}. All flags are cleared. All traps are enabled + (treated as exceptions) except \constant{Inexact}, \constant{Rounded}, and + \constant{Subnormal}. + + Because many of the traps are enabled, this context is useful for debugging. + \end{classdesc*} + + \begin{classdesc*}{ExtendedContext} + This is a standard context defined by the General Decimal Arithmetic + Specification. Precision is set to nine. Rounding is set to + \constant{ROUND_HALF_EVEN}. All flags are cleared. No traps are enabled + (so that exceptions are not raised during computations). + \end{classdesc*} + + \begin{classdesc*}{DefaultContext} + This class is used by the \class{Context} constructor as a prototype for + new contexts. Changing a field (such a precision) has the effect of + changing the default for new contexts creating by the \class{Context} + constructor. + + This context is most useful in multi-threaded environments. Changing one of + the fields before threads are started has the effect of setting system-wide + defaults. Changing the fields after threads have started is not recommended + as it would require thread synchronization to prevent race conditions. + + In single threaded environments, it is preferable to not use this context + at all. Instead, simply create contexts explicitly. This is especially + important because the default values context may change between releases + (with initial release having precision=28, rounding=ROUND_HALF_EVEN, + cleared flags, and no traps enabled). + \end{classdesc*} + + + \begin{classdesc}{Context}{prec=None, rounding=None, trap_enablers=None, + flags=None, Emin=None, Emax=None, capitals=1} + Creates a new context. If a field is not specified or is \constant{None}, + the default values are copied from the \constant{DefaultContext}. If the + \var{flags} field is not specified or is \constant{None}, all flags are + cleared. + + The \var{prec} field in an positive integer that sets the precision for + arithmetic operations in the context. + + The \var{rounding} option is one of: \constant{ROUND_CEILING}, + \constant{ROUND_DOWN}, \constant{ROUND_FLOOR}, \constant{ROUND_HALF_DOWN}, + \constant{ROUND_HALF_EVEN}, \constant{ROUND_HALF_UP}, or + \constant{ROUND_UP}. + + The \var{trap_enablers} and \var{flags} fields are mappings from signals + to either \constant{0} or \constant{1}. + + The \var{Emin} and \var{Emax} fields are integers specifying the outer + limits allowable for exponents. + + The \var{capitals} field is either \constant{0} or \constant{1} (the + default). If set to \constant{1}, exponents are printed with a capital + \constant{E}; otherwise, lowercase is used: \constant{Decimal('6.02e+23')}. + \end{classdesc} + + The \class{Context} class defines several general methods as well as a + large number of methods for doing arithmetic directly from the context. + + \begin{methoddesc}{clear_flags}{} + Sets all of the flags to \constant{0}. + \end{methoddesc} + + \begin{methoddesc}{copy}{} + Returns a duplicate of the context. + \end{methoddesc} + + \begin{methoddesc}{create_decimal}{num} + Creates a new Decimal instance but using \var{self} as context. + Unlike the \class{Decimal} constructor, context precision, + rounding method, flags, and traps are applied to the conversion. + + This is useful because constants are often given to a greater + precision than is needed by the application. + \end{methoddesc} + + \begin{methoddesc}{Etiny}{} + Returns a value equal to \samp{Emin - prec + 1} which is the minimum + exponent value for subnormal results. When underflow occurs, the + exponont is set to \constant{Etiny}. + \end{methoddesc} + + The usual approach to working with decimals is to create Decimal + instances and then apply arithmetic operations which take place + within the current context for the active thread. An alternate + approach is to use a context method to perform a particular + computation within the given context rather than the current context. + + Those methods parallel those for the \class{Decimal} class and are + only briefed recounted here. + + + \begin{methoddesc}{abs}{x} + Returns the absolute value of \var{x}. + \end{methoddesc} + + \begin{methoddesc}{add}{x, y} + Return the sum of \var{x} and \var{y}. + \end{methoddesc} + + \begin{methoddesc}{compare}{x, y} + Compares values numerically. + + Like \method{__cmp__()} but returns a decimal instance: + \begin{verbatim} + a or b is a NaN ==> Decimal("NaN") + a < b ==> Decimal("-1") + a == b ==> Decimal("0") + a > b ==> Decimal("1") + \end{verbatim} + \end{methoddesc} + + \begin{methoddesc}{divide}{x, y} + Return \var{x} divided by \var{y}. + \end{methoddesc} + + \begin{methoddesc}{divide}{x, y} + Divides two numbers and returns the integer part of the result. + \end{methoddesc} + + \begin{methoddesc}{max}{x, y} + Compare two values numerically and returns the maximum. + + If they are numerically equal then the left-hand operand is chosen as the + result. + \end{methoddesc} + + \begin{methoddesc}{min}{x, y} + Compare two values numerically and returns the minimum. + + If they are numerically equal then the left-hand operand is chosen as the + result. + \end{methoddesc} + + \begin{methoddesc}{minus}{x} + Minus corresponds to unary prefix minus in Python. + \end{methoddesc} + + \begin{methoddesc}{multiply}{x, y} + Return the product of \var{x} and \var{y}. + \end{methoddesc} + + \begin{methoddesc}{normalize}{x} + Normalize reduces an operand to its simplest form. + + Essentially a plus operation with all trailing zeros removed from the + result. + \end{methoddesc} + + \begin{methoddesc}{plus}{x} + Minus corresponds to unary prefix plus in Python. + \end{methoddesc} + + \begin{methoddesc}{power}{x, y\optional{, modulo}} + Return \samp{x ** y} to the \var{modulo} if given. + + The right-hand operand must be a whole number whose integer part (after any + exponent has been applied) has no more than 9 digits and whose fractional + part (if any) is all zeros before any rounding. The operand may be positive, + negative, or zero; if negative, the absolute value of the power is used, and + the left-hand operand is inverted (divided into 1) before use. + + If the increased precision needed for the intermediate calculations exceeds + the capabilities of the implementation then an Invalid operation condition + is raised. + + If, when raising to a negative power, an underflow occurs during the + division into 1, the operation is not halted at that point but continues. + \end{methoddesc} + + \begin{methoddesc}{quantize}{x, y} + Returns a value equal to \var{x} after rounding and having the + exponent of v\var{y}. + + Unlike other operations, if the length of the coefficient after the quantize + operation would be greater than precision then an + \constant{InvalidOperation} is signaled. This guarantees that, unless there + is an error condition, the exponent of the result of a quantize is always + equal to that of the right-hand operand. + + Also unlike other operations, quantize never signals Underflow, even + if the result is subnormal and inexact. + \end{methoddesc} + + \begin{methoddesc}{remainder}{x, y} + Returns the remainder from integer division. + + The sign of the result, if non-zero, is the same as that of the original + dividend. + \end{methoddesc} + + \begin{methoddesc}{remainder_near}{x, y} + Computed the modulo as either a positive or negative value depending + on which is closest to zero. For instance, + \samp{Decimal(10).remainder_near(6)} returns \code{Decimal("-2")} + which is closer to zero than \code{Decimal("4")}. + + If both are equally close, the one chosen will have the same sign + as \var{self}. + \end{methoddesc} + + \begin{methoddesc}{same_quantum}{x, y} + Test whether \var{x} and \var{y} have the same exponent or whether both are + \constant{NaN}. + \end{methoddesc} + + \begin{methoddesc}{sqrt}{} + Return the square root to full precision. + \end{methoddesc} + + \begin{methoddesc}{substract}{x, y} + Return the difference of \var{x} and \var{y}. + \end{methoddesc} + + \begin{methoddesc}{to_eng_string}{} + Convert to engineering-type string. + + Engineering notation has an exponent which is a multiple of 3, so there + are up to 3 digits left of the decimal place. For example, converts + \code{Decimal('123E+1')} to \code{Decimal("1.23E+3")} + \end{methoddesc} + + \begin{methoddesc}{to_integral}{x} + Rounds to the nearest integer, without signaling \constant{Inexact} + or \constant{Rounded}. + \end{methoddesc} + + \begin{methoddesc}{to_sci_string}{} + Converts a number to a string, using scientific notation. + \end{methoddesc} From rhettinger at users.sourceforge.net Mon Jul 5 01:37:03 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Jul 5 01:37:11 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2545 Modified Files: decimal.py Log Message: * Fixup docstrings * Make capitals default part of DefaultContext Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** decimal.py 4 Jul 2004 13:53:24 -0000 1.7 --- decimal.py 5 Jul 2004 05:36:39 -0000 1.8 *************** *** 135,139 **** import threading import copy - import math import operator --- 135,138 ---- *************** *** 2121,2126 **** capitals - If 1, 1*10^1 is printed as 1E+1. If 0, printed as 1e1 ! (Defaults to 1) ! clamp - If 1, change exponents if too high (Default 0) """ --- 2120,2124 ---- capitals - If 1, 1*10^1 is printed as 1E+1. If 0, printed as 1e1 ! _clamp - If 1, change exponents if too high (Default 0) """ *************** *** 2131,2135 **** _rounding_decision=None, Emin=None, Emax=None, ! capitals=1, _clamp=0, _ignored_flags=[]): if flags is None: --- 2129,2133 ---- _rounding_decision=None, Emin=None, Emax=None, ! capitals=None, _clamp=0, _ignored_flags=[]): if flags is None: *************** *** 2209,2213 **** def Etop(self): ! """Returns maximum exponent (= Emin - prec + 1)""" return int(self.Emax - self.prec + 1) --- 2207,2211 ---- def Etop(self): ! """Returns maximum exponent (= Emax - prec + 1)""" return int(self.Emax - self.prec + 1) *************** *** 2431,2435 **** def normalize(self, a): ! """normalize reduces its operand to its simplest form. Essentially a plus operation with all trailing zeros removed from the --- 2429,2433 ---- def normalize(self, a): ! """normalize reduces an operand to its simplest form. Essentially a plus operation with all trailing zeros removed from the *************** *** 2969,2973 **** _rounding_decision=ALWAYS_ROUND, Emax=DEFAULT_MAX_EXPONENT, ! Emin=DEFAULT_MIN_EXPONENT ) --- 2967,2972 ---- _rounding_decision=ALWAYS_ROUND, Emax=DEFAULT_MAX_EXPONENT, ! Emin=DEFAULT_MIN_EXPONENT, ! capitals=1 ) From rhettinger at users.sourceforge.net Mon Jul 5 01:52:36 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Jul 5 01:52:46 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdecimal.tex, NONE, 1.1 lib.tex, 1.226, 1.227 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4688 Modified Files: lib.tex Added Files: libdecimal.tex Log Message: Add decimal docs to the core. --- NEW FILE: libdecimal.tex --- \section{\module{decimal} --- Decimal floating point arithmetic} \declaremodule{standard}{decimal} \modulesynopsis{Implementation of the General Decimal Arithmetic Specification.} \moduleauthor{Eric Price}{eprice at tjhsst.edu} \moduleauthor{Facundo Batista}{facundo at taniquetil.com.ar} \moduleauthor{Raymond Hettinger}{python at rcn.com} \moduleauthor{Aahz}{aahz at pobox.com} \moduleauthor{Tim Peters}{tim.one at comcast.net} \sectionauthor{Raymond D. Hettinger}{python at rcn.com} \versionadded{2.4} The decimal \module{module} provides support for decimal floating point arithmetic. It offers several advantages over the \class{float()} datatype: \begin{itemize} \item Decimal numbers can be represented exactly. In contrast, numbers like \constant{1.1} do not have an exact representations in binary floating point. End users typically wound not expect \constant{1.1} to display as \constant{1.1000000000000001} as it does with binary floating point. \item The exactness carries over into arithmetic. In decimal floating point, \samp{0.1 + 0.1 + 0.1 - 0.3} is exactly equal to zero. In binary floating point, result is \constant{5.5511151231257827e-017}. While near to zero, the differences prevent reliable equality testing and differences can accumulate. For this reason, decimal would be preferred in accounting applications which have strict equality invariants. \item The decimal module incorporates notion of significant places so that \samp{1.30 + 1.20} is \constant{2.50}. The trailing zero is kept to indicate significance. This is the customary presentation for monetary applications. For multiplication, the ``schoolbook'' approach uses all the figures in the multiplicands. For instance, \samp{1.3 * 1.2} gives \constant{1.56} while \samp{1.30 * 1.20} gives \constant{1.5600}. \item Unlike hardware based binary floating point, the decimal module has a user settable precision (defaulting to 28 places) which can be as large as needed for a given problem: \begin{verbatim} >>> getcontext().prec = 6 >>> Decimal(1) / Decimal(7) Decimal("0.142857") >>> getcontext().prec = 28 >>> Decimal(1) / Decimal(7) Decimal("0.1428571428571428571428571429") \end{verbatim} \item Both binary and decimal floating point are implemented in terms of published standards. While the built-in float type exposes only a modest portion of its capabilities, the decimal module exposes all required parts of the standard. When needed, the programmer has full control over rounding and signal handling. \end{itemize} The module design is centered around three concepts: the decimal number, the context for arithmetic, and signals. A decimal number is immutable. It has a sign, coefficient digits, and an exponent. To preserve significance, the coefficient digits do not truncate trailing zeroes. Decimals also include special values such as \constant{Infinity} (the result of \samp{1 / 0}), \constant{-Infinity}, (the result of \samp{-1 / 0}), and \constant{NaN} (the result of \samp{0 / 0}). The standard also differentiates \constant{-0} from \constant{+0}. The context for arithmetic is an environment specifying precision, rounding rules, limits on exponents, flags that indicate the results of operations, and trap enablers which determine whether signals are to be treated as exceptions. Rounding options include \constant{ROUND_CEILING}, \constant{ROUND_DOWN}, \constant{ROUND_FLOOR}, \constant{ROUND_HALF_DOWN}, \constant{ROUND_HALF_EVEN}, \constant{ROUND_HALF_UP}, and \constant{ROUND_UP}. Signals are types of information that arise during the course of a computation. Depending on the needs of the application, some signals may be ignored, considered as informational, or treated as exceptions. The signals in the decimal module are: \constant{Clamped}, \constant{InvalidOperation}, \constant{ConversionSyntax}, \constant{DivisionByZero}, \constant{DivisionImpossible}, \constant{DivisionUndefined}, \constant{Inexact}, \constant{InvalidContext}, \constant{Rounded}, \constant{Subnormal}, \constant{Overflow}, and \constant{Underflow}. For each signal there is a flag and a trap enabler. When a signal is encountered, its flag incremented from zero and, then, if the trap enabler is set to one, an exception is raised. \begin{seealso} \seetext{IBM's General Decimal Arithmetic Specification, \citetitle[http://www2.hursley.ibm.com/decimal/decarith.html] {The General Decimal Arithmetic Specification}.} \seetext{IEEE standard 854-1987, \citetitle[http://www.cs.berkeley.edu/~ejr/projects/754/private/drafts/854-1987/dir.html] {Unofficial IEEE 854 Text}.} \end{seealso} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Quick-start Tutorial \label{decimal-tutorial}} The normal start to using decimals is to import the module, and then use \function{getcontext()} to view the context and, if necessary, set the context precision, rounding, or trap enablers: \begin{verbatim} >>> from decimal import * >>> getcontext() Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, setflags=[], settraps=[]) >>> getcontext().prec = 7 \end{verbatim} Decimal instances can be constructed from integers or strings. To create a Decimal from a \class{float}, first convert it to a string. This serves as an explicit reminder of the details of the conversion (including representation error). Malformed strings signal \constant{ConversionSyntax} and return a special kind of Decimal called a \constant{NaN} which stands for ``Not a number''. Positive and negative \constant{Infinity} is yet another special kind of Decimal. \begin{verbatim} >>> Decimal(10) Decimal("10") >>> Decimal('3.14') Decimal("3.14") >>> Decimal(str(2.0 ** 0.5)) Decimal("1.41421356237") >>> Decimal('Mickey Mouse') Decimal("NaN") >>> Decimal('-Infinity') Decimal("-Infinity") \end{verbatim} Creating decimals is unaffected by context precision. Their level of significance is completely determined by the number of digits input. It is the arithmetic operations that are governed by context. \begin{verbatim} >>> getcontext().prec = 6 >>> Decimal('3.0000') Decimal("3.0000") >>> Decimal('3.0') Decimal("3.0") >>> Decimal('3.1415926535') Decimal("3.1415926535") >>> Decimal('3.1415926535') + Decimal('2.7182818285') Decimal("5.85987") >>> getcontext().rounding = ROUND_UP >>> Decimal('3.1415926535') + Decimal('2.7182818285') Decimal("5.85988") \end{verbatim} Decimals interact well with much of the rest of python. Here is a small decimal floating point flying circus: \begin{verbatim} >>> data = map(Decimal, '1.34 1.87 3.45 2.35 1.00 0.03 9.25'.split()) >>> max(data) Decimal("9.25") >>> min(data) Decimal("0.03") >>> sorted(data) [Decimal("0.03"), Decimal("1.00"), Decimal("1.34"), Decimal("1.87"), Decimal("2.35"), Decimal("3.45"), Decimal("9.25")] >>> sum(data) Decimal("19.29") >>> a,b,c = data[:3] >>> str(a) '1.34' >>> float(a) 1.3400000000000001 >>> round(a, 1) 1.3 >>> int(a) 1 >>> a * 5 Decimal("6.70") >>> a * b Decimal("2.5058") >>> c % a Decimal("0.77") \end{verbatim} The \function{getcontext()} function accesses the current context. This one context is sufficient for many applications; however, for more advanced work, multiple contexts can be created using the Context() constructor. To make a new context active, use the \function{setcontext()} function. In accordance with the standard, the \module{Decimal} module provides two ready to use standard contexts, \constant{BasicContext} and \constant{ExtendedContext}. The former is especially useful for debugging because many of the traps are enabled: \begin{verbatim} >>> myothercontext = Context(prec=60, rounding=ROUND_HALF_DOWN) >>> myothercontext Context(prec=60, rounding=ROUND_HALF_DOWN, Emin=-999999999, Emax=999999999, setflags=[], settraps=[]) >>> ExtendedContext Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, setflags=[], settraps=[]) >>> setcontext(myothercontext) >>> Decimal(1) / Decimal(7) Decimal("0.142857142857142857142857142857142857142857142857142857142857") >>> setcontext(ExtendedContext) >>> Decimal(1) / Decimal(7) Decimal("0.142857143") >>> Decimal(42) / Decimal(0) Decimal("Infinity") >>> setcontext(BasicContext) >>> Decimal(42) / Decimal(0) Traceback (most recent call last): File "", line 1, in -toplevel- Decimal(42) / Decimal(0) DivisionByZero: x / 0 \end{verbatim} Besides using contexts to control precision, rounding, and trapping signals, they can be used to monitor flags which give information collected during computation. The flags remain set until explicitly cleared, so it is best to clear the flags before each set of monitored computations by using the \method{clear_flags()} method. \begin{verbatim} >>> setcontext(ExtendedContext) >>> getcontext().clear_flags() >>> Decimal(355) / Decimal(113) Decimal("3.14159292") >>> getcontext() Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, setflags=['Inexact', 'Rounded'], settraps=[]) \end{verbatim} The \var{setflags} entry shows that the rational approximation to \constant{Pi} was rounded (digits beyond the context precision were thrown away) and that the result is inexact (some of the discarded digits were non-zero). Individual traps are set using the dictionary in the \member{trap_enablers} field of a context: \begin{verbatim} >>> Decimal(1) / Decimal(0) Decimal("Infinity") >>> getcontext().trap_enablers[DivisionByZero] = 1 >>> Decimal(1) / Decimal(0) Traceback (most recent call last): File "", line 1, in -toplevel- Decimal(1) / Decimal(0) DivisionByZero: x / 0 \end{verbatim} To turn all the traps on or off all at once, use a loop. Also, the \method{dict.update()} method is useful for changing a handfull of values. \begin{verbatim} >>> getcontext.clear_flags() >>> for sig in getcontext().trap_enablers: ... getcontext().trap_enablers[sig] = 1 >>> getcontext().trap_enablers.update({Rounded:0, Inexact:0, Subnormal:0}) >>> getcontext() Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, setflags=[], settraps=['Underflow', 'DecimalException', 'Clamped', 'InvalidContext', 'InvalidOperation', 'ConversionSyntax', 'DivisionByZero', 'DivisionImpossible', 'DivisionUndefined', 'Overflow']) \end{verbatim} Applications typically set the context once at the beginning of a program and no further changes are needed. For many applications, the data resides in a resource external to the program and is converted to \class{Decimal} with a single cast inside a loop. Afterwards, decimals are as easily manipulated as other Python numeric types. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Decimal objects \label{decimal-decimal}} \begin{classdesc}{Decimal}{\optional{value \optional{, context}}} Constructs a new \class{Decimal} object based from \var{value}. \var{value} can be an integer, string, or another \class{Decimal} object. If no \var{value} is given, returns \code{Decimal("0")}. If \var{value} is a string, it should conform to the decimal numeric string syntax: \begin{verbatim} sign ::= '+' | '-' digit ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' indicator ::= 'e' | 'E' digits ::= digit [digit]... decimal-part ::= digits '.' [digits] | ['.'] digits exponent-part ::= indicator [sign] digits infinity ::= 'Infinity' | 'Inf' nan ::= 'NaN' [digits] | 'sNaN' [digits] numeric-value ::= decimal-part [exponent-part] | infinity numeric-string ::= [sign] numeric-value | [sign] nan \end{verbatim} The supplied \var{context} or, if not specified, the current context governs only the handling of mal-formed strings not conforming to the numeric string syntax. If the context traps \constant{ConversionSyntax}, an exception is raised; otherwise, the constructor returns a new Decimal with the value of \constant{NaN}. The context serves no other purpose. The number of significant digits recorded is determined solely by the \var{value} and the var{context} precision is not a factor. For example, \samp{Decimal("3.0000")} records all four zeroes even if the context precision is only three. Once constructed, \class{Decimal} objects are immutable. \end{classdesc} Decimal floating point objects share many properties with the other builtin numeric types such as \class{float} and \class{int}. All of the usual math operations and special methods apply. Likewise, decimal objects can be copied, pickled, printed, used as dictionary keys, used as set elements, compared, sorted, and coerced to another type (such as \class{float} or \class{long}). In addition to the standard numeric properties, decimal floating point objects have a number of more specialized methods: \begin{methoddesc}{adjusted}{} Return the number's adjusted exponent that results from shifting out the coefficients rightmost digits until only the lead digit remains: \code{Decimal("321e+5").adjusted()} returns seven. Used for determining the place value of the most significant digit. \end{methoddesc} \begin{methoddesc}{as_tuple}{} Returns a tuple representation of the number: \samp{(sign, digittuple, exponent)}. \end{methoddesc} \begin{methoddesc}{compare}{other\optional{, context}} Compares like \method{__cmp__()} but returns a decimal instance: \begin{verbatim} a or b is a NaN ==> Decimal("NaN") a < b ==> Decimal("-1") a == b ==> Decimal("0") a > b ==> Decimal("1") \end{verbatim} \end{methoddesc} \begin{methoddesc}{max}{other\optional{, context}} Like \samp{max(self, other)} but returns \constant{NaN} if either is a \constant{NaN}. Applies the context rounding rule before returning. \end{methoddesc} \begin{methoddesc}{min}{other\optional{, context}} Like \samp{min(self, other)} but returns \constant{NaN} if either is a \constant{NaN}. Applies the context rounding rule before returning. \end{methoddesc} \begin{methoddesc}{normalize}{\optional{context}} Normalize the number by striping the rightmost trailing zeroes and converting any result equal to \constant{Decimal("0")} to Decimal("0e0"). Used for producing a canonical value for members of an equivalence class. For example, \code{Decimal("32.100")} and \code{Decimal("0.321000e+2")} both normalize to the equivalent value \code{Decimal("32.1")} \end{methoddesc} \begin{methoddesc}{quantize} {\optional{exp \optional{, rounding\optional{, context\optional{, watchexp}}}}} Quantize makes the exponent the same as \var{exp}. Searches for a rounding method in \var{rounding}, then in \var{context}, and then in the current context. Of \var{watchexp} is set (default), then an error is returned if the resulting exponent is greater than \member{Emax} or less than \member{Etiny}. \end{methoddesc} \begin{methoddesc}{remainder_near}{other\optional{, context}} Computed the modulo as either a positive or negative value depending on which is closest to zero. For instance, \samp{Decimal(10).remainder_near(6)} returns \code{Decimal("-2")} which is closer to zero than \code{Decimal("4")}. If both are equally close, the one chosen will have the same sign as \var{self}. \end{methoddesc} \begin{methoddesc}{same_quantum{other\optional{, context}}} Test whether self and other have the same exponent or whether both are \constant{NaN}. \end{methoddesc} \begin{methoddesc}{sqrt}{\optional{context}} Return the square root to full precision. \end{methoddesc} \begin{methoddesc}{to_eng_string}{\optional{context}} Convert to engineering-type string. Engineering notation has an exponent which is a multiple of 3, so there are up to 3 digits left of the decimal place. For example, converts \code{Decimal('123E+1')} to \code{Decimal("1.23E+3")} \end{methoddesc} \begin{methoddesc}{to_integral}{\optional{rounding\optional{, context}}} Rounds to the nearest integer, without signaling \constant{Inexact} or \constant{Rounded}. If given, applies \var{rounding}; otherwise, uses the rounding method in either the supplied \var{context} or the current context. \end{methoddesc} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Context objects \label{decimal-decimal}} Contexts are environments for arithmetic operations. They govern the precision, rules for rounding, determine which signals are treated as exceptions, and set limits on the range for exponents. Each thread has its own current context which is accessed or changed using the \function{getcontext()} and \function{setcontext()} functions: \begin{funcdesc}{getcontext}{} Return the current context for the active thread. \end{funcdesc} \begin{funcdesc}{setcontext}{c} Set the current context for the active thread to \var{c}. \end{funcdesc} New contexts can formed using the \class{Context} constructor described below. In addition, the module provides three pre-made contexts: \begin{classdesc*}{BasicContext} This is a standard context defined by the General Decimal Arithmetic Specification. Precision is set to nine. Rounding is set to \constant{ROUND_HALF_UP}. All flags are cleared. All traps are enabled (treated as exceptions) except \constant{Inexact}, \constant{Rounded}, and \constant{Subnormal}. Because many of the traps are enabled, this context is useful for debugging. \end{classdesc*} \begin{classdesc*}{ExtendedContext} This is a standard context defined by the General Decimal Arithmetic Specification. Precision is set to nine. Rounding is set to \constant{ROUND_HALF_EVEN}. All flags are cleared. No traps are enabled (so that exceptions are not raised during computations). \end{classdesc*} \begin{classdesc*}{DefaultContext} This class is used by the \class{Context} constructor as a prototype for new contexts. Changing a field (such a precision) has the effect of changing the default for new contexts creating by the \class{Context} constructor. This context is most useful in multi-threaded environments. Changing one of the fields before threads are started has the effect of setting system-wide defaults. Changing the fields after threads have started is not recommended as it would require thread synchronization to prevent race conditions. In single threaded environments, it is preferable to not use this context at all. Instead, simply create contexts explicitly. This is especially important because the default values context may change between releases (with initial release having precision=28, rounding=ROUND_HALF_EVEN, cleared flags, and no traps enabled). \end{classdesc*} \begin{classdesc}{Context}{prec=None, rounding=None, trap_enablers=None, flags=None, Emin=None, Emax=None, capitals=1} Creates a new context. If a field is not specified or is \constant{None}, the default values are copied from the \constant{DefaultContext}. If the \var{flags} field is not specified or is \constant{None}, all flags are cleared. The \var{prec} field in an positive integer that sets the precision for arithmetic operations in the context. The \var{rounding} option is one of: \constant{ROUND_CEILING}, \constant{ROUND_DOWN}, \constant{ROUND_FLOOR}, \constant{ROUND_HALF_DOWN}, \constant{ROUND_HALF_EVEN}, \constant{ROUND_HALF_UP}, or \constant{ROUND_UP}. The \var{trap_enablers} and \var{flags} fields are mappings from signals to either \constant{0} or \constant{1}. The \var{Emin} and \var{Emax} fields are integers specifying the outer limits allowable for exponents. The \var{capitals} field is either \constant{0} or \constant{1} (the default). If set to \constant{1}, exponents are printed with a capital \constant{E}; otherwise, lowercase is used: \constant{Decimal('6.02e+23')}. \end{classdesc} The \class{Context} class defines several general methods as well as a large number of methods for doing arithmetic directly from the context. \begin{methoddesc}{clear_flags}{} Sets all of the flags to \constant{0}. \end{methoddesc} \begin{methoddesc}{copy}{} Returns a duplicate of the context. \end{methoddesc} \begin{methoddesc}{create_decimal}{num} Creates a new Decimal instance but using \var{self} as context. Unlike the \class{Decimal} constructor, context precision, rounding method, flags, and traps are applied to the conversion. This is useful because constants are often given to a greater precision than is needed by the application. \end{methoddesc} \begin{methoddesc}{Etiny}{} Returns a value equal to \samp{Emin - prec + 1} which is the minimum exponent value for subnormal results. When underflow occurs, the exponont is set to \constant{Etiny}. \end{methoddesc} The usual approach to working with decimals is to create Decimal instances and then apply arithmetic operations which take place within the current context for the active thread. An alternate approach is to use a context method to perform a particular computation within the given context rather than the current context. Those methods parallel those for the \class{Decimal} class and are only briefed recounted here. \begin{methoddesc}{abs}{x} Returns the absolute value of \var{x}. \end{methoddesc} \begin{methoddesc}{add}{x, y} Return the sum of \var{x} and \var{y}. \end{methoddesc} \begin{methoddesc}{compare}{x, y} Compares values numerically. Like \method{__cmp__()} but returns a decimal instance: \begin{verbatim} a or b is a NaN ==> Decimal("NaN") a < b ==> Decimal("-1") a == b ==> Decimal("0") a > b ==> Decimal("1") \end{verbatim} \end{methoddesc} \begin{methoddesc}{divide}{x, y} Return \var{x} divided by \var{y}. \end{methoddesc} \begin{methoddesc}{divide}{x, y} Divides two numbers and returns the integer part of the result. \end{methoddesc} \begin{methoddesc}{max}{x, y} Compare two values numerically and returns the maximum. If they are numerically equal then the left-hand operand is chosen as the result. \end{methoddesc} \begin{methoddesc}{min}{x, y} Compare two values numerically and returns the minimum. If they are numerically equal then the left-hand operand is chosen as the result. \end{methoddesc} \begin{methoddesc}{minus}{x} Minus corresponds to unary prefix minus in Python. \end{methoddesc} \begin{methoddesc}{multiply}{x, y} Return the product of \var{x} and \var{y}. \end{methoddesc} \begin{methoddesc}{normalize}{x} Normalize reduces an operand to its simplest form. Essentially a plus operation with all trailing zeros removed from the result. \end{methoddesc} \begin{methoddesc}{plus}{x} Minus corresponds to unary prefix plus in Python. \end{methoddesc} \begin{methoddesc}{power}{x, y\optional{, modulo}} Return \samp{x ** y} to the \var{modulo} if given. The right-hand operand must be a whole number whose integer part (after any exponent has been applied) has no more than 9 digits and whose fractional part (if any) is all zeros before any rounding. The operand may be positive, negative, or zero; if negative, the absolute value of the power is used, and the left-hand operand is inverted (divided into 1) before use. If the increased precision needed for the intermediate calculations exceeds the capabilities of the implementation then an Invalid operation condition is raised. If, when raising to a negative power, an underflow occurs during the division into 1, the operation is not halted at that point but continues. \end{methoddesc} \begin{methoddesc}{quantize}{x, y} Returns a value equal to \var{x} after rounding and having the exponent of v\var{y}. Unlike other operations, if the length of the coefficient after the quantize operation would be greater than precision then an \constant{InvalidOperation} is signaled. This guarantees that, unless there is an error condition, the exponent of the result of a quantize is always equal to that of the right-hand operand. Also unlike other operations, quantize never signals Underflow, even if the result is subnormal and inexact. \end{methoddesc} \begin{methoddesc}{remainder}{x, y} Returns the remainder from integer division. The sign of the result, if non-zero, is the same as that of the original dividend. \end{methoddesc} \begin{methoddesc}{remainder_near}{x, y} Computed the modulo as either a positive or negative value depending on which is closest to zero. For instance, \samp{Decimal(10).remainder_near(6)} returns \code{Decimal("-2")} which is closer to zero than \code{Decimal("4")}. If both are equally close, the one chosen will have the same sign as \var{self}. \end{methoddesc} \begin{methoddesc}{same_quantum}{x, y} Test whether \var{x} and \var{y} have the same exponent or whether both are \constant{NaN}. \end{methoddesc} \begin{methoddesc}{sqrt}{} Return the square root to full precision. \end{methoddesc} \begin{methoddesc}{substract}{x, y} Return the difference of \var{x} and \var{y}. \end{methoddesc} \begin{methoddesc}{to_eng_string}{} Convert to engineering-type string. Engineering notation has an exponent which is a multiple of 3, so there are up to 3 digits left of the decimal place. For example, converts \code{Decimal('123E+1')} to \code{Decimal("1.23E+3")} \end{methoddesc} \begin{methoddesc}{to_integral}{x} Rounds to the nearest integer, without signaling \constant{Inexact} or \constant{Rounded}. \end{methoddesc} \begin{methoddesc}{to_sci_string}{} Converts a number to a string, using scientific notation. \end{methoddesc} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Signals \label{decimal-signals}} Signals represent conditions that arise during computation. Each corresponds to one context flag and one context trap enabler. The context flag is incremented whenever the condition is encountered. After the computation, flags may be checked for informational purposed (for instance, to determine whether a computation was exact). After checking the flags, be sure to clear all flags before starting the next computation. If the context's trap enabler is set for the signal, then the condition causes a Python exception to be raised. For example, if the \class{DivisionByZero} trap is set, the a \exception{DivisionByZero} exception is raised upon encountering the condition. \begin{classdesc*}{Clamped} Altered an exponent to fit representation constraints. Typically, clamping occurs when an exponent falls outside the context's \member{Emin} and \member{Emax} limits. If possible, the exponent is reduced to fit by adding zeroes to the coefficient. \end{classdesc*} \begin{classdesc*}{ConversionSyntax} Trying to convert a mal-formed string such as: \code{Decimal('jump')}. Decimal converts only strings conforming to the numeric string syntax. If this signal is not trapped, returns \constant{NaN}. \end{classdesc*} \begin{classdesc*}{DecimalException} Base class for other signals. \end{classdesc*} \begin{classdesc*}{DivisionByZero} Signals the division of a non-infinite number by zero. Can occur with division, modulo division, or when raising a number to a negative power. If this signal is not trapped, return \constant{Infinity} or \constant{-Infinity} with sign determined by the inputs to the calculation. \end{classdesc*} \begin{classdesc*}{DivisionImpossible} Error performing a division operation. Caused when an intermediate result has more digits that the allowed by the current precision. If not trapped, returns \constant{NaN}. \end{classdesc*} \begin{classdesc*}{DivisionUndefined} This is a subclass of \class{DivisionByZero}. It occurs only in the context of division operations. \end{classdesc*} \begin{classdesc*}{Inexact} Indicates that rounding occurred and the result is not exact. Signals whenever non-zero digits were discarded during rounding. The rounded result is returned. The signal flag or trap is used to detect when results are inexact. \end{classdesc*} \begin{classdesc*}{InvalidContext} This is a subclass of \class{InvalidOperation}. Indicates an error within the Context object such as an unknown rounding operation. If not trapped, returns \constant{NaN}. \end{classdesc*} \begin{classdesc*}{InvalidOperation} An invalid operation was performed. Indicates that an operation was requested that does not make sense. If not trapped, returns \constant{NaN}. Possible causes include: \begin{verbatim} Infinity - Infinity 0 * Infinity Infinity / Infinity x % 0 Infinity % x x._rescale( non-integer ) sqrt(-x) and x > 0 0 ** 0 x ** (non-integer) x ** Infinity \end{verbatim} \end{classdesc*} \begin{classdesc*}{Overflow} Numerical overflow. Indicates the exponent is larger than \member{Emax} after rounding has occurred. If not trapped, the result depends on the rounding mode, either pulling inward to the largest representable finite number or rounding outward to \constant{Infinity}. In either case, \class{Inexact} and \class{Rounded} are also signaled. \end{classdesc*} \begin{classdesc*}{Rounded} Rounding occurred though possibly not information was lost. Signaled whenever rounding discards digits; even if those digits are zero (such as rounding \constant{5.00} to \constant{5.0}). If not trapped, returns the result unchanged. This signal is used to detect loss of significant digits. \end{classdesc*} \begin{classdesc*}{Subnormal} Exponent was lower than \member{Emin} prior to rounding. Occurs when an operation result is subnormal (the exponent is too small). If not trapped, returns the result unchanged. \end{classdesc*} \begin{classdesc*}{Underflow} Numerical underflow with result rounded to zero. Occurs when a subnormal result is pushed to zero by rounding. \class{Inexact} and \class{Subnormal} are also signaled. \end{classdesc*} The following table summarizes the hierarchy of signals: \begin{verbatim} exceptions.ArithmeticError(exceptions.StandardError) DecimalException Clamped DivisionByZero(DecimalException, exceptions.ZeroDivisionError) Inexact Overflow(Inexact, Rounded) Underflow(Inexact, Rounded, Subnormal) InvalidOperation ConversionSyntax DivisionImpossible DivisionUndefined(InvalidOperation, exceptions.ZeroDivisionError) InvalidContext Rounded Subnormal \end{verbatim} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Working with threads \label{decimal-threads}} The \function{getcontext()} function accesses a different \class{Context} object for each thread. Having separate contexts means that threads may make changes (such as \code{getcontext.prec=10}) without interfering with other threads and without needing mutexes. Likewise, the \function{setcontext()} function automatically assigns its target to the current thread. If \function{setcontext()} has not been called before \function{getcontext()}, then \function{getcontext()} will automatically create a new context for use in the current thread. The new context is copied from a prototype context called \var{DefaultContext}. To control the defaults so that each thread will use the same values throughout the application, directly modify the \var{DefaultContext} object. This should be done \emph{before} any threads are started so that there won't be a race condition with threads calling \function{getcontext()}. For example: \begin{verbatim} # Set application wide defaults for all threads about to be launched DefaultContext.prec=12 DefaultContext.rounding=ROUND_DOWN DefaultContext.trap_enablers=dict.fromkeys(Signals, 0) setcontext(DefaultContext) # Now start all of the threads t1.start() t2.start() t3.start() . . . \end{verbatim} Index: lib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/lib.tex,v retrieving revision 1.226 retrieving revision 1.227 diff -C2 -d -r1.226 -r1.227 *** lib.tex 31 May 2004 18:22:39 -0000 1.226 --- lib.tex 5 Jul 2004 05:52:03 -0000 1.227 *************** *** 121,124 **** --- 121,125 ---- \input{libunittest} \input{libtest} + \input{libdecimal} \input{libmath} \input{libcmath} From rhettinger at users.sourceforge.net Mon Jul 5 14:41:47 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Jul 5 14:41:54 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdecimal.tex,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10274 Modified Files: libdecimal.tex Log Message: * Added missing info on construction from a tuple. * Added a recipe section. Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdecimal.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** libdecimal.tex 5 Jul 2004 05:52:03 -0000 1.1 --- libdecimal.tex 5 Jul 2004 18:41:42 -0000 1.2 *************** *** 293,299 **** Constructs a new \class{Decimal} object based from \var{value}. ! \var{value} can be an integer, string, or another \class{Decimal} object. ! If no \var{value} is given, returns \code{Decimal("0")}. If \var{value} is ! a string, it should conform to the decimal numeric string syntax: \begin{verbatim} --- 293,300 ---- Constructs a new \class{Decimal} object based from \var{value}. ! \var{value} can be an integer, string, tuple, or another \class{Decimal} ! object. If no \var{value} is given, returns \code{Decimal("0")}. If ! \var{value} is a string, it should conform to the decimal numeric string ! syntax: \begin{verbatim} *************** *** 310,313 **** --- 311,320 ---- \end{verbatim} + If \var{value} is a \class{tuple}, it should have three components, + a sign (\constant{0} for positive or \constant{1} for negative), + a \class{tuple} of digits, and an exponent represented as an integer. + For example, \samp{Decimal((0, (1, 4, 1, 4), -3))} returns + \samp{Decimal("1.414")}. + The supplied \var{context} or, if not specified, the current context governs only the handling of mal-formed strings not conforming to the *************** *** 707,711 **** \end{classdesc*} - \begin{classdesc*}{ConversionSyntax} Trying to convert a mal-formed string such as: \code{Decimal('jump')}. --- 714,717 ---- *************** *** 715,724 **** \end{classdesc*} - \begin{classdesc*}{DecimalException} Base class for other signals. \end{classdesc*} - \begin{classdesc*}{DivisionByZero} Signals the division of a non-infinite number by zero. --- 721,728 ---- *************** *** 730,734 **** \end{classdesc*} - \begin{classdesc*}{DivisionImpossible} Error performing a division operation. Caused when an intermediate result --- 734,737 ---- *************** *** 744,748 **** \end{classdesc*} - \begin{classdesc*}{Inexact} Indicates that rounding occurred and the result is not exact. --- 747,750 ---- *************** *** 761,765 **** \end{classdesc*} - \begin{classdesc*}{InvalidOperation} An invalid operation was performed. --- 763,766 ---- *************** *** 782,786 **** \end{classdesc*} - \begin{classdesc*}{Overflow} Numerical overflow. --- 783,786 ---- *************** *** 803,807 **** \end{classdesc*} - \begin{classdesc*}{Subnormal} Exponent was lower than \member{Emin} prior to rounding. --- 803,806 ---- *************** *** 811,815 **** \end{classdesc*} - \begin{classdesc*}{Underflow} Numerical underflow with result rounded to zero. --- 810,813 ---- *************** *** 819,823 **** \end{classdesc*} - The following table summarizes the hierarchy of signals: --- 817,820 ---- *************** *** 839,842 **** --- 836,841 ---- \end{verbatim} + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Working with threads \label{decimal-threads}} *************** *** 876,882 **** ! --- 875,1002 ---- + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \subsection{Recipes \label{decimal-recipes}} + Here are some functions demonstrating ways to work with the + \class{Decimal} class: + \begin{verbatim} + from decimal import Decimal, getcontext + def moneyfmt(value, places=2, curr='$', sep=',', dp='.', pos='', neg='-'): + """Convert Decimal to a money formatted string. ! places: required number of places after the decimal point ! curr: optional currency symbol before the sign (may be blank) ! sep: optional grouping separator (comma, period, or blank) ! dp: decimal point indicator (comma or period) ! only set to blank if places is zero ! pos: optional sign for positive numbers ("+" or blank) ! neg: optional sign for negative numbers ("-" or blank) ! leave blank to separately add brackets or a trailing minus ! ! >>> d = Decimal('-1234567.8901') ! >>> moneyfmt(d) ! '-$1,234,567.89' ! >>> moneyfmt(d, places=0, curr='', sep='.', dp='') ! '-1.234.568' ! >>> '($%s)' % moneyfmt(d, curr='', neg='') ! '($1,234,567.89)' ! """ ! q = Decimal((0, (1,), -places)) # 2 places --> '0.01' ! sign, digits, exp = value.quantize(q).as_tuple() ! result = [] ! digits = map(str, digits) ! build, next = result.append, digits.pop ! for i in range(places): ! build(next()) ! build(dp) ! try: ! while 1: ! for i in range(3): ! build(next()) ! if digits: ! build(sep) ! except IndexError: ! pass ! build(curr) ! if sign: ! build(neg) ! else: ! build(pos) ! result.reverse() ! return ''.join(result) ! ! def pi(): ! "Compute Pi to the current precision" ! getcontext().prec += 9 # extra digits for intermediate steps ! one = Decimal(1) # substitute "one=1.0" for regular floats ! lastc, t, c, n, na, d, da = 0*one, 3*one, 3*one, 1, 0, 0, 24*one ! while c != lastc: ! lastc = c ! n, na = n+na, na+8 ! d, da = d+da, da+32 ! t = (t * n) / d ! c += t ! getcontext().prec -= 10 ! return c ! ! def exp(x): ! """Return e raised to the power of x. ! ! >>> print exp(Decimal(1)) ! 2.718281828459045235360287471352662498 ! >>> print exp(Decimal(2)) ! 7.389056098930650227230427460575007813 ! """ ! getcontext().prec += 9 # extra digits for intermediate steps ! one = Decimal(1) # substitute "one=1.0" for regular floats ! i, laste, e, fact, num = 0*one, 0*one, one, one, one ! while e != laste: ! laste = e ! i += 1 ! fact *= i ! num *= x ! e += num / fact ! getcontext().prec -= 9 ! return e ! ! def cos(x): ! """Return the cosine of x as measured in radians. ! ! >>> print cos(Decimal('0.5')) ! 0.8775825618903727161162815826038296521 ! """ ! getcontext().prec += 9 # extra digits for intermediate steps ! one = Decimal(1) # substitute "one=1.0" for regular floats ! i, laste, e, fact, num, sign = 0*one, 0*one, one, one, one, one ! while e != laste: ! laste = e ! i += 2 ! fact *= i * (i-1) ! num *= x * x ! sign *= -1 ! e += num / fact * sign ! getcontext().prec -= 9 ! return e ! ! def sin(x): ! """Return the cosine of x as measured in radians. ! ! >>> print sin(Decimal('0.5')) ! 0.4794255386042030002732879352155713880 ! """ ! getcontext().prec += 9 # extra digits for intermediate steps ! one = Decimal(1) # substitute "one=1.0" for regular floats ! i, laste, e, fact, num, sign = one, 0*one, x, one, x, one ! while e != laste: ! laste = e ! i += 2 ! fact *= i * (i-1) ! num *= x * x ! sign *= -1 ! e += num / fact * sign ! getcontext().prec -= 9 ! return e ! ! \end{verbatim} From rhettinger at users.sourceforge.net Mon Jul 5 14:48:25 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Jul 5 14:48:28 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11336 Modified Files: decimal.py Log Message: * Update the todo list. * Make ConversionSyntax signals get trapped by default. Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** decimal.py 5 Jul 2004 05:36:39 -0000 1.8 --- decimal.py 5 Jul 2004 18:48:22 -0000 1.9 *************** *** 10,14 **** # Todo: ! # Provide a clean way of attaching monetary format representations --- 10,14 ---- # Todo: ! # Add rich comparisons for equality testing with other types *************** *** 2970,2973 **** --- 2970,2974 ---- capitals=1 ) + DefaultContext.trap_enablers.update({ConversionSyntax : 1}) # Pre-made alternate contexts offered by the specification From rhettinger at users.sourceforge.net Mon Jul 5 14:49:41 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Jul 5 14:49:45 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_decimal.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11608 Modified Files: test_decimal.py Log Message: Test the logic for int(d). Index: test_decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decimal.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_decimal.py 3 Jul 2004 12:26:21 -0000 1.3 --- test_decimal.py 5 Jul 2004 18:49:38 -0000 1.4 *************** *** 1059,1062 **** --- 1059,1072 ---- self.assertEqual(d, e) + def test_int(self): + data = '1.0 1.1 1.9 2.0 0.0 -1.0 -1.1 -1.9 -2.0'.split() + for s in data: + # should work the same as for floats + self.assertEqual(int(Decimal(s)), int(float(s))) + # should work the same as ROUND_DOWN + d = Decimal(s) + r = Context(prec=1, rounding=ROUND_DOWN).create_decimal(s) + self.assertEqual(Decimal(int(d)), r) + class ContextAPItests(unittest.TestCase): From rhettinger at users.sourceforge.net Mon Jul 5 14:56:05 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Jul 5 14:56:07 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdecimal.tex,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12961 Modified Files: libdecimal.tex Log Message: Fix typo Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdecimal.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** libdecimal.tex 5 Jul 2004 18:41:42 -0000 1.2 --- libdecimal.tex 5 Jul 2004 18:56:03 -0000 1.3 *************** *** 939,943 **** t = (t * n) / d c += t ! getcontext().prec -= 10 return c --- 939,943 ---- t = (t * n) / d c += t ! getcontext().prec -= 9 return c From rhettinger at users.sourceforge.net Tue Jul 6 03:55:17 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jul 6 03:55:20 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdecimal.tex,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22699 Modified Files: libdecimal.tex Log Message: Demonstrate how to round final result. Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdecimal.tex,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** libdecimal.tex 5 Jul 2004 21:13:28 -0000 1.6 --- libdecimal.tex 6 Jul 2004 01:55:14 -0000 1.7 *************** *** 933,939 **** >>> print pi() ! 3.141592653589793238462643383279502887 """ ! getcontext().prec += 9 # extra digits for intermediate steps three = Decimal(3) # substitute "three=3.0" for regular floats lastc, t, c, n, na, d, da = 0, three, 3, 1, 0, 0, 24 --- 933,939 ---- >>> print pi() ! 3.141592653589793238462643383 """ ! getcontext().prec += 2 # extra digits for intermediate steps three = Decimal(3) # substitute "three=3.0" for regular floats lastc, t, c, n, na, d, da = 0, three, 3, 1, 0, 0, 24 *************** *** 944,949 **** t = (t * n) / d c += t ! getcontext().prec -= 9 ! return c def exp(x): --- 944,949 ---- t = (t * n) / d c += t ! getcontext().prec -= 2 ! return c + 0 def exp(x): *************** *** 951,957 **** >>> print exp(Decimal(1)) ! 2.718281828459045235360287471352662498 >>> print exp(Decimal(2)) ! 7.389056098930650227230427460575007813 >>> print exp(2.0) 7.38905609893 --- 951,957 ---- >>> print exp(Decimal(1)) ! 2.718281828459045235360287471 >>> print exp(Decimal(2)) ! 7.389056098930650227230427461 >>> print exp(2.0) 7.38905609893 *************** *** 959,963 **** (7.38905609893+0j) """ ! getcontext().prec += 9 # extra digits for intermediate steps i, laste, e, fact, num = 0, 0, 1, 1, 1 while e != laste: --- 959,963 ---- (7.38905609893+0j) """ ! getcontext().prec += 2 # extra digits for intermediate steps i, laste, e, fact, num = 0, 0, 1, 1, 1 while e != laste: *************** *** 967,972 **** num *= x e += num / fact ! getcontext().prec -= 9 ! return e def cos(x): --- 967,972 ---- num *= x e += num / fact ! getcontext().prec -= 2 ! return e + 0 def cos(x): *************** *** 974,978 **** >>> print cos(Decimal('0.5')) ! 0.8775825618903727161162815826038296521 >>> print cos(0.5) 0.87758256189 --- 974,978 ---- >>> print cos(Decimal('0.5')) ! 0.8775825618903727161162815826 >>> print cos(0.5) 0.87758256189 *************** *** 980,984 **** (0.87758256189+0j) """ ! getcontext().prec += 9 # extra digits for intermediate steps i, laste, e, fact, num, sign = 0, 0, 1, 1, 1, 1 while e != laste: --- 980,984 ---- (0.87758256189+0j) """ ! getcontext().prec += 2 # extra digits for intermediate steps i, laste, e, fact, num, sign = 0, 0, 1, 1, 1, 1 while e != laste: *************** *** 989,994 **** sign *= -1 e += num / fact * sign ! getcontext().prec -= 9 ! return e def sin(x): --- 989,994 ---- sign *= -1 e += num / fact * sign ! getcontext().prec -= 2 ! return e + 0 def sin(x): *************** *** 996,1000 **** >>> print sin(Decimal('0.5')) ! 0.4794255386042030002732879352155713880 >>> print sin(0.5) 0.479425538604 --- 996,1000 ---- >>> print sin(Decimal('0.5')) ! 0.4794255386042030002732879352 >>> print sin(0.5) 0.479425538604 *************** *** 1002,1006 **** (0.479425538604+0j) """ ! getcontext().prec += 9 # extra digits for intermediate steps i, laste, e, fact, num, sign = 1, 0, x, 1, x, 1 while e != laste: --- 1002,1006 ---- (0.479425538604+0j) """ ! getcontext().prec += 2 # extra digits for intermediate steps i, laste, e, fact, num, sign = 1, 0, x, 1, x, 1 while e != laste: *************** *** 1011,1016 **** sign *= -1 e += num / fact * sign ! getcontext().prec -= 9 ! return e \end{verbatim} --- 1011,1016 ---- sign *= -1 e += num / fact * sign ! getcontext().prec -= 2 ! return e + 0 \end{verbatim} From rhettinger at users.sourceforge.net Tue Jul 6 03:15:36 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jul 6 03:55:22 2004 Subject: [Python-checkins] python/nondist/peps pep-0000.txt, 1.273, 1.274 pep-0327.txt, 1.5, 1.6 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16890 Modified Files: pep-0000.txt pep-0327.txt Log Message: Mark PEP327 (decimal floating point) as approved and final. Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.273 retrieving revision 1.274 diff -C2 -d -r1.273 -r1.274 *** pep-0000.txt 28 May 2004 01:45:32 -0000 1.273 --- pep-0000.txt 6 Jul 2004 01:15:33 -0000 1.274 *************** *** 122,126 **** S 324 popen5 - New POSIX process module Astrand S 325 Resource-Release Support for Generators Pedroni - S 327 Decimal Data Type Batista S 330 Python Bytecode Verification Pelletier S 754 IEEE 754 Floating Point Special Values Warnes --- 122,125 ---- *************** *** 166,169 **** --- 165,169 ---- SF 311 Simplified GIL Acquisition for Extensions Hammond SF 322 Reverse Iteration Hettinger + SF 327 Decimal Data Type Batista Empty PEPs (or containing only an abstract) *************** *** 350,354 **** S 325 Resource-Release Support for Generators Pedroni SR 326 A Case for Top and Bottom Values Carlson, Reedy ! S 327 Decimal Data Type Batista SA 328 Imports: Multi-Line and Absolute/Relative Aahz SR 329 Treating Builtins as Constants in the Standard Library Hettinger --- 350,354 ---- S 325 Resource-Release Support for Generators Pedroni SR 326 A Case for Top and Bottom Values Carlson, Reedy ! SF 327 Decimal Data Type Batista SA 328 Imports: Multi-Line and Absolute/Relative Aahz SR 329 Treating Builtins as Constants in the Standard Library Hettinger Index: pep-0327.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0327.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pep-0327.txt 30 Jun 2004 04:46:47 -0000 1.5 --- pep-0327.txt 6 Jul 2004 01:15:33 -0000 1.6 *************** *** 4,8 **** Last-Modified: $Date$ Author: Facundo Batista ! Status: Draft Type: Standards Track Content-Type: text/x-rst --- 4,8 ---- Last-Modified: $Date$ Author: Facundo Batista ! Status: Final Type: Standards Track Content-Type: text/x-rst From rhettinger at users.sourceforge.net Tue Jul 6 00:53:06 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jul 6 03:55:25 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_decimal.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24143/test Modified Files: test_decimal.py Log Message: * Add __eq__ and __ne__ so that things like list.index() work properly for lists of mixed types. * Test that sort works. Index: test_decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decimal.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_decimal.py 5 Jul 2004 18:49:38 -0000 1.4 --- test_decimal.py 5 Jul 2004 22:53:03 -0000 1.5 *************** *** 34,37 **** --- 34,38 ---- from test.test_support import TestSkipped, run_unittest, run_doctest, is_resource_enabled import threading + import random # Tests are built around these assumed context defaults *************** *** 842,856 **** #a Decimal and uncomparable ! try: da == 'ugly' ! except TypeError: pass ! else: self.fail('Did not raised an error!') ! ! try: da == '32.7' ! except TypeError: pass ! else: self.fail('Did not raised an error!') ! try: da == object ! except TypeError: pass ! else: self.fail('Did not raised an error!') def test_copy_and_deepcopy_methods(self): --- 843,857 ---- #a Decimal and uncomparable ! self.assertNotEqual(da, 'ugly') ! self.assertNotEqual(da, 32.7) ! self.assertNotEqual(da, object()) ! self.assertNotEqual(da, object) ! # sortable ! a = map(Decimal, xrange(100)) ! b = a[:] ! random.shuffle(a) ! a.sort() ! self.assertEqual(a, b) def test_copy_and_deepcopy_methods(self): *************** *** 1079,1082 **** --- 1080,1087 ---- self.assertEqual(v1, v2) + def test_equality_with_other_types(self): + self.assert_(Decimal(10) in ['a', 1.0, Decimal(10), (1,2), {}]) + self.assert_(Decimal(10) not in ['a', 1.0, (1,2), {}]) + def test_main(arith=False, verbose=None): """ Execute the tests. From rhettinger at users.sourceforge.net Tue Jul 6 00:53:05 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jul 6 03:55:25 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24143 Modified Files: decimal.py Log Message: * Add __eq__ and __ne__ so that things like list.index() work properly for lists of mixed types. * Test that sort works. Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** decimal.py 5 Jul 2004 18:48:22 -0000 1.9 --- decimal.py 5 Jul 2004 22:53:02 -0000 1.10 *************** *** 9,16 **** - # Todo: - # Add rich comparisons for equality testing with other types - - """ This is a Py2.3 implementation of decimal floating point arithmetic based on --- 9,12 ---- *************** *** 645,648 **** --- 641,654 ---- return 1 + def __eq__(self, other): + if not isinstance(other, (Decimal, int, long)): + return False + return self.__cmp__(other) == 0 + + def __ne__(self, other): + if not isinstance(other, (Decimal, int, long)): + return True + return self.__cmp__(other) != 0 + def compare(self, other, context=None): """Compares one to another. From rhettinger at users.sourceforge.net Mon Jul 5 23:13:31 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jul 6 03:55:26 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdecimal.tex,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5645 Modified Files: libdecimal.tex Log Message: Expand examples to show polymorphism Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdecimal.tex,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** libdecimal.tex 5 Jul 2004 20:27:53 -0000 1.5 --- libdecimal.tex 5 Jul 2004 21:13:28 -0000 1.6 *************** *** 936,940 **** """ getcontext().prec += 9 # extra digits for intermediate steps ! three = Decimal(3) # substitute "three=3.0" for regular floats lastc, t, c, n, na, d, da = 0, three, 3, 1, 0, 0, 24 while c != lastc: --- 936,940 ---- """ getcontext().prec += 9 # extra digits for intermediate steps ! three = Decimal(3) # substitute "three=3.0" for regular floats lastc, t, c, n, na, d, da = 0, three, 3, 1, 0, 0, 24 while c != lastc: *************** *** 948,952 **** def exp(x): ! """Return e raised to the power of x. >>> print exp(Decimal(1)) --- 948,952 ---- def exp(x): ! """Return e raised to the power of x. Result type matches input type. >>> print exp(Decimal(1)) *************** *** 954,957 **** --- 954,961 ---- >>> print exp(Decimal(2)) 7.389056098930650227230427460575007813 + >>> print exp(2.0) + 7.38905609893 + >>> print exp(2+0j) + (7.38905609893+0j) """ getcontext().prec += 9 # extra digits for intermediate steps *************** *** 971,974 **** --- 975,982 ---- >>> print cos(Decimal('0.5')) 0.8775825618903727161162815826038296521 + >>> print cos(0.5) + 0.87758256189 + >>> print cos(0.5+0j) + (0.87758256189+0j) """ getcontext().prec += 9 # extra digits for intermediate steps *************** *** 989,992 **** --- 997,1004 ---- >>> print sin(Decimal('0.5')) 0.4794255386042030002732879352155713880 + >>> print sin(0.5) + 0.479425538604 + >>> print sin(0.5+0j) + (0.479425538604+0j) """ getcontext().prec += 9 # extra digits for intermediate steps From rhettinger at users.sourceforge.net Mon Jul 5 22:27:55 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jul 6 03:55:29 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdecimal.tex,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29616 Modified Files: libdecimal.tex Log Message: Simplify examples. Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdecimal.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** libdecimal.tex 5 Jul 2004 20:17:13 -0000 1.4 --- libdecimal.tex 5 Jul 2004 20:27:53 -0000 1.5 *************** *** 936,941 **** """ getcontext().prec += 9 # extra digits for intermediate steps ! one = Decimal(1) # substitute "one=1.0" for regular floats ! lastc, t, c, n, na, d, da = 0*one, 3*one, 3*one, 1, 0, 0, 24*one while c != lastc: lastc = c --- 936,941 ---- """ getcontext().prec += 9 # extra digits for intermediate steps ! three = Decimal(3) # substitute "three=3.0" for regular floats ! lastc, t, c, n, na, d, da = 0, three, 3, 1, 0, 0, 24 while c != lastc: lastc = c *************** *** 956,960 **** """ getcontext().prec += 9 # extra digits for intermediate steps - one = Decimal(1) # substitute "one=1.0" for regular floats i, laste, e, fact, num = 0, 0, 1, 1, 1 while e != laste: --- 956,959 ---- *************** *** 974,978 **** """ getcontext().prec += 9 # extra digits for intermediate steps - one = Decimal(1) # substitute "one=1.0" for regular floats i, laste, e, fact, num, sign = 0, 0, 1, 1, 1, 1 while e != laste: --- 973,976 ---- *************** *** 993,997 **** """ getcontext().prec += 9 # extra digits for intermediate steps - one = Decimal(1) # substitute "one=1.0" for regular floats i, laste, e, fact, num, sign = 1, 0, x, 1, x, 1 while e != laste: --- 991,994 ---- From rhettinger at users.sourceforge.net Mon Jul 5 22:17:15 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jul 6 03:55:30 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdecimal.tex,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27972 Modified Files: libdecimal.tex Log Message: Doc tested the recipes. Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdecimal.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** libdecimal.tex 5 Jul 2004 18:56:03 -0000 1.3 --- libdecimal.tex 5 Jul 2004 20:17:13 -0000 1.4 *************** *** 883,886 **** --- 883,887 ---- \begin{verbatim} from decimal import Decimal, getcontext + getcontext().prec = 28 def moneyfmt(value, places=2, curr='$', sep=',', dp='.', pos='', neg='-'): *************** *** 929,933 **** def pi(): ! "Compute Pi to the current precision" getcontext().prec += 9 # extra digits for intermediate steps one = Decimal(1) # substitute "one=1.0" for regular floats --- 930,938 ---- def pi(): ! """Compute Pi to the current precision. ! ! >>> print pi() ! 3.141592653589793238462643383279502887 ! """ getcontext().prec += 9 # extra digits for intermediate steps one = Decimal(1) # substitute "one=1.0" for regular floats *************** *** 952,956 **** getcontext().prec += 9 # extra digits for intermediate steps one = Decimal(1) # substitute "one=1.0" for regular floats ! i, laste, e, fact, num = 0*one, 0*one, one, one, one while e != laste: laste = e --- 957,961 ---- getcontext().prec += 9 # extra digits for intermediate steps one = Decimal(1) # substitute "one=1.0" for regular floats ! i, laste, e, fact, num = 0, 0, 1, 1, 1 while e != laste: laste = e *************** *** 970,974 **** getcontext().prec += 9 # extra digits for intermediate steps one = Decimal(1) # substitute "one=1.0" for regular floats ! i, laste, e, fact, num, sign = 0*one, 0*one, one, one, one, one while e != laste: laste = e --- 975,979 ---- getcontext().prec += 9 # extra digits for intermediate steps one = Decimal(1) # substitute "one=1.0" for regular floats ! i, laste, e, fact, num, sign = 0, 0, 1, 1, 1, 1 while e != laste: laste = e *************** *** 989,993 **** getcontext().prec += 9 # extra digits for intermediate steps one = Decimal(1) # substitute "one=1.0" for regular floats ! i, laste, e, fact, num, sign = one, 0*one, x, one, x, one while e != laste: laste = e --- 994,998 ---- getcontext().prec += 9 # extra digits for intermediate steps one = Decimal(1) # substitute "one=1.0" for regular floats ! i, laste, e, fact, num, sign = 1, 0, x, 1, x, 1 while e != laste: laste = e *************** *** 998,1002 **** e += num / fact * sign getcontext().prec -= 9 ! return e \end{verbatim} --- 1003,1007 ---- e += num / fact * sign getcontext().prec -= 9 ! return e \end{verbatim} From rhettinger at users.sourceforge.net Tue Jul 6 15:44:43 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jul 6 15:44:46 2004 Subject: [Python-checkins] python/dist/src/Python bltinmodule.c,2.310,2.311 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9136/Python Modified Files: bltinmodule.c Log Message: * Fix missing return after error message is set. * Add a test case that would have caught it. Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.310 retrieving revision 2.311 diff -C2 -d -r2.310 -r2.311 *** bltinmodule.c 2 Jul 2004 06:41:07 -0000 2.310 --- bltinmodule.c 6 Jul 2004 13:44:40 -0000 2.311 *************** *** 460,464 **** if (locals != Py_None && !PyMapping_Check(locals)) { PyErr_SetString(PyExc_TypeError, "locals must be a mapping"); ! return NULL; } if (globals != Py_None && !PyDict_Check(globals)) { --- 460,464 ---- if (locals != Py_None && !PyMapping_Check(locals)) { PyErr_SetString(PyExc_TypeError, "locals must be a mapping"); ! return NULL; } if (globals != Py_None && !PyDict_Check(globals)) { *************** *** 466,469 **** --- 466,470 ---- "globals must be a real dict; try eval(expr, {}, mapping)" : "globals must be a dict"); + return NULL; } if (globals == Py_None) { From rhettinger at users.sourceforge.net Tue Jul 6 15:44:43 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jul 6 15:44:47 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_builtin.py, 1.30, 1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9136/Lib/test Modified Files: test_builtin.py Log Message: * Fix missing return after error message is set. * Add a test case that would have caught it. Index: test_builtin.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_builtin.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** test_builtin.py 2 Jul 2004 06:41:05 -0000 1.30 --- test_builtin.py 6 Jul 2004 13:44:41 -0000 1.31 *************** *** 282,285 **** --- 282,286 ---- self.assertEqual(eval('globals()', g, m), g) self.assertEqual(eval('locals()', g, m), m) + self.assertRaises(TypeError, eval, 'a', m) # Verify that dict subclasses work as well From bwarsaw at users.sourceforge.net Tue Jul 6 18:48:27 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Tue Jul 6 18:48:31 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_socket.py, 1.70, 1.71 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12991 Modified Files: test_socket.py Log Message: testGetServBy(): Use services that should be available both on *nix and Windows (XP at least ;). Test in this order: echo, daytime, domain. Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** test_socket.py 28 Jun 2004 00:50:37 -0000 1.70 --- test_socket.py 6 Jul 2004 16:48:25 -0000 1.71 *************** *** 290,294 **** # I've ordered this by protocols that have both a tcp and udp # protocol, at least for modern Linuxes. ! for service in ('ssh', 'www', 'echo', 'imap2'): try: port = socket.getservbyname(service, 'tcp') --- 290,294 ---- # I've ordered this by protocols that have both a tcp and udp # protocol, at least for modern Linuxes. ! for service in ('echo', 'daytime', 'domain'): try: port = socket.getservbyname(service, 'tcp') From gvanrossum at users.sourceforge.net Tue Jul 6 19:52:36 2004 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue Jul 6 19:52:40 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1023,1.1024 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26264 Modified Files: NEWS Log Message: Add msg for bug #981530 (shutil.rmtree). Somehow that got missed in the checkin. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1023 retrieving revision 1.1024 diff -C2 -d -r1.1023 -r1.1024 *** NEWS 4 Jul 2004 15:41:59 -0000 1.1023 --- NEWS 6 Jul 2004 17:52:32 -0000 1.1024 *************** *** 360,363 **** --- 360,367 ---- Library ------- + + - Bug #981530: Fix UnboundLocalError in shutil.rmtree(). This affects + the documented behavior: the function passed to the onerror() + handler can now also be os.listdir. - Bug #754449: threading.Thread objects no longer mask exceptions raised during From gvanrossum at users.sourceforge.net Tue Jul 6 19:55:28 2004 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue Jul 6 19:55:31 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.128, 1.831.4.129 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26763 Modified Files: Tag: release23-maint NEWS Log Message: Add msg for bug #981530 (shutil.rmtree). Somehow that got missed in the checkin. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.128 retrieving revision 1.831.4.129 diff -C2 -d -r1.831.4.128 -r1.831.4.129 *** NEWS 3 Jul 2004 19:58:58 -0000 1.831.4.128 --- NEWS 6 Jul 2004 17:55:25 -0000 1.831.4.129 *************** *** 40,43 **** --- 40,47 ---- Library ------- + + - Bug #981530: Fix UnboundLocalError in shutil.rmtree(). This affects + the documented behavior: the function passed to the onerror() + handler can now also be os.listdir. - Bug #754449: threading.Thread will no longer mask exceptions raised during From theller at users.sourceforge.net Tue Jul 6 21:23:31 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Tue Jul 6 21:23:38 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils/command bdist_wininst.py, 1.48, 1.49 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11947 Modified Files: bdist_wininst.py Log Message: Fix SF#983164. Patch from Mark Hammond: bdist_wininst attempts to use the correct MSVC runtime for the current version of Python. This doesn't work correctly when --target-version is set. In that case, bdist_wininst still uses the *current* sys.version (ie, 2.4) rather than the version specified as --target-version. Thus, the msvc7 runtime based executable stub is *always* used. This patch "hard-codes" knowledge of earlier Python versions, providing the correct result when Python 2.4 is used to build Python 2.3 and earlier distributions. Remove the short variant (-v) of the --target-version command line options, it conflicts with the --verbose/-v standard distutils switch. Index: bdist_wininst.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_wininst.py,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** bdist_wininst.py 20 Feb 2004 19:38:50 -0000 1.48 --- bdist_wininst.py 6 Jul 2004 19:23:27 -0000 1.49 *************** *** 25,29 **** "keep the pseudo-installation tree around after " + "creating the distribution archive"), ! ('target-version=', 'v', "require a specific python version" + " on the target system"), --- 25,29 ---- "keep the pseudo-installation tree around after " + "creating the distribution archive"), ! ('target-version=', None, "require a specific python version" + " on the target system"), *************** *** 266,274 **** def get_exe_bytes (self): from distutils.msvccompiler import get_build_version # wininst-x.y.exe is in the same directory as this file directory = os.path.dirname(__file__) # we must use a wininst-x.y.exe built with the same C compiler # used for python. XXX What about mingw, borland, and so on? ! filename = os.path.join(directory, "wininst-%s.exe" % get_build_version()) return open(filename, "rb").read() # class bdist_wininst --- 266,298 ---- def get_exe_bytes (self): from distutils.msvccompiler import get_build_version + # If a target-version other than the current version has been + # specified, then using the MSVC version from *this* build is no good. + # Without actually finding and executing the target version and parsing + # its sys.version, we just hard-code our knowledge of old versions. + # NOTE: Possible alternative is to allow "--target-version" to + # specify a Python executable rather than a simple version string. + # We can then execute this program to obtain any info we need, such + # as the real sys.version string for the build. + cur_version = get_python_version() + if self.target_version and self.target_version != cur_version: + # If the target version is *later* than us, then we assume they + # use what we use + # string compares seem wrong, but are what sysconfig.py itself uses + if self.target_version > cur_version: + bv = get_build_version() + else: + if self.target_version < "2.4": + bv = "6" + else: + bv = "7.1" + else: + # for current version - use authoritative check. + bv = get_build_version() + # wininst-x.y.exe is in the same directory as this file directory = os.path.dirname(__file__) # we must use a wininst-x.y.exe built with the same C compiler # used for python. XXX What about mingw, borland, and so on? ! filename = os.path.join(directory, "wininst-%s.exe" % bv) return open(filename, "rb").read() # class bdist_wininst From montanaro at users.sourceforge.net Tue Jul 6 23:53:30 2004 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Tue Jul 6 23:53:33 2004 Subject: [Python-checkins] python/dist/src/Lib/idlelib PyShell.py,1.89,1.90 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9512 Modified Files: PyShell.py Log Message: whitespace normalization Index: PyShell.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/PyShell.py,v retrieving revision 1.89 retrieving revision 1.90 diff -C2 -d -r1.89 -r1.90 *** PyShell.py 4 Jul 2004 01:25:56 -0000 1.89 --- PyShell.py 6 Jul 2004 21:53:27 -0000 1.90 *************** *** 835,840 **** def set_warning_stream(self, stream): ! global warning_stream ! warning_stream = stream def get_warning_stream(self): --- 835,840 ---- def set_warning_stream(self, stream): ! global warning_stream ! warning_stream = stream def get_warning_stream(self): From tim_one at users.sourceforge.net Wed Jul 7 04:32:39 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Jul 7 04:32:43 2004 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.236,1.237 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27357/Doc/tut Modified Files: tut.tex Log Message: Typo repair. Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.236 retrieving revision 1.237 diff -C2 -d -r1.236 -r1.237 *** tut.tex 1 Jul 2004 14:26:31 -0000 1.236 --- tut.tex 7 Jul 2004 02:32:36 -0000 1.237 *************** *** 5487,5491 **** if you simply round the display of your final results to the number of decimal digits you expect. \function{str()} usually suffices, and for ! finer control see the discussion of Pythons's \code{\%} format operator: the \code{\%g}, \code{\%f} and \code{\%e} format codes supply flexible and easy ways to round float results for display. --- 5487,5491 ---- if you simply round the display of your final results to the number of decimal digits you expect. \function{str()} usually suffices, and for ! finer control see the discussion of Python's \code{\%} format operator: the \code{\%g}, \code{\%f} and \code{\%e} format codes supply flexible and easy ways to round float results for display. From tim_one at users.sourceforge.net Wed Jul 7 04:46:05 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Jul 7 04:46:09 2004 Subject: [Python-checkins] python/dist/src/Misc README.valgrind,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28795/Misc Modified Files: README.valgrind Log Message: Made the explanation more accurate; trimmed trailing whitespace; fixed a typo. Index: README.valgrind =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/README.valgrind,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** README.valgrind 6 Jun 2004 19:58:40 -0000 1.1 --- README.valgrind 7 Jul 2004 02:46:03 -0000 1.2 *************** *** 1,23 **** This document describes some caveats about the use of Valgrind with ! Python. Valgrind is used periodically by Python developers to try to ensure there are no memory leaks or invalid memory reads/writes. If you don't want to read about the details of using Valgrind, there ! are still two things you must do to suppress the warnings. First, you must use a suppressions file. One is supplied in Misc/valgrind-python.supp. Second, you must do one of the following: * Uncomment Py_USING_MEMORY_DEBUGGER in Objects/obmalloc.c, ! then rebuild Python ! * Uncomment the lines in Misc/valgrind-python.supp that suppress the warnings for PyObject_Free and PyObject_Realloc Details: -------- ! Python uses its own allocation scheme on top of malloc called PyMalloc. ! Valgrind my show some unexpected results when PyMalloc is used. Starting with Python 2.3, PyMalloc is used by default. You can disable PyMalloc when configuring python by adding the --without-pymalloc option. ! If you disable PyMalloc, most of the information in this document and the supplied suppressions file will not be useful. --- 1,25 ---- This document describes some caveats about the use of Valgrind with ! Python. Valgrind is used periodically by Python developers to try to ensure there are no memory leaks or invalid memory reads/writes. If you don't want to read about the details of using Valgrind, there ! are still two things you must do to suppress the warnings. First, you must use a suppressions file. One is supplied in Misc/valgrind-python.supp. Second, you must do one of the following: * Uncomment Py_USING_MEMORY_DEBUGGER in Objects/obmalloc.c, ! then rebuild Python ! * Uncomment the lines in Misc/valgrind-python.supp that suppress the warnings for PyObject_Free and PyObject_Realloc Details: -------- ! Python uses its own small-object allocation scheme on top of malloc, ! called PyMalloc. ! ! Valgrind may show some unexpected results when PyMalloc is used. Starting with Python 2.3, PyMalloc is used by default. You can disable PyMalloc when configuring python by adding the --without-pymalloc option. ! If you disable PyMalloc, most of the information in this document and the supplied suppressions file will not be useful. *************** *** 33,37 **** PyMalloc needs to know whether an arbitrary address is one ! that's managed by it, or is managed by the system malloc. The current scheme allows this to be determined in constant time, regardless of how many memory areas are under pymalloc's --- 35,39 ---- PyMalloc needs to know whether an arbitrary address is one ! that's managed by it, or is managed by the system malloc. The current scheme allows this to be determined in constant time, regardless of how many memory areas are under pymalloc's *************** *** 39,48 **** The memory pymalloc manages itself is in one or more "arenas", ! each a large contiguous memory area obtained from malloc. ! The base address of each arena is saved by pymalloc ! in a vector, and a field at the start of each arena contains ! the index of that arena's base address in that vector. ! Given an arbitrary address, pymalloc computes the arena base address corresponding to it, then looks at "the index" stored near there. If the index read up is out of bounds for the --- 41,51 ---- The memory pymalloc manages itself is in one or more "arenas", ! each a large contiguous memory area obtained from malloc. ! The base address of each arena is saved by pymalloc ! in a vector. Each arena is carved into "pools", and a field at ! the start of each pool contains the index of that pool's arena's ! base address in that vector. ! Given an arbitrary address, pymalloc computes the pool base address corresponding to it, then looks at "the index" stored near there. If the index read up is out of bounds for the *************** *** 56,67 **** to ! the computed arena address ! pymalloc controls this arena if and only if they're equal. It doesn't matter whether the memory pymalloc reads up ("the index") is initialized. If it's not initialized, then whatever trash gets read up will lead pymalloc to conclude ! (correctly) that the address isn't controlled by it. This determination has to be made on every call to one of --- 59,73 ---- to ! the arbitrary address pymalloc is investigating ! pymalloc controls this arbitrary address if and only if it lies ! in the arena the address's pool's index claims it lies in. It doesn't matter whether the memory pymalloc reads up ("the index") is initialized. If it's not initialized, then whatever trash gets read up will lead pymalloc to conclude ! (correctly) that the address isn't controlled by it, either ! because the index is out of bounds, or the index is in bounds ! but the arena it represents doesn't contain the address. This determination has to be made on every call to one of From theller at users.sourceforge.net Wed Jul 7 09:34:42 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Wed Jul 7 09:34:45 2004 Subject: [Python-checkins] python/dist/src/PC/bdist_wininst install.c, 1.6, 1.7 Message-ID: Update of /cvsroot/python/python/dist/src/PC/bdist_wininst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3918 Modified Files: install.c Log Message: Remove the annoing and useless messagebox asking about overwriting files. Fixes SF #984290. Index: install.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/install.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** install.c 2 Jul 2004 23:53:16 -0000 1.6 --- install.c 7 Jul 2004 07:34:40 -0000 1.7 *************** *** 146,151 **** /* lParam: points to pathname */ - enum { UNSPECIFIED, ALWAYS, NEVER } allow_overwrite = UNSPECIFIED; - static BOOL notify(int code, char *fmt, ...); --- 146,149 ---- *************** *** 809,834 **** } - static BOOL AskOverwrite(char *filename) - { - int result; - again: - if (allow_overwrite == ALWAYS) - return TRUE; - if (allow_overwrite == NEVER) - return FALSE; - result = MessageBox(hDialog, - "Overwrite existing files?\n" - "\n" - "Press YES to ALWAYS overwrite existing files,\n" - "press NO to NEVER overwrite existing files.", - "Overwrite options", - MB_YESNO | MB_ICONQUESTION); - if (result == IDYES) - allow_overwrite = ALWAYS; - else if (result == IDNO) - allow_overwrite = NEVER; - goto again; - } - static BOOL notify (int code, char *fmt, ...) { --- 807,810 ---- *************** *** 845,849 **** /* Questions */ case CAN_OVERWRITE: - result = AskOverwrite(Buffer); break; --- 821,824 ---- From akuchling at users.sourceforge.net Wed Jul 7 14:23:56 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Jul 7 14:23:59 2004 Subject: [Python-checkins] python/dist/src/Lib asyncore.py,1.53,1.54 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19653 Modified Files: asyncore.py Log Message: For readable() objects, the previous value of 'flags' was ignored. Rearrange code for writable() case to make the parallel logic clearer Index: asyncore.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/asyncore.py,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** asyncore.py 30 Jun 2004 09:02:32 -0000 1.53 --- asyncore.py 7 Jul 2004 12:23:53 -0000 1.54 *************** *** 139,145 **** flags = select.POLLERR | select.POLLHUP | select.POLLNVAL if obj.readable(): ! flags = select.POLLIN | select.POLLPRI if obj.writable(): ! flags = flags | select.POLLOUT if flags: pollster.register(fd, flags) --- 139,145 ---- flags = select.POLLERR | select.POLLHUP | select.POLLNVAL if obj.readable(): ! flags |= select.POLLIN | select.POLLPRI if obj.writable(): ! flags |= select.POLLOUT if flags: pollster.register(fd, flags) From akuchling at users.sourceforge.net Wed Jul 7 15:01:58 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Jul 7 15:02:02 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.62, 1.63 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26017 Modified Files: whatsnew24.tex Log Message: Add logging changes Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** whatsnew24.tex 5 Jul 2004 01:40:07 -0000 1.62 --- whatsnew24.tex 7 Jul 2004 13:01:53 -0000 1.63 *************** *** 783,792 **** bookmarking, windowing, or lookahead iterators. \item The \module{operator} module gained two new functions, \function{attrgetter(\var{attr})} and \function{itemgetter(\var{index})}. Both functions return callables that take a single argument and return the corresponding attribute or item; these callables make excellent ! data extractors when used with \function{map()} or \function{sorted()}. ! For example: \begin{verbatim} --- 783,813 ---- bookmarking, windowing, or lookahead iterators. + \item A \function{basicConfig} function was added to the + \module{logging} package to simplify log configuration. It defaults + to logging to standard error, but a + number of optional keyword arguments can be specified to + log to a particular file, change the logging format, or set the + logging level. For example: + + \begin{verbatim} + import logging + logging.basicConfig(filename = '/var/log/application.log', + level=0, # Log all messages, including debugging, + format='%(levelname):%(process):%(thread):%(message)') + \end{verbatim} + + Another addition to \module{logging} is a + \class{TimedRotatingFileHandler} class which rotates its log files at + a timed interval. The module already had \class{RotatingFileHandler}, + which rotated logs once the file exceeded a certain size. Both + classes derive from a new \class{BaseRotatingHandler} class that can + be used to implement other rotating handlers. + \item The \module{operator} module gained two new functions, \function{attrgetter(\var{attr})} and \function{itemgetter(\var{index})}. Both functions return callables that take a single argument and return the corresponding attribute or item; these callables make excellent ! data extractors when used with \function{map()} or ! \function{sorted()}. For example: \begin{verbatim} From akuchling at users.sourceforge.net Wed Jul 7 15:07:50 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Jul 7 15:07:53 2004 Subject: [Python-checkins] python/dist/src/Doc/api abstract.tex,1.33,1.34 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27114 Modified Files: abstract.tex Log Message: [Bug #984017] Incorrect prototype, fixed by Timothy Stranex Index: abstract.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/abstract.tex,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** abstract.tex 5 Jun 2004 19:00:55 -0000 1.33 --- abstract.tex 7 Jul 2004 13:07:47 -0000 1.34 *************** *** 1000,1004 **** \begin{cfuncdesc}{int}{PyObject_AsReadBuffer}{PyObject *obj, ! const char **buffer, int *buffer_len} Returns a pointer to a read-only memory location containing --- 1000,1004 ---- \begin{cfuncdesc}{int}{PyObject_AsReadBuffer}{PyObject *obj, ! const void **buffer, int *buffer_len} Returns a pointer to a read-only memory location containing *************** *** 1018,1022 **** \begin{cfuncdesc}{int}{PyObject_AsWriteBuffer}{PyObject *obj, ! char **buffer, int *buffer_len} Returns a pointer to a writeable memory location. The \var{obj} --- 1018,1022 ---- \begin{cfuncdesc}{int}{PyObject_AsWriteBuffer}{PyObject *obj, ! void **buffer, int *buffer_len} Returns a pointer to a writeable memory location. The \var{obj} From akuchling at users.sourceforge.net Wed Jul 7 15:08:50 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Jul 7 15:08:55 2004 Subject: [Python-checkins] python/dist/src/Doc/api abstract.tex, 1.26.12.6, 1.26.12.7 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27315 Modified Files: Tag: release23-maint abstract.tex Log Message: [Bug #984017] Incorrect prototype, fixed by Timothy Stranex Index: abstract.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/abstract.tex,v retrieving revision 1.26.12.6 retrieving revision 1.26.12.7 diff -C2 -d -r1.26.12.6 -r1.26.12.7 *** abstract.tex 5 Jun 2004 19:01:47 -0000 1.26.12.6 --- abstract.tex 7 Jul 2004 13:08:47 -0000 1.26.12.7 *************** *** 993,997 **** \begin{cfuncdesc}{int}{PyObject_AsReadBuffer}{PyObject *obj, ! const char **buffer, int *buffer_len} Returns a pointer to a read-only memory location containing --- 993,997 ---- \begin{cfuncdesc}{int}{PyObject_AsReadBuffer}{PyObject *obj, ! const void **buffer, int *buffer_len} Returns a pointer to a read-only memory location containing *************** *** 1011,1015 **** \begin{cfuncdesc}{int}{PyObject_AsWriteBuffer}{PyObject *obj, ! char **buffer, int *buffer_len} Returns a pointer to a writeable memory location. The \var{obj} --- 1011,1015 ---- \begin{cfuncdesc}{int}{PyObject_AsWriteBuffer}{PyObject *obj, ! void **buffer, int *buffer_len} Returns a pointer to a writeable memory location. The \var{obj} From aimacintyre at users.sourceforge.net Wed Jul 7 15:55:27 2004 From: aimacintyre at users.sourceforge.net (aimacintyre@users.sourceforge.net) Date: Wed Jul 7 15:55:32 2004 Subject: [Python-checkins] python/dist/src/PC/os2emx Makefile, 1.16, 1.17 config.c, 1.6, 1.7 Message-ID: Update of /cvsroot/python/python/dist/src/PC/os2emx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5051 Modified Files: Makefile config.c Log Message: bring OS/2 EMX port build environment up to date Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/os2emx/Makefile,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Makefile 25 Dec 2003 13:25:20 -0000 1.16 --- Makefile 7 Jul 2004 13:55:24 -0000 1.17 *************** *** 1,15 **** #####################==================---------------- # ! # Top-Level Makefile for Building Python 2.3 for OS/2 using GCC/EMX # Originally written by Andrew Zabolotny, for Python 1.5.2 ! # Modified by Andrew MacIntyre, for Python 2.3 # # This makefile was developed for use with [P]GCC/EMX compiler any # version and GNU Make. # ! # The output of the build is a largish Python23.DLL containing the # essential modules of Python and a small Python.exe program to start # the interpreter. When embedding Python within another program, only ! # Python23.DLL is needed. We also build python_s.a static library (which # can be converted into OMF (.lib) format using emxomf tool) and both # python.a and python.lib import libraries. Then the optional --- 1,15 ---- #####################==================---------------- # ! # Top-Level Makefile for Building Python 2.4 for OS/2 using GCC/EMX # Originally written by Andrew Zabolotny, for Python 1.5.2 ! # Modified by Andrew MacIntyre, for Python 2.4 # # This makefile was developed for use with [P]GCC/EMX compiler any # version and GNU Make. # ! # The output of the build is a largish Python24.DLL containing the # essential modules of Python and a small Python.exe program to start # the interpreter. When embedding Python within another program, only ! # Python24.DLL is needed. We also build python_s.a static library (which # can be converted into OMF (.lib) format using emxomf tool) and both # python.a and python.lib import libraries. Then the optional *************** *** 65,69 **** # === install locations === # default value of PYTHONHOME ! LIB_DIR=C:/Python23 # default is to have everything in or under PYTHONHOME EXE_DIR=$(LIB_DIR) --- 65,69 ---- # === install locations === # default value of PYTHONHOME ! LIB_DIR=C:/Python24 # default is to have everything in or under PYTHONHOME EXE_DIR=$(LIB_DIR) *************** *** 221,226 **** # Output file names ! PYTHON_VER= 2.3 ! PYTHON_LIB= python23 PYTHON.LIB= $(PYTHON_LIB)_s$A PYTHON.IMPLIB= $(PYTHON_LIB)$A --- 221,226 ---- # Output file names ! PYTHON_VER= 2.4 ! PYTHON_LIB= python24 PYTHON.LIB= $(PYTHON_LIB)_s$A PYTHON.IMPLIB= $(PYTHON_LIB)$A *************** *** 273,276 **** --- 273,277 ---- Modules/cmathmodule.c \ Modules/_codecsmodule.c \ + Modules/collectionsmodule.c \ Modules/cPickle.c \ Modules/cStringIO.c \ *************** *** 280,283 **** --- 281,285 ---- Modules/errnomodule.c \ Modules/fcntlmodule.c \ + Modules/_heapqmodule.c \ Modules/imageop.c \ Modules/itertoolsmodule.c \ *************** *** 287,292 **** Modules/md5module.c \ Modules/operator.c \ - Modules/pcremodule.c \ - Modules/pypcre.c \ Modules/_randommodule.c \ Modules/regexmodule.c \ --- 289,292 ---- *************** *** 344,347 **** --- 344,348 ---- Python/pyfpe.c \ Python/pystate.c \ + Python/pystrtod.c \ Python/pythonrun.c \ Python/structmember.c \ *************** *** 367,370 **** --- 368,372 ---- Objects/frameobject.c \ Objects/funcobject.c \ + Objects/genobject.c \ Objects/intobject.c \ Objects/iterobject.c \ *************** *** 376,379 **** --- 378,382 ---- Objects/obmalloc.c \ Objects/rangeobject.c \ + Objects/setobject.c \ Objects/sliceobject.c \ Objects/stringobject.c \ *************** *** 492,496 **** rm -f $(OUT)* rm -f $(PYTHON.LIB) $(PYTHON.IMPLIB) $(PYTHON.EXEIMP) $(PYTHON.DLL) \ ! $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) *$(MODULE.EXT) find ../../Lib -name "*.py[co]" -exec rm {} ";" --- 495,499 ---- rm -f $(OUT)* rm -f $(PYTHON.LIB) $(PYTHON.IMPLIB) $(PYTHON.EXEIMP) $(PYTHON.DLL) \ ! $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) *$(MODULE.EXT) *.dll find ../../Lib -name "*.py[co]" -exec rm {} ";" Index: config.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/os2emx/config.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** config.c 9 Jun 2003 08:16:02 -0000 1.6 --- config.c 7 Jul 2004 13:55:25 -0000 1.7 *************** *** 53,56 **** --- 53,57 ---- extern void initcPickle(); extern void initcStringIO(); + extern void initcollections(); extern void initcmath(); extern void initdatetime(); *************** *** 58,61 **** --- 59,63 ---- extern void initerrno(); extern void initfcntl(); + extern void init_heapq(); extern void initimageop(); extern void inititertools(); *************** *** 63,67 **** extern void initmd5(); extern void initoperator(); - extern void initpcre(); extern void initregex(); extern void initrgbimg(); --- 65,68 ---- *************** *** 118,121 **** --- 119,123 ---- {"cPickle", initcPickle}, {"cStringIO", initcStringIO}, + {"collections", initcollections}, {"cmath", initcmath}, {"datetime", initdatetime}, *************** *** 123,126 **** --- 125,129 ---- {"errno", initerrno}, {"fcntl", initfcntl}, + {"_heapq", init_heapq}, {"imageop", initimageop}, {"itertools", inititertools}, *************** *** 128,132 **** {"md5", initmd5}, {"operator", initoperator}, - {"pcre", initpcre}, {"regex", initregex}, {"rgbimg", initrgbimg}, --- 131,134 ---- From aimacintyre at users.sourceforge.net Wed Jul 7 16:03:03 2004 From: aimacintyre at users.sourceforge.net (aimacintyre@users.sourceforge.net) Date: Wed Jul 7 16:03:06 2004 Subject: [Python-checkins] python/dist/src/Modules socketmodule.c, 1.292, 1.293 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6295 Modified Files: socketmodule.c Log Message: OS/2 EMX needs addrinfo.h for code included from getaddrinfo.c Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.292 retrieving revision 1.293 diff -C2 -d -r1.292 -r1.293 *** socketmodule.c 28 Jun 2004 00:50:43 -0000 1.292 --- socketmodule.c 7 Jul 2004 14:02:59 -0000 1.293 *************** *** 280,283 **** --- 280,287 ---- #endif + #if defined(PYOS_OS2) && defined(PYCC_GCC) + #include "addrinfo.h" + #endif + #ifndef HAVE_INET_PTON int inet_pton(int af, const char *src, void *dst); From akuchling at users.sourceforge.net Wed Jul 7 16:09:24 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Jul 7 16:09:27 2004 Subject: [Python-checkins] python/dist/src/Lib mailbox.py,1.41,1.42 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7754 Modified Files: mailbox.py Log Message: [Bug #925107] Make .readline() consider self.stop. This makes read() and readline() very similar, so they're refactored into _read. Patch by Johannes Gijsbers. 2.3 bugfix candidate. Index: mailbox.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mailbox.py,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** mailbox.py 7 Feb 2004 02:16:24 -0000 1.41 --- mailbox.py 7 Jul 2004 14:09:21 -0000 1.42 *************** *** 44,69 **** self.pos = self.start ! def read(self, length = None): if self.pos >= self.stop: return '' remaining = self.stop - self.pos ! if length is None or length < 0: ! length = remaining ! elif length > remaining: length = remaining self.fp.seek(self.pos) ! data = self.fp.read(length) self.pos = self.fp.tell() return data def readline(self, length = None): ! if self.pos >= self.stop: ! return '' ! if length is None: ! length = self.stop - self.pos ! self.fp.seek(self.pos) ! data = self.fp.readline(length) ! self.pos = self.fp.tell() ! return data def readlines(self, sizehint = -1): --- 44,64 ---- self.pos = self.start ! ! def _read(self, length, read_function): if self.pos >= self.stop: return '' remaining = self.stop - self.pos ! if length is None or length < 0 or length > remaining: length = remaining self.fp.seek(self.pos) ! data = read_function(length) self.pos = self.fp.tell() return data + def read(self, length = None): + self._read(length, self.fp.read) + def readline(self, length = None): ! self._read(length, self.fp.readline) def readlines(self, sizehint = -1): From akuchling at users.sourceforge.net Wed Jul 7 16:19:12 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Jul 7 16:19:15 2004 Subject: [Python-checkins] python/dist/src/Modules gdbmmodule.c,2.35,2.36 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9854 Modified Files: gdbmmodule.c Log Message: [Bug #982806] The default argument for opening GDBM files is bogus. Patch #984672 by James Lamanna Index: gdbmmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/gdbmmodule.c,v retrieving revision 2.35 retrieving revision 2.36 diff -C2 -d -r2.35 -r2.36 *** gdbmmodule.c 2 Aug 2002 02:27:13 -0000 2.35 --- gdbmmodule.c 7 Jul 2004 14:19:09 -0000 2.36 *************** *** 435,439 **** { char *name; ! char *flags = "r "; int iflags; int mode = 0666; --- 435,439 ---- { char *name; ! char *flags = "r"; int iflags; int mode = 0666; From akuchling at users.sourceforge.net Wed Jul 7 16:20:06 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Jul 7 16:20:09 2004 Subject: [Python-checkins] python/dist/src/Modules gdbmmodule.c, 2.35, 2.35.14.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10067 Modified Files: Tag: release23-maint gdbmmodule.c Log Message: [Bug #982806] The default argument for opening GDBM files is bogus. Patch #984672 by James Lamanna Index: gdbmmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/gdbmmodule.c,v retrieving revision 2.35 retrieving revision 2.35.14.1 diff -C2 -d -r2.35 -r2.35.14.1 *** gdbmmodule.c 2 Aug 2002 02:27:13 -0000 2.35 --- gdbmmodule.c 7 Jul 2004 14:20:04 -0000 2.35.14.1 *************** *** 435,439 **** { char *name; ! char *flags = "r "; int iflags; int mode = 0666; --- 435,439 ---- { char *name; ! char *flags = "r"; int iflags; int mode = 0666; From vsajip at users.sourceforge.net Wed Jul 7 17:59:52 2004 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Wed Jul 7 17:59:56 2004 Subject: [Python-checkins] python/dist/src/Doc/lib liblogging.tex,1.19,1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29400 Modified Files: liblogging.tex Log Message: Replaced some tabs with spaces in verbatim section. Index: liblogging.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liblogging.tex,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** liblogging.tex 3 Jul 2004 11:45:53 -0000 1.19 --- liblogging.tex 7 Jul 2004 15:59:49 -0000 1.20 *************** *** 398,404 **** logging.basicConfig(level=logging.DEBUG, ! format='%(asctime)s %(levelname)s %(message)s', ! filename='/tmp/myapp.log', ! filemode='w') logging.debug('A debug message') logging.info('Some information') --- 398,404 ---- logging.basicConfig(level=logging.DEBUG, ! format='%(asctime)s %(levelname)s %(message)s', ! filename='/tmp/myapp.log', ! filemode='w') logging.debug('A debug message') logging.info('Some information') *************** *** 445,452 **** logging.basicConfig(level=logging.DEBUG, ! format='%(asctime)s %(levelname)-8s %(message)s', ! datefmt='%a, %d %b %Y %H:%M:%S', ! filename='/temp/myapp.log', ! filemode='w') logging.debug('A debug message') logging.info('Some information') --- 445,452 ---- logging.basicConfig(level=logging.DEBUG, ! format='%(asctime)s %(levelname)-8s %(message)s', ! datefmt='%a, %d %b %Y %H:%M:%S', ! filename='/temp/myapp.log', ! filemode='w') logging.debug('A debug message') logging.info('Some information') From mwh at users.sourceforge.net Wed Jul 7 19:44:13 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Wed Jul 7 19:44:16 2004 Subject: [Python-checkins] python/dist/src/Misc ACKS,1.269,1.270 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18275/Misc Modified Files: ACKS Log Message: This closes patch: [ 960406 ] unblock signals in threads although the changes do not correspond exactly to any patch attached to that report. Non-main threads no longer have all signals masked. A different interface to readline is used. The handling of signals inside calls to PyOS_Readline is now rather different. These changes are all a bit scary! Review and cross-platform testing much appreciated. Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.269 retrieving revision 1.270 diff -C2 -d -r1.269 -r1.270 *** ACKS 29 Jun 2004 14:03:04 -0000 1.269 --- ACKS 7 Jul 2004 17:44:10 -0000 1.270 *************** *** 328,331 **** --- 328,332 ---- Vladimir Kushnir Cameron Laird + Andrew Langmead Detlef Lannert Soren Larsen From mwh at users.sourceforge.net Wed Jul 7 19:44:13 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Wed Jul 7 19:44:17 2004 Subject: [Python-checkins] python/dist/src/Modules readline.c,2.70,2.71 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18275/Modules Modified Files: readline.c Log Message: This closes patch: [ 960406 ] unblock signals in threads although the changes do not correspond exactly to any patch attached to that report. Non-main threads no longer have all signals masked. A different interface to readline is used. The handling of signals inside calls to PyOS_Readline is now rather different. These changes are all a bit scary! Review and cross-platform testing much appreciated. Index: readline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v retrieving revision 2.70 retrieving revision 2.71 diff -C2 -d -r2.70 -r2.71 *** readline.c 24 May 2004 14:20:15 -0000 2.70 --- readline.c 7 Jul 2004 17:44:10 -0000 2.71 *************** *** 657,660 **** --- 657,720 ---- } + /* Wrapper around GNU readline that handles signals differently. */ + + + #if defined(HAVE_RL_CALLBACK) && defined(HAVE_SELECT) + + static char *completed_input_string; + static void + rlhandler(char *text) + { + completed_input_string = text; + rl_callback_handler_remove(); + } + + extern PyThreadState* _PyOS_ReadlineTState; + + static char * + readline_until_enter_or_signal(char *prompt, int *signal) + { + char * not_done_reading = ""; + fd_set selectset; + + *signal = 0; + #ifdef HAVE_RL_CATCH_SIGNAL + rl_catch_signals = 0; + #endif + + rl_callback_handler_install (prompt, rlhandler); + FD_ZERO(&selectset); + FD_SET(fileno(rl_instream), &selectset); + + completed_input_string = not_done_reading; + + while(completed_input_string == not_done_reading) { + int has_input; + + has_input = select(fileno(rl_instream) + 1, &selectset, + NULL, NULL, NULL); + if(has_input > 0) { + rl_callback_read_char(); + } + else if (errno == EINTR) { + int s; + PyEval_RestoreThread(_PyOS_ReadlineTState); + s = PyErr_CheckSignals(); + PyThreadState_Swap(NULL); + if (s < 0) { + rl_free_line_state(); + rl_cleanup_after_signal(); + rl_callback_handler_remove(); + *signal = 1; + completed_input_string = NULL; + } + } + } + + return completed_input_string; + } + + + #else /* Interrupt handler */ *************** *** 670,681 **** - /* Wrapper around GNU readline that handles signals differently. */ - static char * ! call_readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt) { - size_t n; - char *p, *q; PyOS_sighandler_t old_inthandler; old_inthandler = PyOS_setsig(SIGINT, onintr); --- 730,740 ---- static char * ! readline_until_enter_or_signal(char *prompt, int *signal) { PyOS_sighandler_t old_inthandler; + char *p; + + *signal = 0; old_inthandler = PyOS_setsig(SIGINT, onintr); *************** *** 686,691 **** --- 745,766 ---- #endif PyOS_setsig(SIGINT, old_inthandler); + *signal = 1; return NULL; } + p = readline(prompt); + PyOS_setsig(SIGINT, old_inthandler); + + return p; + } + #endif /*defined(HAVE_RL_CALLBACK) && defined(HAVE_SELECT) */ + + + static char * + call_readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt) + { + size_t n; + char *p, *q; + int signal; + rl_event_hook = PyOS_InputHook; *************** *** 698,705 **** } ! p = readline(prompt); ! PyOS_setsig(SIGINT, old_inthandler); ! /* We must return a buffer allocated with PyMem_Malloc. */ if (p == NULL) { p = PyMem_Malloc(1); --- 773,784 ---- } ! p = readline_until_enter_or_signal(prompt, &signal); ! ! /* we got an interrupt signal */ ! if(signal) { ! return NULL; ! } ! /* We got an EOF, return a empty string. */ if (p == NULL) { p = PyMem_Malloc(1); *************** *** 708,711 **** --- 787,792 ---- return p; } + + /* we have a valid line */ n = strlen(p); if (n > 0) { From mwh at users.sourceforge.net Wed Jul 7 19:44:13 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Wed Jul 7 19:44:17 2004 Subject: [Python-checkins] python/dist/src configure, 1.449, 1.450 configure.in, 1.460, 1.461 pyconfig.h.in, 1.99, 1.100 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18275 Modified Files: configure configure.in pyconfig.h.in Log Message: This closes patch: [ 960406 ] unblock signals in threads although the changes do not correspond exactly to any patch attached to that report. Non-main threads no longer have all signals masked. A different interface to readline is used. The handling of signals inside calls to PyOS_Readline is now rather different. These changes are all a bit scary! Review and cross-platform testing much appreciated. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.449 retrieving revision 1.450 diff -C2 -d -r1.449 -r1.450 *** configure 25 Jun 2004 23:30:56 -0000 1.449 --- configure 7 Jul 2004 17:44:03 -0000 1.450 *************** *** 1,8 **** #! /bin/sh ! # From configure.in Revision: 1.459 . # Guess values for system-dependent variables and create Makefiles. ! # Generated by GNU Autoconf 2.59 for python 2.4. # ! # Copyright (C) 2003 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. --- 1,9 ---- #! /bin/sh [...12726 lines suppressed...] sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } *************** *** 21003,21010 **** as_dir=`(dirname "$as_dir") 2>/dev/null || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ ! X"$as_dir" : 'X\(//\)[^/]' \| \ ! X"$as_dir" : 'X\(//\)$' \| \ ! X"$as_dir" : 'X\(/\)' \| \ ! . : '\(.\)' 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } --- 19354,19361 ---- as_dir=`(dirname "$as_dir") 2>/dev/null || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ ! X"$as_dir" : 'X\(//\)[^/]' \| \ ! X"$as_dir" : 'X\(//\)$' \| \ ! X"$as_dir" : 'X\(/\)' \| \ ! . : '\(.\)' 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.460 retrieving revision 1.461 diff -C2 -d -r1.460 -r1.461 *** configure.in 25 Jun 2004 23:31:05 -0000 1.460 --- configure.in 7 Jul 2004 17:44:09 -0000 1.461 *************** *** 2784,2787 **** --- 2784,2792 ---- fi + # check for readline 2.1 + AC_CHECK_LIB(readline, rl_callback_handler_install, + AC_DEFINE(HAVE_RL_CALLBACK, 1, + [Define if you have readline 2.1]), , -ltermcap) + # check for readline 2.2 AC_TRY_CPP([#include ], *************** *** 2805,2808 **** --- 2810,2824 ---- [Define if you have readline 4.2]), , -ltermcap) + # also in readline 4.2 + AC_TRY_CPP([#include ], + have_readline=yes, have_readline=no) + if test $have_readline = yes + then + AC_EGREP_HEADER([extern int rl_catch_signals;], + [readline/readline.h], + AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1, + [Define if you can turn off readline's signal handling.]), ) + fi + AC_MSG_CHECKING(for broken nice()) AC_CACHE_VAL(ac_cv_broken_nice, [ Index: pyconfig.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/pyconfig.h.in,v retrieving revision 1.99 retrieving revision 1.100 diff -C2 -d -r1.99 -r1.100 *** pyconfig.h.in 25 Jun 2004 23:31:05 -0000 1.99 --- pyconfig.h.in 7 Jul 2004 17:44:09 -0000 1.100 *************** *** 360,363 **** --- 360,369 ---- #undef HAVE_REALPATH + /* Define if you have readline 2.1 */ + #undef HAVE_RL_CALLBACK + + /* Define if you can turn off readline's signal handling. */ + #undef HAVE_RL_CATCH_SIGNAL + /* Define if you have readline 2.2 */ #undef HAVE_RL_COMPLETION_APPEND_CHARACTER From mwh at users.sourceforge.net Wed Jul 7 19:44:13 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Wed Jul 7 19:44:18 2004 Subject: [Python-checkins] python/dist/src/Parser myreadline.c,2.30,2.31 Message-ID: Update of /cvsroot/python/python/dist/src/Parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18275/Parser Modified Files: myreadline.c Log Message: This closes patch: [ 960406 ] unblock signals in threads although the changes do not correspond exactly to any patch attached to that report. Non-main threads no longer have all signals masked. A different interface to readline is used. The handling of signals inside calls to PyOS_Readline is now rather different. These changes are all a bit scary! Review and cross-platform testing much appreciated. Index: myreadline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/myreadline.c,v retrieving revision 2.30 retrieving revision 2.31 diff -C2 -d -r2.30 -r2.31 *** myreadline.c 19 Nov 2003 15:24:46 -0000 2.30 --- myreadline.c 7 Jul 2004 17:44:10 -0000 2.31 *************** *** 20,23 **** --- 20,31 ---- #endif + + PyThreadState* _PyOS_ReadlineTState; + + #if WITH_THREAD + #include "pythread.h" + static PyThread_type_lock _PyOS_ReadlineLock = NULL; + #endif + int (*PyOS_InputHook)(void) = NULL; *************** *** 74,81 **** #ifdef EINTR if (errno == EINTR) { ! if (PyOS_InterruptOccurred()) { ! return 1; /* Interrupt */ } - continue; } #endif --- 82,92 ---- #ifdef EINTR if (errno == EINTR) { ! int s; ! PyEval_RestoreThread(_PyOS_ReadlineTState); ! s = PyErr_CheckSignals(); ! PyThreadState_Swap(NULL); ! if (s < 0) { ! return 1; } } #endif *************** *** 156,159 **** --- 167,177 ---- char *rv; + if (_PyOS_ReadlineTState == PyThreadState_GET()) { + PyErr_SetString(PyExc_RuntimeError, + "can't re-enter readline"); + return NULL; + } + + if (PyOS_ReadlineFunctionPointer == NULL) { #ifdef __VMS *************** *** 163,168 **** --- 181,196 ---- #endif } + + #if WITH_THREAD + if (_PyOS_ReadlineLock == NULL) { + _PyOS_ReadlineLock = PyThread_allocate_lock(); + } + #endif + _PyOS_ReadlineTState = PyThreadState_GET(); Py_BEGIN_ALLOW_THREADS + #if WITH_THREAD + PyThread_acquire_lock(_PyOS_ReadlineLock, 1); + #endif /* This is needed to handle the unlikely case that the *************** *** 177,180 **** --- 205,215 ---- prompt); Py_END_ALLOW_THREADS + + #if WITH_THREAD + PyThread_release_lock(_PyOS_ReadlineLock); + #endif + + _PyOS_ReadlineTState = NULL; + return rv; } From mwh at users.sourceforge.net Wed Jul 7 19:44:15 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Wed Jul 7 19:44:20 2004 Subject: [Python-checkins] python/dist/src/Python bltinmodule.c, 2.311, 2.312 ceval.c, 2.408, 2.409 pythonrun.c, 2.205, 2.206 thread_pthread.h, 2.52, 2.53 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18275/Python Modified Files: bltinmodule.c ceval.c pythonrun.c thread_pthread.h Log Message: This closes patch: [ 960406 ] unblock signals in threads although the changes do not correspond exactly to any patch attached to that report. Non-main threads no longer have all signals masked. A different interface to readline is used. The handling of signals inside calls to PyOS_Readline is now rather different. These changes are all a bit scary! Review and cross-platform testing much appreciated. Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.311 retrieving revision 2.312 diff -C2 -d -r2.311 -r2.312 *** bltinmodule.c 6 Jul 2004 13:44:40 -0000 2.311 --- bltinmodule.c 7 Jul 2004 17:44:11 -0000 2.312 *************** *** 1590,1594 **** Py_XDECREF(po); if (s == NULL) { ! PyErr_SetNone(PyExc_KeyboardInterrupt); return NULL; } --- 1590,1595 ---- Py_XDECREF(po); if (s == NULL) { ! if (!PyErr_Occurred()) ! PyErr_SetNone(PyExc_KeyboardInterrupt); return NULL; } Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.408 retrieving revision 2.409 diff -C2 -d -r2.408 -r2.409 *** ceval.c 2 Jul 2004 06:41:07 -0000 2.408 --- ceval.c 7 Jul 2004 17:44:11 -0000 2.409 *************** *** 319,323 **** Py_AddPendingCall(int (*func)(void *), void *arg) { ! static int busy = 0; int i, j; /* XXX Begin critical section */ --- 319,323 ---- Py_AddPendingCall(int (*func)(void *), void *arg) { ! static volatile int busy = 0; int i, j; /* XXX Begin critical section */ Index: pythonrun.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v retrieving revision 2.205 retrieving revision 2.206 diff -C2 -d -r2.205 -r2.206 *** pythonrun.c 24 Mar 2004 22:22:12 -0000 2.205 --- pythonrun.c 7 Jul 2004 17:44:12 -0000 2.206 *************** *** 1436,1440 **** break; case E_INTR: ! PyErr_SetNone(PyExc_KeyboardInterrupt); Py_XDECREF(v); return; --- 1436,1441 ---- break; case E_INTR: ! if (!PyErr_Occurred()) ! PyErr_SetNone(PyExc_KeyboardInterrupt); Py_XDECREF(v); return; Index: thread_pthread.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_pthread.h,v retrieving revision 2.52 retrieving revision 2.53 diff -C2 -d -r2.52 -r2.53 *** thread_pthread.h 4 Mar 2004 06:35:57 -0000 2.52 --- thread_pthread.h 7 Jul 2004 17:44:12 -0000 2.53 *************** *** 120,124 **** pthread_t th; int status; - sigset_t oldmask, newmask; #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED) pthread_attr_t attrs; --- 120,123 ---- *************** *** 138,148 **** #endif - /* Mask all signals in the current thread before creating the new - * thread. This causes the new thread to start with all signals - * blocked. - */ - sigfillset(&newmask); - SET_THREAD_SIGMASK(SIG_BLOCK, &newmask, &oldmask); - status = pthread_create(&th, #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED) --- 137,140 ---- *************** *** 155,161 **** ); - /* Restore signal mask for original thread */ - SET_THREAD_SIGMASK(SIG_SETMASK, &oldmask, NULL); - #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED) pthread_attr_destroy(&attrs); --- 147,150 ---- From tim_one at users.sourceforge.net Wed Jul 7 22:42:17 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Jul 7 22:42:20 2004 Subject: [Python-checkins] python/dist/src/Parser myreadline.c,2.31,2.32 Message-ID: Update of /cvsroot/python/python/dist/src/Parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24618 Modified Files: myreadline.c Log Message: "#if WITH_THREAD" is incorrect; must be #ifdef instead; WITH_THREAD isn't always set to an integer value when it's defined. Index: myreadline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/myreadline.c,v retrieving revision 2.31 retrieving revision 2.32 diff -C2 -d -r2.31 -r2.32 *** myreadline.c 7 Jul 2004 17:44:10 -0000 2.31 --- myreadline.c 7 Jul 2004 20:42:07 -0000 2.32 *************** *** 23,27 **** PyThreadState* _PyOS_ReadlineTState; ! #if WITH_THREAD #include "pythread.h" static PyThread_type_lock _PyOS_ReadlineLock = NULL; --- 23,27 ---- PyThreadState* _PyOS_ReadlineTState; ! #ifdef WITH_THREAD #include "pythread.h" static PyThread_type_lock _PyOS_ReadlineLock = NULL; *************** *** 182,186 **** } ! #if WITH_THREAD if (_PyOS_ReadlineLock == NULL) { _PyOS_ReadlineLock = PyThread_allocate_lock(); --- 182,186 ---- } ! #ifdef WITH_THREAD if (_PyOS_ReadlineLock == NULL) { _PyOS_ReadlineLock = PyThread_allocate_lock(); *************** *** 190,194 **** _PyOS_ReadlineTState = PyThreadState_GET(); Py_BEGIN_ALLOW_THREADS ! #if WITH_THREAD PyThread_acquire_lock(_PyOS_ReadlineLock, 1); #endif --- 190,194 ---- _PyOS_ReadlineTState = PyThreadState_GET(); Py_BEGIN_ALLOW_THREADS ! #ifdef WITH_THREAD PyThread_acquire_lock(_PyOS_ReadlineLock, 1); #endif *************** *** 206,210 **** Py_END_ALLOW_THREADS ! #if WITH_THREAD PyThread_release_lock(_PyOS_ReadlineLock); #endif --- 206,210 ---- Py_END_ALLOW_THREADS ! #ifdef WITH_THREAD PyThread_release_lock(_PyOS_ReadlineLock); #endif From tim_one at users.sourceforge.net Wed Jul 7 22:54:49 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Jul 7 22:54:53 2004 Subject: [Python-checkins] python/dist/src/Lib/compiler pycodegen.py, 1.67, 1.68 symbols.py, 1.14, 1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/compiler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28101/Lib/compiler Modified Files: pycodegen.py symbols.py Log Message: Whitespace normalization. Index: pycodegen.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/compiler/pycodegen.py,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** pycodegen.py 19 May 2004 08:20:07 -0000 1.67 --- pycodegen.py 7 Jul 2004 20:54:46 -0000 1.68 *************** *** 672,676 **** start = self.newBlock() anchor = self.newBlock() ! if node.is_outmost: self.loadName('[outmost-iterable]') --- 672,676 ---- start = self.newBlock() anchor = self.newBlock() ! if node.is_outmost: self.loadName('[outmost-iterable]') Index: symbols.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/compiler/symbols.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** symbols.py 19 May 2004 08:20:08 -0000 1.14 --- symbols.py 7 Jul 2004 20:54:47 -0000 1.15 *************** *** 261,271 **** def visitGenExprIf(self, node, scope): self.visit(node.test, scope) ! def visitLambda(self, node, parent, assign=0): # Lambda is an expression, so it could appear in an expression # context where assign is passed. The transformer should catch # any code that has a lambda on the left-hand side. ! assert not assign ! for n in node.defaults: self.visit(n, parent) --- 261,271 ---- def visitGenExprIf(self, node, scope): self.visit(node.test, scope) ! def visitLambda(self, node, parent, assign=0): # Lambda is an expression, so it could appear in an expression # context where assign is passed. The transformer should catch # any code that has a lambda on the left-hand side. ! assert not assign ! for n in node.defaults: self.visit(n, parent) From tim_one at users.sourceforge.net Wed Jul 7 22:54:50 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Jul 7 22:54:55 2004 Subject: [Python-checkins] python/dist/src/Lib/logging __init__.py, 1.15, 1.16 handlers.py, 1.13, 1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/logging In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28101/Lib/logging Modified Files: __init__.py handlers.py Log Message: Whitespace normalization. Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/logging/__init__.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** __init__.py 3 Jul 2004 11:47:26 -0000 1.15 --- __init__.py 7 Jul 2004 20:54:47 -0000 1.16 *************** *** 1163,1167 **** level = kwargs.get("level") if level: ! root.setLevel(level) #--------------------------------------------------------------------------- --- 1163,1167 ---- level = kwargs.get("level") if level: ! root.setLevel(level) #--------------------------------------------------------------------------- Index: handlers.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/logging/handlers.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** handlers.py 3 Jul 2004 11:48:34 -0000 1.13 --- handlers.py 7 Jul 2004 20:54:48 -0000 1.14 *************** *** 316,322 **** # we've waited long enough. if self.retryTime is None: ! attempt = 1 else: ! attempt = (now >= self.retryTime) if attempt: try: --- 316,322 ---- # we've waited long enough. if self.retryTime is None: ! attempt = 1 else: ! attempt = (now >= self.retryTime) if attempt: try: *************** *** 367,375 **** ei = record.exc_info if ei: ! dummy = self.format(record) # just to get traceback text into record.exc_text ! record.exc_info = None # to avoid Unpickleable error s = cPickle.dumps(record.__dict__, 1) if ei: ! record.exc_info = ei # for next handler slen = struct.pack(">L", len(s)) return slen + s --- 367,375 ---- ei = record.exc_info if ei: ! dummy = self.format(record) # just to get traceback text into record.exc_text ! record.exc_info = None # to avoid Unpickleable error s = cPickle.dumps(record.__dict__, 1) if ei: ! record.exc_info = ei # for next handler slen = struct.pack(">L", len(s)) return slen + s From tim_one at users.sourceforge.net Wed Jul 7 22:54:52 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Jul 7 22:54:56 2004 Subject: [Python-checkins] python/dist/src/Lib/encodings big5.py, 1.1, 1.2 cp932.py, 1.1, 1.2 cp949.py, 1.1, 1.2 cp950.py, 1.1, 1.2 euc_jisx0213.py, 1.1, 1.2 euc_jp.py, 1.1, 1.2 euc_kr.py, 1.1, 1.2 gb18030.py, 1.1, 1.2 gb2312.py, 1.1, 1.2 gbk.py, 1.1, 1.2 hz.py, 1.1, 1.2 iso2022_jp.py, 1.1, 1.2 iso2022_jp_1.py, 1.1, 1.2 iso2022_jp_2.py, 1.1, 1.2 iso2022_jp_3.py, 1.1, 1.2 iso2022_jp_ext.py, 1.1, 1.2 iso2022_kr.py, 1.1, 1.2 johab.py, 1.1, 1.2 ptcp154.py, 1.1, 1.2 shift_jis.py, 1.1, 1.2 shift_jisx0213.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/encodings In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28101/Lib/encodings Modified Files: big5.py cp932.py cp949.py cp950.py euc_jisx0213.py euc_jp.py euc_kr.py gb18030.py gb2312.py gbk.py hz.py iso2022_jp.py iso2022_jp_1.py iso2022_jp_2.py iso2022_jp_3.py iso2022_jp_ext.py iso2022_kr.py johab.py ptcp154.py shift_jis.py shift_jisx0213.py Log Message: Whitespace normalization. Index: big5.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/big5.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** big5.py 17 Jan 2004 14:29:28 -0000 1.1 --- big5.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 32,34 **** def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) - --- 32,33 ---- Index: cp932.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/cp932.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** cp932.py 17 Jan 2004 14:29:28 -0000 1.1 --- cp932.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 32,34 **** def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) - --- 32,33 ---- Index: cp949.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/cp949.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** cp949.py 17 Jan 2004 14:29:28 -0000 1.1 --- cp949.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 32,34 **** def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) - --- 32,33 ---- Index: cp950.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/cp950.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** cp950.py 17 Jan 2004 14:29:28 -0000 1.1 --- cp950.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 32,34 **** def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) - --- 32,33 ---- Index: euc_jisx0213.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/euc_jisx0213.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** euc_jisx0213.py 17 Jan 2004 14:29:28 -0000 1.1 --- euc_jisx0213.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 32,34 **** def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) - --- 32,33 ---- Index: euc_jp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/euc_jp.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** euc_jp.py 17 Jan 2004 14:29:28 -0000 1.1 --- euc_jp.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 32,34 **** def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) - --- 32,33 ---- Index: euc_kr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/euc_kr.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** euc_kr.py 17 Jan 2004 14:29:28 -0000 1.1 --- euc_kr.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 32,34 **** def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) - --- 32,33 ---- Index: gb18030.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/gb18030.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** gb18030.py 17 Jan 2004 14:29:28 -0000 1.1 --- gb18030.py 7 Jul 2004 20:54:47 -0000 1.2 *************** *** 32,34 **** def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) - --- 32,33 ---- Index: gb2312.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/gb2312.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1