diff -r 5738c611ff2a -r 6a1c8fcce229 Doc/library/cdecimal.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Doc/library/cdecimal.rst Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,131 @@ +:mod:`cdecimal` --- Decimal fixed point and floating point arithmetic +===================================================================== + +.. module:: cdecimal + :synopsis: C-Implementation of the General Decimal Arithmetic Specification. + +.. moduleauthor:: Stefan Krah + +.. import modules for testing inline doctests with the Sphinx doctest builder +.. testsetup:: * + + import cdecimal + import math + from cdecimal import * + # make sure each group gets a fresh context + setcontext(Context()) + + +The :mod:`cdecimal` module is a C implementation of :mod:`decimal`. Since it is +almost fully compatible with :mod:`decimal`, this documentation will only list +the differences between the two modules. + + +Setting Context Values +---------------------- + +* *prec*, *Emin*, *Emax*, *rounding*, *capitals* and *_clamp* are implemented as + getters/setters. + +* An additional field *_allcr* toggles correct rounding for :meth:`exp`, + :meth:`ln` and :meth:`log10`. + +* *traps* and *flags* have the custom type :class:`SignalDict`, + which behaves like a dictionary for most purposes. This is the familiar + interface from :mod:`decimal`. + +* Internally, *traps* and *flags* are just C unsigned integers. :mod:`cdecimal` + provides the option to access the integers directly using the getters/setters + *_traps* and *_flags*. + +* Use of the two interfaces can be mixed freely. The following table shows + how the :class:`SignalDict` items and the C-flags are related: + + +---------------------------+------------------------------------+--------------------------------+ + | SignalDict | C signals | C conditions | + +===========================+====================================+================================+ + | :const:`InvalidOperation` | :const:`DecIEEEInvalidOperation` | n/a | + +---------------------------+------------------------------------+--------------------------------+ + | n/a | n/a | :const:`DecConversionSyntax` | + +---------------------------+------------------------------------+--------------------------------+ + | n/a | n/a | :const:`DecDivisionImpossible` | + +---------------------------+------------------------------------+--------------------------------+ + | n/a | n/a | :const:`DecDivisionUndefined` | + +---------------------------+------------------------------------+--------------------------------+ + | n/a | n/a | :const:`DecInvalidContext` | + +---------------------------+------------------------------------+--------------------------------+ + | n/a | n/a | :const:`DecInvalidOperation` | + +---------------------------+------------------------------------+--------------------------------+ + | n/a | n/a | :const:`DecMallocError` | + +---------------------------+------------------------------------+--------------------------------+ + | :const:`Clamped` | :const:`DecClamped` | :const:`DecClamped` | + +---------------------------+------------------------------------+--------------------------------+ + | :const:`DivisionByZero` | :const:`DecDivisionByZero` | :const:`DecDivisionByZero` | + +---------------------------+------------------------------------+--------------------------------+ + | :const:`Inexact` | :const:`DecInexact` | :const:`DecInexact` | + +---------------------------+------------------------------------+--------------------------------+ + | :const:`Rounded` | :const:`DecRounded` | :const:`DecRounded` | + +---------------------------+------------------------------------+--------------------------------+ + | :const:`Subnormal` | :const:`DecSubnormal` | :const:`DecSubnormal` | + +---------------------------+------------------------------------+--------------------------------+ + | :const:`Overflow` | :const:`DecOverflow` | :const:`DecOverflow` | + +---------------------------+------------------------------------+--------------------------------+ + | :const:`Underflow` | :const:`DecUnderflow` | :const:`DecUnderflow` | + +---------------------------+------------------------------------+--------------------------------+ + + +Context Limits +-------------- + + ++------------+-----------------+---------------------+------------------------------+ +| | decimal | cdecimal, 32-bit | cdecimal, 64-bit | ++============+=================+=====================+==============================+ +| max *Emax* | unlimited | :const:`425000000` | :const:`999999999999999999` | ++------------+-----------------+---------------------+------------------------------+ +| min *Emin* | unlimited | :const:`-425000000` | :const:`-999999999999999999` | ++------------+-----------------+---------------------+------------------------------+ +| max *prec* | unlimited | :const:`425000000` | :const:`999999999999999999` | ++------------+-----------------+---------------------+------------------------------+ +| min *Etop* | may be negative | :const:`0` | :const:`0` | ++------------+-----------------+---------------------+------------------------------+ + + +*Etop* is only relevant if *_clamp* is set to 1. In this case, the maximum exponent +is defined as *Etop* = *Emax* - (*prec*-1). + + +Thread local default contexts +----------------------------- + +When no context is given, all operations use the default context. In :mod:`decimal`, +this default context is thread local. For :mod:`cdecimal`, thread local default contexts +can be enabled at compile time. However, the performance penalty is so huge that +this is not the default. + +The consequences for threaded programs are: + +* One new context has to be created for each thread. + +* Only context methods or methods that take a context argument can be used. + + +Unlimited reading of decimals +----------------------------- + +The :class:`Decimal` constructor is supposed to read input as if there were no limits. +Since the context of cdecimal has limits, the following approach is used: + +If the :const:`Inexact` or :const:`Rounded` conditions occur during conversion, +:const:`InvalidOperation` is raised and the result is :const:`NaN`. In this case, +the :meth:`create_decimal` context method has to be used. + + +Correct rounding in the power method +------------------------------------ + +The :meth:`power()` method in :mod:`decimal` is correctly rounded. :mod:`cdecimal` +currently only guarantees an error less than one ULP (which is standard conforming). + + + diff -r 5738c611ff2a -r 6a1c8fcce229 Doc/library/numeric.rst --- a/Doc/library/numeric.rst Sat Mar 05 20:31:42 2011 +0100 +++ b/Doc/library/numeric.rst Sun Mar 06 08:37:10 2011 +0100 @@ -8,9 +8,9 @@ The modules described in this chapter provide numeric and math-related functions and data types. The :mod:`numbers` module defines an abstract hierarchy of numeric types. The :mod:`math` and :mod:`cmath` modules contain various -mathematical functions for floating-point and complex numbers. For users more -interested in decimal accuracy than in speed, the :mod:`decimal` module supports -exact representations of decimal numbers. +mathematical functions for floating-point and complex numbers. The :mod:`decimal` +and :mod:`cdecimal` modules support exact representations of decimal numbers, +using arbitrary precision arithmetic. The following modules are documented in this chapter: @@ -20,6 +20,7 @@ numbers.rst math.rst cmath.rst + cdecimal.rst decimal.rst fractions.rst random.rst diff -r 5738c611ff2a -r 6a1c8fcce229 Include/longintrepr.h --- a/Include/longintrepr.h Sat Mar 05 20:31:42 2011 +0100 +++ b/Include/longintrepr.h Sun Mar 06 08:37:10 2011 +0100 @@ -6,7 +6,7 @@ #endif -/* This is published for the benefit of "friend" marshal.c only. */ +/* This is published for the benefit of "friends" marshal.c and cdecimal.c. */ /* Parameters of the long integer representation. There are two different sets of parameters: one set for 30-bit digits, stored in an unsigned 32-bit diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/decimal_tests.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/decimal_tests.py Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,3412 @@ +# 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 and Cdecimal modules. + +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 + +This test module can be called from command line with one parameter (Arithmetic +or Behaviour) to test each part, or without parameter to test both parts. If +you're working through IDLE, you can import this test module and call test_main() +with the corresponding argument. +""" + +import math +import os, sys +import operator +import pickle, copy +import unittest +import numbers +from test.support import run_unittest, run_doctest, is_resource_enabled +import random +try: + import threading +except ImportError: + threading = None + + +if sys.modules['have_cdecimal']: + from cdecimal import * + HAVE_CDECIMAL = True + HAVE_CONFIG_64 = (MAX_EMAX == 999999999999999999) +else: + from decimal import * + HAVE_CDECIMAL = False + HAVE_CONFIG_64 = False + + +if HAVE_CDECIMAL and (not HAVE_CONFIG_64): + readcontext = Context() + readcontext.unsafe_setprec(1070000000) + readcontext.unsafe_setemax(1070000000) + readcontext.unsafe_setemin(-1070000000) + readcontext._traps = 0 + def read_unlimited(v, context): + savetraps = context._traps + saveflags = context._flags + context._traps = 0 + vv = Decimal(v, context) + context._traps = savetraps + if context._flags & DecInvalidOperation: + # Do it the hard way + context._flags = saveflags + vv = readcontext.create_decimal(v) + return vv +else: + def read_unlimited(v, context): + return Decimal(v, context) + +if HAVE_CDECIMAL: + def is_integer(v): + return v.is_integer() + def is_special(v): + return v.is_special() + def raise_error(context, flag): + context.flags[flag] = True + if context.traps[flag]: + raise flag + def make_grouping(lst): + return ''.join([chr(x) for x in lst]) + def get_fmt(x, override=None, fmt='n'): + return Decimal.__format__(Decimal(x), fmt, override) +else: + def is_integer(v): + return v._isinteger() + def is_special(v): + return v._is_special + def raise_error(context, flag): + context._raise_error(flag) + def make_grouping(lst): + return lst + def get_fmt(x, locale, fmt='n'): + return Decimal.__format__(Decimal(x), fmt, _localeconv=locale) + +# Useful Test Constant +Signals = tuple(getcontext().flags.keys()) + +# Signals ordered with respect to precedence: when an operation +# produces multiple signals, signals occurring later in the list +# should be handled before those occurring earlier in the list. +OrderedSignals = (Clamped, Rounded, Inexact, Subnormal, + Underflow, Overflow, DivisionByZero, InvalidOperation) + +# Tests are built around these assumed context defaults. +# test_main() restores the original context. +def init(): + global ORIGINAL_CONTEXT + ORIGINAL_CONTEXT = getcontext().copy() + DefaultTestContext = Context( + prec = 9, + rounding = ROUND_HALF_EVEN, + traps = dict.fromkeys(Signals, 0) + ) + setcontext(DefaultTestContext) + +# decorator for skipping tests on non-IEEE 754 platforms +requires_IEEE_754 = unittest.skipUnless( + float.__getformat__("double").startswith("IEEE"), + "test requires IEEE 754 doubles") + +TESTDATADIR = 'decimaltestdata' +if __name__ == '__main__': + file = sys.argv[0] +else: + file = __file__ +testdir = os.path.dirname(file) or os.curdir +directory = testdir + os.sep + TESTDATADIR + os.sep + +skip_expected = not os.path.isdir(directory) + +# list of individual .decTest test ids that correspond to tests that +# we're skipping for one reason or another. +skipped_test_ids = [ + 'scbx164', # skipping apparently implementation-specific scaleb + 'scbx165', # tests, pending clarification of scaleb rules. +] + +# XXX: BEGIN CDECIMAL SKIPS +cdecimal_status_diff = {} +cdecimal_result_diff = {} +cdecimal_skipped_disagreements = [] +if HAVE_CDECIMAL: + if HAVE_CONFIG_64: + # 64 bit version: With a reduced working precision in mpd_qpow() + # the status matches. + cdecimal_status_diff = { + "pwsx803": ([Inexact, Rounded, Subnormal, Underflow], + [Inexact, Rounded]), + "pwsx805": ([Inexact, Rounded, Subnormal, Underflow], + [Inexact, Rounded]) + } + # These are skipped for decNumber, too. + cdecimal_result_diff = { + "powx4302": ("1.000000", "1.000001"), + "powx4303": ("1.000000", "1.000001"), + "powx4342": ("1.000000", "0.9999999"), + "powx4343": ("1.000000", "0.9999999") + } + # Disagreements: + # http://bugs.python.org/issue7049 + cdecimal_skipped_disagreements = ['pwmx325', 'pwmx326'] +# END CDECIMAL SKIPS + +# Make sure it actually raises errors when not expected and caught in flags +# Slower, since it runs some things several times. +EXTENDEDERRORTEST = False + +#Map the test cases' error names to the actual errors +ErrorNames = {'clamped' : Clamped, + 'conversion_syntax' : InvalidOperation, + 'division_by_zero' : DivisionByZero, + 'division_impossible' : InvalidOperation, + 'division_undefined' : InvalidOperation, + 'inexact' : Inexact, + 'invalid_context' : InvalidOperation, + 'invalid_operation' : InvalidOperation, + 'overflow' : Overflow, + 'rounded' : Rounded, + 'subnormal' : Subnormal, + 'underflow' : Underflow} + + +def Nonfunction(*args): + """Doesn't do anything.""" + return None + +RoundingDict = {'ceiling' : ROUND_CEILING, #Maps test-case names to roundings. + 'down' : ROUND_DOWN, + 'floor' : ROUND_FLOOR, + 'half_down' : ROUND_HALF_DOWN, + 'half_even' : ROUND_HALF_EVEN, + 'half_up' : ROUND_HALF_UP, + 'up' : ROUND_UP, + '05up' : ROUND_05UP} + +# Name adapter to be able to change the Decimal and Context +# interface without changing the test files from Cowlishaw +nameAdapter = {'and':'logical_and', + 'apply':'_apply', + 'class':'number_class', + 'comparesig':'compare_signal', + 'comparetotal':'compare_total', + 'comparetotmag':'compare_total_mag', + 'copy':'copy_decimal', + 'copyabs':'copy_abs', + 'copynegate':'copy_negate', + 'copysign':'copy_sign', + 'divideint':'divide_int', + 'invert':'logical_invert', + 'iscanonical':'is_canonical', + 'isfinite':'is_finite', + 'isinfinite':'is_infinite', + 'isnan':'is_nan', + 'isnormal':'is_normal', + 'isqnan':'is_qnan', + 'issigned':'is_signed', + 'issnan':'is_snan', + 'issubnormal':'is_subnormal', + 'iszero':'is_zero', + 'maxmag':'max_mag', + 'minmag':'min_mag', + 'nextminus':'next_minus', + 'nextplus':'next_plus', + 'nexttoward':'next_toward', + 'or':'logical_or', + 'reduce':'normalize', + 'remaindernear':'remainder_near', + 'samequantum':'same_quantum', + 'squareroot':'sqrt', + 'toeng':'to_eng_string', + 'tointegral':'to_integral_value', + 'tointegralx':'to_integral_exact', + 'tosci':'to_sci_string', + 'xor':'logical_xor', + } + +# The following functions return True/False rather than a Decimal instance + +LOGICAL_FUNCTIONS = ( + 'is_canonical', + 'is_finite', + 'is_infinite', + 'is_nan', + 'is_normal', + 'is_qnan', + 'is_signed', + 'is_snan', + 'is_subnormal', + 'is_zero', + 'same_quantum', + ) + +# For some operations (currently exp, ln, log10, power), the decNumber +# reference implementation imposes additional restrictions on the +# context and operands. These restrictions are not part of the +# specification; however, the effect of these restrictions does show +# up in some of the testcases. We skip testcases that violate these +# restrictions, since Decimal behaves differently from decNumber for +# these testcases so these testcases would otherwise fail. + +decNumberRestricted = ('power', 'ln', 'log10', 'exp') +DEC_MAX_MATH = 999999 +def outside_decNumber_bounds(v, context): + if (context.prec > DEC_MAX_MATH or + context.Emax > DEC_MAX_MATH or + -context.Emin > DEC_MAX_MATH): + return True + if not is_special(v) and v and ( + v.adjusted() > DEC_MAX_MATH or + v.adjusted() < 1-2*DEC_MAX_MATH): + return True + return False + +class DecimalTest(unittest.TestCase): + """Class which tests the Decimal class against the test cases. + + Changed for unittest. + """ + def setUp(self): + self.context = Context() + self.ignore_list = ['#'] + # Basically, a # means return NaN InvalidOperation. + # Different from a sNaN in trim + + self.ChangeDict = {'precision' : self.change_precision, + 'rounding' : self.change_rounding_method, + 'maxexponent' : self.change_max_exponent, + 'minexponent' : self.change_min_exponent, + 'clamp' : self.change_clamp} + + def eval_file(self, file): + global skip_expected + if skip_expected: + raise unittest.SkipTest + return + with open(file) as f: + for line in f: + line = line.replace('\r\n', '').replace('\n', '') + #print line + try: + t = self.eval_line(line) + except DecimalException as exception: + #Exception raised where there shoudn't have been one. + self.fail('Exception "'+exception.__class__.__name__ + '" raised on line '+line) + + return + + def eval_line(self, s): + if s.find(' -> ') >= 0 and s[:2] != '--' and not s.startswith(' --'): + s = (s.split('->')[0] + '->' + + s.split('->')[1].split('--')[0]).strip() + else: + s = s.split('--')[0].strip() + + for ignore in self.ignore_list: + if s.find(ignore) >= 0: + #print s.split()[0], 'NotImplemented--', ignore + return + if not s: + return + elif ':' in s: + return self.eval_directive(s) + else: + return self.eval_equation(s) + + def eval_directive(self, s): + funct, value = (x.strip().lower() for x in s.split(':')) + if funct == 'rounding': + value = RoundingDict[value] + else: + try: + value = int(value) + except ValueError: + pass + + funct = self.ChangeDict.get(funct, Nonfunction) + funct(value) + + def eval_equation(self, s): + #global DEFAULT_PRECISION + #print DEFAULT_PRECISION + + if not TEST_ALL and random.random() < 0.90: + return + + try: + Sides = s.split('->') + L = Sides[0].strip().split() + id = L[0] + if DEBUG: + print("Test ", id, end=" ") + funct = L[1].lower() + valstemp = L[2:] + L = Sides[1].strip().split() + ans = L[0] + exceptions = L[1:] + except (TypeError, AttributeError, IndexError): + raise InvalidOperation + def FixQuotes(val): + val = val.replace("''", 'SingleQuote').replace('""', 'DoubleQuote') + val = val.replace("'", '').replace('"', '') + val = val.replace('SingleQuote', "'").replace('DoubleQuote', '"') + return val + + if id in skipped_test_ids or id in cdecimal_skipped_disagreements: # XXX + return + + fname = nameAdapter.get(funct, funct) + if fname == 'rescale': + return + funct = getattr(self.context, fname) + vals = [] + conglomerate = '' + quote = 0 + theirexceptions = [ErrorNames[x.lower()] for x in exceptions] + if id in cdecimal_status_diff: # XXX + t = cdecimal_status_diff[id] + theirexceptions = t[0] + + for exception in Signals: + self.context.traps[exception] = 1 #Catch these bugs... + for exception in theirexceptions: + self.context.traps[exception] = 0 + for i, val in enumerate(valstemp): + if val.count("'") % 2 == 1: + quote = 1 - quote + if quote: + conglomerate = conglomerate + ' ' + val + continue + else: + val = conglomerate + val + conglomerate = '' + v = FixQuotes(val) + if fname in ('to_sci_string', 'to_eng_string'): + if EXTENDEDERRORTEST: + for error in theirexceptions: + self.context.traps[error] = 1 + try: + funct(self.context.create_decimal(v)) + except error: + pass + except Signals as e: + self.fail("Raised %s in %s when %s disabled" % \ + (e, s, error)) + else: + self.fail("Did not raise %s in %s" % (error, s)) + self.context.traps[error] = 0 + v = self.context.create_decimal(v) + else: + v = read_unlimited(v, self.context) # XXX + vals.append(v) + + ans = FixQuotes(ans) + + # XXX: three argument power/powmod + if HAVE_CDECIMAL: + if fname == 'power' and len(vals) == 3: + # name is different + fname = 'powmod' + funct = getattr(self.context, fname) + + # skip tests that are related to bounds imposed in the decNumber + # reference implementation + if fname in decNumberRestricted: + if fname == 'power': + if not (is_integer(vals[1]) and + -1999999997 <= vals[1] <= 999999999): + if outside_decNumber_bounds(vals[0], self.context) or \ + outside_decNumber_bounds(vals[1], self.context): + #print "Skipping test %s" % s + return + else: + if outside_decNumber_bounds(vals[0], self.context): + #print "Skipping test %s" % s + return + + + if EXTENDEDERRORTEST and fname not in ('to_sci_string', 'to_eng_string'): + for error in theirexceptions: + self.context.traps[error] = 1 + try: + funct(*vals) + except error: + pass + except Signals as e: + self.fail("Raised %s in %s when %s disabled" % \ + (e, s, error)) + else: + self.fail("Did not raise %s in %s" % (error, s)) + self.context.traps[error] = 0 + + # as above, but add traps cumulatively, to check precedence + ordered_errors = [e for e in OrderedSignals if e in theirexceptions] + for error in ordered_errors: + self.context.traps[error] = 1 + try: + funct(*vals) + except error: + pass + except Signals as e: + self.fail("Raised %s in %s; expected %s" % + (type(e), s, error)) + else: + self.fail("Did not raise %s in %s" % (error, s)) + # reset traps + for error in ordered_errors: + self.context.traps[error] = 0 + + if DEBUG: + print("--", self.context) + try: + result = str(funct(*vals)) + if fname in LOGICAL_FUNCTIONS: + result = str(int(eval(result))) # 'True', 'False' -> '1', '0' + except Signals as error: + self.fail("Raised %s in %s" % (error, s)) + except: #Catch any error long enough to state the test case. + print("ERROR:", s) + raise + + myexceptions = self.getexceptions() + self.context.clear_flags() + + myexceptions.sort(key=repr) + theirexceptions.sort(key=repr) + + if id in cdecimal_result_diff: # XXX + t = cdecimal_result_diff[id] + self.assertTrue(result == t[0] and ans == t[1]) + else: + self.assertEqual(result, ans, + 'Incorrect answer for ' + s + ' -- got ' + result) + + self.assertEqual(myexceptions, theirexceptions, + 'Incorrect flags set in ' + s + ' -- got ' + str(myexceptions)) + return + + def getexceptions(self): + return [e for e in Signals if self.context.flags[e]] + + def change_precision(self, prec): + if (not HAVE_CDECIMAL) or HAVE_CONFIG_64: + self.context.prec = prec + else: # XXX + self.context.unsafe_setprec(prec) + def change_rounding_method(self, rounding): + self.context.rounding = rounding + def change_min_exponent(self, exp): + if (not HAVE_CDECIMAL) or HAVE_CONFIG_64: + self.context.Emin = exp + else: # XXX + self.context.unsafe_setemin(exp) + def change_max_exponent(self, exp): + if (not HAVE_CDECIMAL) or HAVE_CONFIG_64: + self.context.Emax = exp + else: # XXX + self.context.unsafe_setemax(exp) + def change_clamp(self, clamp): + self.context._clamp = clamp + + + +# The following classes test the behaviour of Decimal according to PEP 327 + +class DecimalExplicitConstructionTest(unittest.TestCase): + '''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 + d = Decimal(45) + self.assertEqual(str(d), '45') + + #very large positive + d = Decimal(500000123) + self.assertEqual(str(d), '500000123') + + #negative + d = Decimal(-45) + self.assertEqual(str(d), '-45') + + #zero + d = Decimal(0) + self.assertEqual(str(d), '0') + + def test_explicit_from_string(self): + + #empty + self.assertEqual(str(Decimal('')), 'NaN') + + #int + self.assertEqual(str(Decimal('45')), '45') + + #float + self.assertEqual(str(Decimal('45.34')), '45.34') + + #engineer notation + self.assertEqual(str(Decimal('45e2')), '4.5E+3') + + #just not a number + self.assertEqual(str(Decimal('ugly')), 'NaN') + + #leading and trailing whitespace permitted + self.assertEqual(str(Decimal('1.3E4 \n')), '1.3E+4') + self.assertEqual(str(Decimal(' -7.89')), '-7.89') + self.assertEqual(str(Decimal(" 3.45679 ")), '3.45679') + + with localcontext() as c: + c.traps[InvalidOperation] = True + # Invalid string + self.assertRaises(InvalidOperation, Decimal, "xyz") + # Two arguments max + self.assertRaises(TypeError, Decimal, "1234", "x", "y") + if HAVE_CDECIMAL: + # Too large for cdecimal to be converted exactly + self.assertRaises(InvalidOperation, Decimal, + "1e9999999999999999999") + + def test_explicit_from_tuples(self): + + #zero + d = Decimal( (0, (0,), 0) ) + self.assertEqual(str(d), '0') + + #int + d = Decimal( (1, (4, 5), 0) ) + self.assertEqual(str(d), '-45') + + #float + d = Decimal( (0, (4, 5, 3, 4), -2) ) + self.assertEqual(str(d), '45.34') + + #weird + d = Decimal( (1, (4, 3, 4, 9, 1, 3, 5, 3, 4), -25) ) + self.assertEqual(str(d), '-4.34913534E-17') + + #inf + d = Decimal( (0, (), "F") ) + self.assertEqual(str(d), 'Infinity') + + #wrong number of items + self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, 9, 1)) ) + + #bad sign + self.assertRaises(ValueError, Decimal, (8, (4, 3, 4, 9, 1), 2) ) + self.assertRaises(ValueError, Decimal, (0., (4, 3, 4, 9, 1), 2) ) + self.assertRaises(ValueError, Decimal, (Decimal(1), (4, 3, 4, 9, 1), 2)) + + #bad exp + self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, 9, 1), 'wrong!') ) + self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, 9, 1), 0.) ) + self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, 9, 1), '1') ) + + #bad coefficients + self.assertRaises(ValueError, Decimal, (1, "xyz", 2) ) + self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, None, 1), 2) ) + self.assertRaises(ValueError, Decimal, (1, (4, -3, 4, 9, 1), 2) ) + self.assertRaises(ValueError, Decimal, (1, (4, 10, 4, 9, 1), 2) ) + self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, 'a', 1), 2) ) + + def test_explicit_from_bool(self): + self.assertIs(bool(Decimal(0)), False) + self.assertIs(bool(Decimal(1)), True) + self.assertEqual(Decimal(False), Decimal(0)) + self.assertEqual(Decimal(True), Decimal(1)) + + def test_explicit_from_Decimal(self): + + #positive + d = Decimal(45) + e = Decimal(d) + self.assertEqual(str(e), '45') + + #very large positive + d = Decimal(500000123) + e = Decimal(d) + self.assertEqual(str(e), '500000123') + + #negative + d = Decimal(-45) + e = Decimal(d) + self.assertEqual(str(e), '-45') + + #zero + d = Decimal(0) + e = Decimal(d) + self.assertEqual(str(e), '0') + + @requires_IEEE_754 + def test_explicit_from_float(self): + if HAVE_CDECIMAL: + with localcontext() as c: + c.clear_flags() + self.assertEqual(Decimal(7.5), 7.5) + self.assertTrue(c.flags[FloatOperation]) + + c.traps[FloatOperation] = True + self.assertRaises(FloatOperation, Decimal, 7.5) + self.assertTrue(c.flags[FloatOperation]) + + r = Decimal(0.1) + self.assertEqual(type(r), Decimal) + self.assertEqual(str(r), + '0.1000000000000000055511151231257827021181583404541015625') + self.assertTrue(Decimal(float('nan')).is_qnan()) + self.assertTrue(Decimal(float('inf')).is_infinite()) + self.assertTrue(Decimal(float('-inf')).is_infinite()) + self.assertEqual(str(Decimal(float('nan'))), + str(Decimal('NaN'))) + self.assertEqual(str(Decimal(float('inf'))), + str(Decimal('Infinity'))) + self.assertEqual(str(Decimal(float('-inf'))), + str(Decimal('-Infinity'))) + self.assertEqual(str(Decimal(float('-0.0'))), + str(Decimal('-0'))) + for i in range(200): + x = random.expovariate(0.01) * (random.random() * 2.0 - 1.0) + self.assertEqual(x, float(Decimal(x))) # roundtrip + + def test_explicit_context_create_decimal(self): + + nc = copy.copy(getcontext()) + nc.prec = 3 + + # empty + d = Decimal() + self.assertEqual(str(d), '0') + d = nc.create_decimal() + self.assertEqual(str(d), '0') + + # from None + self.assertRaises(TypeError, nc.create_decimal, None) + + # from int + d = nc.create_decimal(456) + self.assertIsInstance(d, Decimal) + self.assertEqual(nc.create_decimal(45678), + nc.create_decimal('457E+2')) + + # from string + d = Decimal('456789') + self.assertEqual(str(d), '456789') + d = nc.create_decimal('456789') + self.assertEqual(str(d), '4.57E+5') + # leading and trailing whitespace should result in a NaN; + # spaces are already checked in Cowlishaw's test-suite, so + # here we just check that a trailing newline results in a NaN + self.assertEqual(str(nc.create_decimal('3.14\n')), 'NaN') + + # from tuples + d = Decimal( (1, (4, 3, 4, 9, 1, 3, 5, 3, 4), -25) ) + self.assertEqual(str(d), '-4.34913534E-17') + d = nc.create_decimal( (1, (4, 3, 4, 9, 1, 3, 5, 3, 4), -25) ) + self.assertEqual(str(d), '-4.35E-17') + + # from Decimal + prevdec = Decimal(500000123) + d = Decimal(prevdec) + self.assertEqual(str(d), '500000123') + d = nc.create_decimal(prevdec) + self.assertEqual(str(d), '5.00E+8') + + # more integers + nc.prec = 28 + nc.traps[InvalidOperation] = True + + for v in [-2**63-1, -2**63, -2**31-1, -2**31, 0, + 2**31-1, 2**31, 2**63-1, 2**63]: + d = nc.create_decimal(v) + self.assertTrue(isinstance(d, Decimal)) + self.assertEqual(int(d), v) + + nc.prec = 3 + nc.traps[Rounded] = True + self.assertRaises(Rounded, nc.create_decimal, 1234) + + # from string + nc.prec = 28 + self.assertEqual(str(nc.create_decimal('0E-017')), '0E-17') + self.assertEqual(str(nc.create_decimal('45')), '45') + self.assertEqual(str(nc.create_decimal('-Inf')), '-Infinity') + self.assertEqual(str(nc.create_decimal('NaN123')), 'NaN123') + + # invalid arguments + self.assertRaises(InvalidOperation, nc.create_decimal, "xyz") + self.assertRaises(ValueError, nc.create_decimal, (1, "xyz", -25)) + if HAVE_CDECIMAL: # decimal.py accepts lists. + self.assertRaises(TypeError, nc.create_decimal, ["%"]) + self.assertRaises(TypeError, nc.create_decimal, "1234", "5678") + + def test_explicit_context_create_from_float(self): + nc = Context() + if HAVE_CDECIMAL: + nc.clear_flags() + self.assertEqual(nc.create_decimal(7.5), 7.5) + self.assertTrue(nc.flags[FloatOperation]) + + nc.traps[FloatOperation] = True + self.assertRaises(FloatOperation, nc.create_decimal, 7.5) + self.assertTrue(nc.flags[FloatOperation]) + nc.traps[FloatOperation] = False + + r = nc.create_decimal(0.1) + self.assertEqual(type(r), Decimal) + self.assertEqual(str(r), '0.1000000000000000055511151231') + self.assertTrue(nc.create_decimal(float('nan')).is_qnan()) + self.assertTrue(nc.create_decimal(float('inf')).is_infinite()) + self.assertTrue(nc.create_decimal(float('-inf')).is_infinite()) + self.assertEqual(str(nc.create_decimal(float('nan'))), + str(nc.create_decimal('NaN'))) + self.assertEqual(str(nc.create_decimal(float('inf'))), + str(nc.create_decimal('Infinity'))) + self.assertEqual(str(nc.create_decimal(float('-inf'))), + str(nc.create_decimal('-Infinity'))) + self.assertEqual(str(nc.create_decimal(float('-0.0'))), + str(nc.create_decimal('-0'))) + nc.prec = 100 + for i in range(200): + x = random.expovariate(0.01) * (random.random() * 2.0 - 1.0) + self.assertEqual(x, float(nc.create_decimal(x))) # roundtrip + + def test_unicode_digits(self): + test_values = { + '\uff11': '1', + '\u0660.\u0660\u0663\u0667\u0662e-\u0663' : '0.0000372', + '-nan\u0c68\u0c6a\u0c66\u0c66' : '-NaN2400', + } + for input, expected in test_values.items(): + self.assertEqual(str(Decimal(input)), expected) + + +class DecimalImplicitConstructionTest(unittest.TestCase): + '''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)) + + def test_rop(self): + # Allow other classes to be trained to interact with Decimals + class E: + def __divmod__(self, other): + return 'divmod ' + str(other) + def __rdivmod__(self, other): + return str(other) + ' rdivmod' + def __lt__(self, other): + return 'lt ' + str(other) + def __gt__(self, other): + return 'gt ' + str(other) + def __le__(self, other): + return 'le ' + str(other) + def __ge__(self, other): + return 'ge ' + str(other) + def __eq__(self, other): + return 'eq ' + str(other) + def __ne__(self, other): + return 'ne ' + str(other) + + self.assertEqual(divmod(E(), Decimal(10)), 'divmod 10') + self.assertEqual(divmod(Decimal(10), E()), '10 rdivmod') + self.assertEqual(eval('Decimal(10) < E()'), 'gt 10') + self.assertEqual(eval('Decimal(10) > E()'), 'lt 10') + self.assertEqual(eval('Decimal(10) <= E()'), 'ge 10') + self.assertEqual(eval('Decimal(10) >= E()'), 'le 10') + self.assertEqual(eval('Decimal(10) == E()'), 'eq 10') + self.assertEqual(eval('Decimal(10) != E()'), 'ne 10') + + # insert operator methods and then exercise them + oplist = [ + ('+', '__add__', '__radd__'), + ('-', '__sub__', '__rsub__'), + ('*', '__mul__', '__rmul__'), + ('/', '__truediv__', '__rtruediv__'), + ('%', '__mod__', '__rmod__'), + ('//', '__floordiv__', '__rfloordiv__'), + ('**', '__pow__', '__rpow__') + ] + + for sym, lop, rop in oplist: + setattr(E, lop, lambda self, other: 'str' + lop + str(other)) + setattr(E, rop, lambda self, other: str(other) + rop + 'str') + self.assertEqual(eval('E()' + sym + 'Decimal(10)'), + 'str' + lop + '10') + self.assertEqual(eval('Decimal(10)' + sym + 'E()'), + '10' + rop + 'str') + + +class DecimalFormatTest(unittest.TestCase): + '''Unit tests for the format function.''' + def test_formatting(self): + # triples giving a format, a Decimal, and the expected result + test_values = [ + ('e', '0E-15', '0e-15'), + ('e', '2.3E-15', '2.3e-15'), + ('e', '2.30E+2', '2.30e+2'), # preserve significant zeros + ('e', '2.30000E-15', '2.30000e-15'), + ('e', '1.23456789123456789e40', '1.23456789123456789e+40'), + ('e', '1.5', '1.5e+0'), + ('e', '0.15', '1.5e-1'), + ('e', '0.015', '1.5e-2'), + ('e', '0.0000000000015', '1.5e-12'), + ('e', '15.0', '1.50e+1'), + ('e', '-15', '-1.5e+1'), + ('e', '0', '0e+0'), + ('e', '0E1', '0e+1'), + ('e', '0.0', '0e-1'), + ('e', '0.00', '0e-2'), + ('.6e', '0E-15', '0.000000e-9'), + ('.6e', '0', '0.000000e+6'), + ('.6e', '9.999999', '9.999999e+0'), + ('.6e', '9.9999999', '1.000000e+1'), + ('.6e', '-1.23e5', '-1.230000e+5'), + ('.6e', '1.23456789e-3', '1.234568e-3'), + ('f', '0', '0'), + ('f', '0.0', '0.0'), + ('f', '0E-2', '0.00'), + ('f', '0.00E-8', '0.0000000000'), + ('f', '0E1', '0'), # loses exponent information + ('f', '3.2E1', '32'), + ('f', '3.2E2', '320'), + ('f', '3.20E2', '320'), + ('f', '3.200E2', '320.0'), + ('f', '3.2E-6', '0.0000032'), + ('.6f', '0E-15', '0.000000'), # all zeros treated equally + ('.6f', '0E1', '0.000000'), + ('.6f', '0', '0.000000'), + ('.0f', '0', '0'), # no decimal point + ('.0f', '0e-2', '0'), + ('.0f', '3.14159265', '3'), + ('.1f', '3.14159265', '3.1'), + ('.4f', '3.14159265', '3.1416'), + ('.6f', '3.14159265', '3.141593'), + ('.7f', '3.14159265', '3.1415926'), # round-half-even! + ('.8f', '3.14159265', '3.14159265'), + ('.9f', '3.14159265', '3.141592650'), + + ('g', '0', '0'), + ('g', '0.0', '0.0'), + ('g', '0E1', '0e+1'), + ('G', '0E1', '0E+1'), + ('g', '0E-5', '0.00000'), + ('g', '0E-6', '0.000000'), + ('g', '0E-7', '0e-7'), + ('g', '-0E2', '-0e+2'), + ('.0g', '3.14159265', '3'), # 0 sig fig -> 1 sig fig + ('.1g', '3.14159265', '3'), + ('.2g', '3.14159265', '3.1'), + ('.5g', '3.14159265', '3.1416'), + ('.7g', '3.14159265', '3.141593'), + ('.8g', '3.14159265', '3.1415926'), # round-half-even! + ('.9g', '3.14159265', '3.14159265'), + ('.10g', '3.14159265', '3.14159265'), # don't pad + + ('%', '0E1', '0%'), + ('%', '0E0', '0%'), + ('%', '0E-1', '0%'), + ('%', '0E-2', '0%'), + ('%', '0E-3', '0.0%'), + ('%', '0E-4', '0.00%'), + + ('.3%', '0', '0.000%'), # all zeros treated equally + ('.3%', '0E10', '0.000%'), + ('.3%', '0E-10', '0.000%'), + ('.3%', '2.34', '234.000%'), + ('.3%', '1.234567', '123.457%'), + ('.0%', '1.23', '123%'), + + ('e', 'NaN', 'NaN'), + ('f', '-NaN123', '-NaN123'), + ('+g', 'NaN456', '+NaN456'), + ('.3e', 'Inf', 'Infinity'), + ('.16f', '-Inf', '-Infinity'), + ('.0g', '-sNaN', '-sNaN'), + + ('', '1.00', '1.00'), + + # test alignment and padding + ('6', '123', ' 123'), + ('<6', '123', '123 '), + ('>6', '123', ' 123'), + ('^6', '123', ' 123 '), + ('=+6', '123', '+ 123'), + ('#<10', 'NaN', 'NaN#######'), + ('#<10', '-4.3', '-4.3######'), + ('#<+10', '0.0130', '+0.0130###'), + ('#< 10', '0.0130', ' 0.0130###'), + ('@>10', '-Inf', '@-Infinity'), + ('#>5', '-Inf', '-Infinity'), + ('?^5', '123', '?123?'), + ('%^6', '123', '%123%%'), + (' ^6', '-45.6', '-45.6 '), + ('/=10', '-45.6', '-/////45.6'), + ('/=+10', '45.6', '+/////45.6'), + ('/= 10', '45.6', ' /////45.6'), + + # thousands separator + (',', '1234567', '1,234,567'), + (',', '123456', '123,456'), + (',', '12345', '12,345'), + (',', '1234', '1,234'), + (',', '123', '123'), + (',', '12', '12'), + (',', '1', '1'), + (',', '0', '0'), + (',', '-1234567', '-1,234,567'), + (',', '-123456', '-123,456'), + ('7,', '123456', '123,456'), + ('8,', '123456', ' 123,456'), + ('08,', '123456', '0,123,456'), # special case: extra 0 needed + ('+08,', '123456', '+123,456'), # but not if there's a sign + (' 08,', '123456', ' 123,456'), + ('08,', '-123456', '-123,456'), + ('+09,', '123456', '+0,123,456'), + # ... with fractional part... + ('07,', '1234.56', '1,234.56'), + ('08,', '1234.56', '1,234.56'), + ('09,', '1234.56', '01,234.56'), + ('010,', '1234.56', '001,234.56'), + ('011,', '1234.56', '0,001,234.56'), + ('012,', '1234.56', '0,001,234.56'), + ('08,.1f', '1234.5', '01,234.5'), + # no thousands separators in fraction part + (',', '1.23456789', '1.23456789'), + (',%', '123.456789', '12,345.6789%'), + (',e', '123456', '1.23456e+5'), + (',E', '123456', '1.23456E+5'), + + # issue 6850 + ('a=-7.0', '0.12345', 'aaaa0.1'), + ] + for fmt, d, result in test_values: + self.assertEqual(format(Decimal(d), fmt), result) + + def test_n_format(self): + try: + from locale import CHAR_MAX + except ImportError: + return + + # Set up some localeconv-like dictionaries + en_US = { + 'decimal_point' : '.', + 'grouping' : make_grouping([3, 3, 0]), + 'thousands_sep' : ',' + } + + fr_FR = { + 'decimal_point' : ',', + 'grouping' : make_grouping([CHAR_MAX]), + 'thousands_sep' : '' + } + + ru_RU = { + 'decimal_point' : ',', + 'grouping': make_grouping([3, 3, 0]), + 'thousands_sep' : ' ' + } + + crazy = { + 'decimal_point' : '&', + 'grouping': make_grouping([1, 4, 2, CHAR_MAX]), + 'thousands_sep' : '-' + } + + dotsep_wide = { + 'decimal_point' : b'\xc2\xbf'.decode('utf-8'), + 'grouping': make_grouping([3, 3, 0]), + 'thousands_sep' : b'\xc2\xb4'.decode('utf-8') + } + + self.assertEqual(get_fmt(Decimal('12.7'), en_US), '12.7') + self.assertEqual(get_fmt(Decimal('12.7'), fr_FR), '12,7') + self.assertEqual(get_fmt(Decimal('12.7'), ru_RU), '12,7') + self.assertEqual(get_fmt(Decimal('12.7'), crazy), '1-2&7') + + self.assertEqual(get_fmt(123456789, en_US), '123,456,789') + self.assertEqual(get_fmt(123456789, fr_FR), '123456789') + self.assertEqual(get_fmt(123456789, ru_RU), '123 456 789') + self.assertEqual(get_fmt(1234567890123, crazy), '123456-78-9012-3') + + self.assertEqual(get_fmt(123456789, en_US, '.6n'), '1.23457e+8') + self.assertEqual(get_fmt(123456789, fr_FR, '.6n'), '1,23457e+8') + self.assertEqual(get_fmt(123456789, ru_RU, '.6n'), '1,23457e+8') + self.assertEqual(get_fmt(123456789, crazy, '.6n'), '1&23457e+8') + + # zero padding + self.assertEqual(get_fmt(1234, fr_FR, '03n'), '1234') + self.assertEqual(get_fmt(1234, fr_FR, '04n'), '1234') + self.assertEqual(get_fmt(1234, fr_FR, '05n'), '01234') + self.assertEqual(get_fmt(1234, fr_FR, '06n'), '001234') + + self.assertEqual(get_fmt(12345, en_US, '05n'), '12,345') + self.assertEqual(get_fmt(12345, en_US, '06n'), '12,345') + self.assertEqual(get_fmt(12345, en_US, '07n'), '012,345') + self.assertEqual(get_fmt(12345, en_US, '08n'), '0,012,345') + self.assertEqual(get_fmt(12345, en_US, '09n'), '0,012,345') + self.assertEqual(get_fmt(12345, en_US, '010n'), '00,012,345') + + self.assertEqual(get_fmt(123456, crazy, '06n'), '1-2345-6') + self.assertEqual(get_fmt(123456, crazy, '07n'), '1-2345-6') + self.assertEqual(get_fmt(123456, crazy, '08n'), '1-2345-6') + self.assertEqual(get_fmt(123456, crazy, '09n'), '01-2345-6') + self.assertEqual(get_fmt(123456, crazy, '010n'), '0-01-2345-6') + self.assertEqual(get_fmt(123456, crazy, '011n'), '0-01-2345-6') + self.assertEqual(get_fmt(123456, crazy, '012n'), '00-01-2345-6') + self.assertEqual(get_fmt(123456, crazy, '013n'), '000-01-2345-6') + + # wide char separator and decimal point + self.assertEqual(get_fmt(Decimal('-1.5'), dotsep_wide, '020n'), + '-0´000´000´000´001¿5') + +class DecimalArithmeticOperatorsTest(unittest.TestCase): + '''Unit tests for all arithmetic operators, binary and unary.''' + + def test_addition(self): + + d1 = Decimal('-11.1') + d2 = Decimal('22.2') + + #two Decimals + self.assertEqual(d1+d2, Decimal('11.1')) + self.assertEqual(d2+d1, Decimal('11.1')) + + #with other type, left + c = d1 + 5 + self.assertEqual(c, Decimal('-6.1')) + self.assertEqual(type(c), type(d1)) + + #with other type, right + c = 5 + d1 + self.assertEqual(c, Decimal('-6.1')) + self.assertEqual(type(c), type(d1)) + + #inline with decimal + d1 += d2 + self.assertEqual(d1, Decimal('11.1')) + + #inline with other type + d1 += 5 + self.assertEqual(d1, Decimal('16.1')) + + def test_subtraction(self): + + d1 = Decimal('-11.1') + d2 = Decimal('22.2') + + #two Decimals + self.assertEqual(d1-d2, Decimal('-33.3')) + self.assertEqual(d2-d1, Decimal('33.3')) + + #with other type, left + c = d1 - 5 + self.assertEqual(c, Decimal('-16.1')) + self.assertEqual(type(c), type(d1)) + + #with other type, right + c = 5 - d1 + self.assertEqual(c, Decimal('16.1')) + self.assertEqual(type(c), type(d1)) + + #inline with decimal + d1 -= d2 + self.assertEqual(d1, Decimal('-33.3')) + + #inline with other type + d1 -= 5 + self.assertEqual(d1, Decimal('-38.3')) + + def test_multiplication(self): + + d1 = Decimal('-5') + d2 = Decimal('3') + + #two Decimals + self.assertEqual(d1*d2, Decimal('-15')) + self.assertEqual(d2*d1, Decimal('-15')) + + #with other type, left + c = d1 * 5 + self.assertEqual(c, Decimal('-25')) + self.assertEqual(type(c), type(d1)) + + #with other type, right + c = 5 * d1 + self.assertEqual(c, Decimal('-25')) + self.assertEqual(type(c), type(d1)) + + #inline with decimal + d1 *= d2 + self.assertEqual(d1, Decimal('-15')) + + #inline with other type + d1 *= 5 + self.assertEqual(d1, Decimal('-75')) + + def test_division(self): + + d1 = Decimal('-5') + d2 = Decimal('2') + + #two Decimals + self.assertEqual(d1/d2, Decimal('-2.5')) + self.assertEqual(d2/d1, Decimal('-0.4')) + + #with other type, left + c = d1 / 4 + self.assertEqual(c, Decimal('-1.25')) + self.assertEqual(type(c), type(d1)) + + #with other type, right + c = 4 / d1 + self.assertEqual(c, Decimal('-0.8')) + self.assertEqual(type(c), type(d1)) + + #inline with decimal + d1 /= d2 + self.assertEqual(d1, Decimal('-2.5')) + + #inline with other type + d1 /= 4 + self.assertEqual(d1, Decimal('-0.625')) + + def test_floor_division(self): + + d1 = Decimal('5') + d2 = Decimal('2') + + #two Decimals + self.assertEqual(d1//d2, Decimal('2')) + self.assertEqual(d2//d1, Decimal('0')) + + #with other type, left + c = d1 // 4 + self.assertEqual(c, Decimal('1')) + self.assertEqual(type(c), type(d1)) + + #with other type, right + c = 7 // d1 + self.assertEqual(c, Decimal('1')) + self.assertEqual(type(c), type(d1)) + + #inline with decimal + d1 //= d2 + self.assertEqual(d1, Decimal('2')) + + #inline with other type + d1 //= 2 + self.assertEqual(d1, Decimal('1')) + + def test_powering(self): + + d1 = Decimal('5') + d2 = Decimal('2') + + #two Decimals + self.assertEqual(d1**d2, Decimal('25')) + self.assertEqual(d2**d1, Decimal('32')) + + #with other type, left + c = d1 ** 4 + self.assertEqual(c, Decimal('625')) + self.assertEqual(type(c), type(d1)) + + #with other type, right + c = 7 ** d1 + self.assertEqual(c, Decimal('16807')) + self.assertEqual(type(c), type(d1)) + + #inline with decimal + d1 **= d2 + self.assertEqual(d1, Decimal('25')) + + #inline with other type + d1 **= 4 + self.assertEqual(d1, Decimal('390625')) + + def test_module(self): + + d1 = Decimal('5') + d2 = Decimal('2') + + #two Decimals + self.assertEqual(d1%d2, Decimal('1')) + self.assertEqual(d2%d1, Decimal('2')) + + #with other type, left + c = d1 % 4 + self.assertEqual(c, Decimal('1')) + self.assertEqual(type(c), type(d1)) + + #with other type, right + c = 7 % d1 + self.assertEqual(c, Decimal('2')) + self.assertEqual(type(c), type(d1)) + + #inline with decimal + d1 %= d2 + self.assertEqual(d1, Decimal('1')) + + #inline with other type + d1 %= 4 + self.assertEqual(d1, Decimal('1')) + + def test_floor_div_module(self): + + d1 = Decimal('5') + d2 = Decimal('2') + + #two Decimals + (p, q) = divmod(d1, d2) + self.assertEqual(p, Decimal('2')) + self.assertEqual(q, Decimal('1')) + self.assertEqual(type(p), type(d1)) + self.assertEqual(type(q), type(d1)) + + #with other type, left + (p, q) = divmod(d1, 4) + self.assertEqual(p, Decimal('1')) + self.assertEqual(q, Decimal('1')) + self.assertEqual(type(p), type(d1)) + self.assertEqual(type(q), type(d1)) + + #with other type, right + (p, q) = divmod(7, d1) + self.assertEqual(p, Decimal('1')) + self.assertEqual(q, Decimal('2')) + self.assertEqual(type(p), type(d1)) + self.assertEqual(type(q), type(d1)) + + 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 + + def test_nan_comparisons(self): + # comparisons involving signaling nans signal InvalidOperation + + # order comparisons (<, <=, >, >=) involving only quiet nans + # also signal InvalidOperation + + # equality comparisons (==, !=) involving only quiet nans + # don't signal, but return False or True respectively. + + n = Decimal('NaN') + s = Decimal('sNaN') + i = Decimal('Inf') + f = Decimal('2') + + qnan_pairs = (n, n), (n, i), (i, n), (n, f), (f, n) + snan_pairs = (s, n), (n, s), (s, i), (i, s), (s, f), (f, s), (s, s) + order_ops = operator.lt, operator.le, operator.gt, operator.ge + equality_ops = operator.eq, operator.ne + + # results when InvalidOperation is not trapped + for x, y in qnan_pairs + snan_pairs: + for op in order_ops + equality_ops: + got = op(x, y) + expected = True if op is operator.ne else False + self.assertIs(expected, got, + "expected {0!r} for operator.{1}({2!r}, {3!r}); " + "got {4!r}".format( + expected, op.__name__, x, y, got)) + + # repeat the above, but this time trap the InvalidOperation + with localcontext() as ctx: + ctx.traps[InvalidOperation] = 1 + + for x, y in qnan_pairs: + for op in equality_ops: + got = op(x, y) + expected = True if op is operator.ne else False + self.assertIs(expected, got, + "expected {0!r} for " + "operator.{1}({2!r}, {3!r}); " + "got {4!r}".format( + expected, op.__name__, x, y, got)) + + for x, y in snan_pairs: + for op in equality_ops: + self.assertRaises(InvalidOperation, operator.eq, x, y) + self.assertRaises(InvalidOperation, operator.ne, x, y) + + for x, y in qnan_pairs + snan_pairs: + for op in order_ops: + self.assertRaises(InvalidOperation, op, x, y) + + def test_copy_sign(self): + d = Decimal(1).copy_sign(Decimal(-2)) + + self.assertEqual(Decimal(1).copy_sign(-2), d) + self.assertRaises(TypeError, Decimal(1).copy_sign, '-2') + +# The following are two functions used to test threading in the next class + +def thfunc1(cls): + d1 = Decimal(1) + d3 = Decimal(3) + test1 = d1/d3 + + cls.finish1.set() + cls.synchro.wait() + + test2 = d1/d3 + with localcontext() as c2: + cls.assertTrue(c2.flags[Inexact]) + cls.assertRaises(DivisionByZero, c2.divide, d1, 0) + cls.assertTrue(c2.flags[DivisionByZero]) + with localcontext() as c3: + cls.assertTrue(c3.flags[Inexact]) + cls.assertTrue(c3.flags[DivisionByZero]) + cls.assertRaises(InvalidOperation, c3.compare, d1, Decimal('sNaN')) + cls.assertTrue(c3.flags[InvalidOperation]) + del c3 + cls.assertFalse(c2.flags[InvalidOperation]) + del c2 + + cls.assertEqual(test1, Decimal('0.333333333333333333333333')) + cls.assertEqual(test2, Decimal('0.333333333333333333333333')) + + c1 = getcontext() + cls.assertTrue(c1.flags[Inexact]) + for sig in Overflow, Underflow, DivisionByZero, InvalidOperation: + cls.assertFalse(c1.flags[sig]) + return + +def thfunc2(cls): + d1 = Decimal(1) + d3 = Decimal(3) + test1 = d1/d3 + + thiscontext = getcontext() + thiscontext.prec = 18 + test2 = d1/d3 + + with localcontext() as c2: + cls.assertTrue(c2.flags[Inexact]) + cls.assertRaises(Overflow, c2.multiply, Decimal('1e425000000'), 999) + cls.assertTrue(c2.flags[Overflow]) + with localcontext(thiscontext) as c3: + cls.assertTrue(c3.flags[Inexact]) + cls.assertFalse(c3.flags[Overflow]) + c3.traps[Underflow] = True + cls.assertRaises(Underflow, c3.divide, Decimal('1e-425000000'), 999) + cls.assertTrue(c3.flags[Underflow]) + del c3 + cls.assertFalse(c2.flags[Underflow]) + cls.assertFalse(c2.traps[Underflow]) + del c2 + + cls.synchro.set() + cls.finish2.set() + + cls.assertEqual(test1, Decimal('0.333333333333333333333333')) + cls.assertEqual(test2, Decimal('0.333333333333333333')) + + cls.assertFalse(thiscontext.traps[Underflow]) + cls.assertTrue(thiscontext.flags[Inexact]) + for sig in Overflow, Underflow, DivisionByZero, InvalidOperation: + cls.assertFalse(thiscontext.flags[sig]) + return + +@unittest.skipUnless(threading, 'threading required') +class DecimalUseOfContextTest(unittest.TestCase): + '''Unit tests for Use of Context cases in Decimal.''' + + # Take care executing this test from IDLE, there's an issue in threading + # that hangs IDLE and I couldn't find it + + def test_threading(self): + if HAVE_CDECIMAL and not HAVE_THREADS: + self.skipTest("compiled without threading") + # Test the "threading isolation" of a Context. Also test changing + # the DefaultContext, which acts as a template for the thread-local + # contexts. + save_prec = DefaultContext.prec + save_emax = DefaultContext.Emax + save_emin = DefaultContext.Emin + DefaultContext.prec = 24 + DefaultContext.Emax = 425000000 + DefaultContext.Emin = -425000000 + + self.synchro = threading.Event() + self.finish1 = threading.Event() + self.finish2 = threading.Event() + + th1 = threading.Thread(target=thfunc1, args=(self,)) + th2 = threading.Thread(target=thfunc2, args=(self,)) + + th1.start() + th2.start() + + self.finish1.wait() + self.finish2.wait() + + for sig in (Inexact, Overflow, Underflow, DivisionByZero, + InvalidOperation): + self.assertFalse(DefaultContext.flags[sig]) + + DefaultContext.prec = save_prec + DefaultContext.Emax = save_emax + DefaultContext.Emin = save_emin + return + +class DecimalUsabilityTest(unittest.TestCase): + '''Unit tests for Usability cases of Decimal.''' + + def test_comparison_operators(self): + + da = Decimal('23.42') + db = Decimal('23.42') + dc = Decimal('45') + + #two Decimals + self.assertGreater(dc, da) + self.assertGreaterEqual(dc, da) + self.assertLess(da, dc) + self.assertLessEqual(da, dc) + self.assertEqual(da, db) + self.assertNotEqual(da, dc) + self.assertLessEqual(da, db) + self.assertGreaterEqual(da, db) + + #a Decimal and an int + self.assertGreater(dc, 23) + self.assertLess(23, dc) + self.assertEqual(dc, 45) + + #a Decimal and uncomparable + self.assertNotEqual(da, 'ugly') + self.assertNotEqual(da, 32.7) + self.assertNotEqual(da, object()) + self.assertNotEqual(da, object) + + # sortable + a = list(map(Decimal, range(100))) + b = a[:] + random.shuffle(a) + a.sort() + self.assertEqual(a, b) + + def test_decimal_float_comparison(self): + def assert_attr(a, b, attr, context, signal=None): + context.clear_flags() + f = getattr(a, attr) + if HAVE_CDECIMAL: + if signal == FloatOperation: + self.assertRaises(signal, f, b) + else: + self.assertIs(f(b), True) + self.assertTrue(context.flags[FloatOperation]) + else: + self.assertIs(f(b), True) + + small_d = Decimal('0.25') + big_d = Decimal('3.0') + small_f = 0.25 + big_f = 3.0 + + zero_d = Decimal('0.0') + neg_zero_d = Decimal('-0.0') + zero_f = 0.0 + neg_zero_f = -0.0 + + inf_d = Decimal('Infinity') + neg_inf_d = Decimal('-Infinity') + inf_f = float('inf') + neg_inf_f = float('-inf') + + def doit(c, signal=None): + # Order + for attr in '__lt__', '__le__': + assert_attr(small_d, big_f, attr, c, signal) + + for attr in '__gt__', '__ge__': + assert_attr(big_d, small_f, attr, c, signal) + + # Equality + assert_attr(small_d, small_f, '__eq__', c, None) + + assert_attr(neg_zero_d, neg_zero_f, '__eq__', c, None) + assert_attr(neg_zero_d, zero_f, '__eq__', c, None) + + assert_attr(zero_d, neg_zero_f, '__eq__', c, None) + assert_attr(zero_d, zero_f, '__eq__', c, None) + + assert_attr(neg_inf_d, neg_inf_f, '__eq__', c, None) + assert_attr(inf_d, inf_f, '__eq__', c, None) + + # Inequality + assert_attr(small_d, big_f, '__ne__', c, None) + + assert_attr(Decimal('0.1'), 0.1, '__ne__', c, None) + + assert_attr(neg_inf_d, inf_f, '__ne__', c, None) + assert_attr(inf_d, neg_inf_f, '__ne__', c, None) + + assert_attr(Decimal('NaN'), float('nan'), '__ne__', c, None) + + def test_containers(c, signal): + c.clear_flags() + s = set([100.0, Decimal('100.0')]) + self.assertEqual(len(s), 1) + self.assertTrue(c.flags[FloatOperation]) + + c.clear_flags() + if signal: + self.assertRaises(signal, sorted, [1.0, Decimal('10.0')]) + else: + s = sorted([10.0, Decimal('10.0')]) + self.assertTrue(c.flags[FloatOperation]) + + c.clear_flags() + b = 10.0 in [Decimal('10.0'), 1.0] + self.assertTrue(c.flags[FloatOperation]) + + c.clear_flags() + b = 10.0 in {Decimal('10.0'):'a', 1.0:'b'} + self.assertTrue(c.flags[FloatOperation]) + + if HAVE_CDECIMAL: + nc = Context() + with localcontext(nc) as c: + sig = None + self.assertFalse(c.traps[FloatOperation]) + doit(c, signal=sig) + test_containers(c, sig) + + c.traps[FloatOperation] = True + doit(c, signal=FloatOperation) + test_containers(c, FloatOperation) + else: + # decimal.py does not have the FloatOperation signal. + nc = Context() + with localcontext(nc) as c: + doit(c, signal=False) + + def test_copy_and_deepcopy_methods(self): + d = Decimal('43.24') + c = copy.copy(d) + self.assertEqual(id(c), id(d)) + dc = copy.deepcopy(d) + self.assertEqual(id(dc), id(d)) + + def test_hash_method(self): + def hashit(d): + a = hash(d) + b = d.__hash__() + self.assertEqual(a, b) + return a + + #just that it's hashable + hashit(Decimal(23)) + hashit(Decimal('Infinity')) + hashit(Decimal('-Infinity')) + hashit(Decimal('nan123')) + hashit(Decimal('-NaN')) + + test_values = [Decimal(sign*(2**m + n)) + for m in [0, 14, 15, 16, 17, 30, 31, + 32, 33, 61, 62, 63, 64, 65, 66] + for n in range(-10, 10) + for sign in [-1, 1]] + test_values.extend([ + Decimal("-1"), # ==> -2 + Decimal("-0"), # zeros + Decimal("0.00"), + Decimal("-0.000"), + Decimal("0E10"), + Decimal("-0E12"), + Decimal("10.0"), # negative exponent + Decimal("-23.00000"), + Decimal("1230E100"), # positive exponent + Decimal("-4.5678E50"), + # a value for which hash(n) != hash(n % (2**64-1)) + # in Python pre-2.6 + Decimal(2**64 + 2**32 - 1), + # selection of values which fail with the old (before + # version 2.6) long.__hash__ + Decimal("1.634E100"), + Decimal("90.697E100"), + Decimal("188.83E100"), + Decimal("1652.9E100"), + Decimal("56531E100"), + ]) + + # check that hash(d) == hash(int(d)) for integral values + for value in test_values: + self.assertEqual(hashit(value), hashit(int(value))) + + #the same hash that to an int + self.assertEqual(hashit(Decimal(23)), hashit(23)) + self.assertRaises(TypeError, hash, Decimal('sNaN')) + self.assertTrue(hashit(Decimal('Inf'))) + self.assertTrue(hashit(Decimal('-Inf'))) + + # check that the hashes of a Decimal float match when they + # represent exactly the same values + test_strings = ['inf', '-Inf', '0.0', '-.0e1', + '34.0', '2.5', '112390.625', '-0.515625'] + for s in test_strings: + f = float(s) + d = Decimal(s) + self.assertEqual(hashit(f), hashit(d)) + + # check that the value of the hash doesn't depend on the + # current context (issue #1757) + c = getcontext() + old_precision = c.prec + x = Decimal("123456789.1") + + c.prec = 6 + h1 = hashit(x) + c.prec = 10 + h2 = hashit(x) + c.prec = 16 + h3 = hashit(x) + + self.assertEqual(h1, h2) + self.assertEqual(h1, h3) + c.prec = old_precision + + def test_min_and_max_methods(self): + + d1 = Decimal('15.32') + d2 = Decimal('28.5') + l1 = 15 + l2 = 28 + + #between Decimals + self.assertIs(min(d1,d2), d1) + self.assertIs(min(d2,d1), d1) + self.assertIs(max(d1,d2), d2) + self.assertIs(max(d2,d1), d2) + + #between Decimal and long + self.assertIs(min(d1,l2), d1) + self.assertIs(min(l2,d1), d1) + self.assertIs(max(l1,d2), d2) + self.assertIs(max(d2,l1), d2) + + def test_as_nonzero(self): + #as false + self.assertFalse(Decimal(0)) + #as true + self.assertTrue(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 and int methods. + + d1 = Decimal('66') + d2 = Decimal('15.32') + + #int + self.assertEqual(int(d1), 66) + self.assertEqual(int(d2), 15) + + #float + self.assertEqual(float(d1), 66) + self.assertEqual(float(d2), 15.32) + + #floor + test_pairs = [ + ('123.00', 123), + ('3.2', 3), + ('3.54', 3), + ('3.899', 3), + ('-2.3', -3), + ('-11.0', -11), + ('0.0', 0), + ('-0E3', 0), + ] + for d, i in test_pairs: + self.assertEqual(math.floor(Decimal(d)), i) + self.assertRaises(ValueError, math.floor, Decimal('-NaN')) + self.assertRaises(ValueError, math.floor, Decimal('sNaN')) + self.assertRaises(ValueError, math.floor, Decimal('NaN123')) + self.assertRaises(OverflowError, math.floor, Decimal('Inf')) + self.assertRaises(OverflowError, math.floor, Decimal('-Inf')) + + #ceiling + test_pairs = [ + ('123.00', 123), + ('3.2', 4), + ('3.54', 4), + ('3.899', 4), + ('-2.3', -2), + ('-11.0', -11), + ('0.0', 0), + ('-0E3', 0), + ] + for d, i in test_pairs: + self.assertEqual(math.ceil(Decimal(d)), i) + self.assertRaises(ValueError, math.ceil, Decimal('-NaN')) + self.assertRaises(ValueError, math.ceil, Decimal('sNaN')) + self.assertRaises(ValueError, math.ceil, Decimal('NaN123')) + self.assertRaises(OverflowError, math.ceil, Decimal('Inf')) + self.assertRaises(OverflowError, math.ceil, Decimal('-Inf')) + + #round, single argument + test_pairs = [ + ('123.00', 123), + ('3.2', 3), + ('3.54', 4), + ('3.899', 4), + ('-2.3', -2), + ('-11.0', -11), + ('0.0', 0), + ('-0E3', 0), + ('-3.5', -4), + ('-2.5', -2), + ('-1.5', -2), + ('-0.5', 0), + ('0.5', 0), + ('1.5', 2), + ('2.5', 2), + ('3.5', 4), + ] + for d, i in test_pairs: + self.assertEqual(round(Decimal(d)), i) + self.assertRaises(ValueError, round, Decimal('-NaN')) + self.assertRaises(ValueError, round, Decimal('sNaN')) + self.assertRaises(ValueError, round, Decimal('NaN123')) + self.assertRaises(OverflowError, round, Decimal('Inf')) + self.assertRaises(OverflowError, round, Decimal('-Inf')) + + #round, two arguments; this is essentially equivalent + #to quantize, which is already extensively tested + test_triples = [ + ('123.456', -4, '0E+4'), + ('123.456', -3, '0E+3'), + ('123.456', -2, '1E+2'), + ('123.456', -1, '1.2E+2'), + ('123.456', 0, '123'), + ('123.456', 1, '123.5'), + ('123.456', 2, '123.46'), + ('123.456', 3, '123.456'), + ('123.456', 4, '123.4560'), + ('123.455', 2, '123.46'), + ('123.445', 2, '123.44'), + ('Inf', 4, 'NaN'), + ('-Inf', -23, 'NaN'), + ('sNaN314', 3, 'NaN314'), + ] + for d, n, r in test_triples: + self.assertEqual(str(round(Decimal(d), n)), r) + + + + def test_eval_round_trip(self): + + #with zero + d = Decimal( (0, (0,), 0) ) + self.assertEqual(d, eval(repr(d))) + + #int + d = Decimal( (1, (4, 5), 0) ) + self.assertEqual(d, eval(repr(d))) + + #float + d = Decimal( (0, (4, 5, 3, 4), -2) ) + self.assertEqual(d, eval(repr(d))) + + #weird + d = Decimal( (1, (4, 3, 4, 9, 1, 3, 5, 3, 4), -25) ) + self.assertEqual(d, eval(repr(d))) + + def test_as_tuple(self): + + #with zero + d = Decimal(0) + self.assertEqual(d.as_tuple(), (0, (0,), 0) ) + + #int + d = Decimal(-45) + self.assertEqual(d.as_tuple(), (1, (4, 5), 0) ) + + #complicated string + d = Decimal("-4.34913534E-17") + self.assertEqual(d.as_tuple(), (1, (4, 3, 4, 9, 1, 3, 5, 3, 4), -25) ) + + # XXX empty tuple, like in the NaN case + d = Decimal("Infinity") + if HAVE_CDECIMAL: + self.assertEqual(d.as_tuple(), (0, (), 'F') ) + else: + self.assertEqual(d.as_tuple(), (0, (0,), 'F') ) + + #leading zeros in coefficient should be stripped + d = Decimal( (0, (0, 0, 4, 0, 5, 3, 4), -2) ) + self.assertEqual(d.as_tuple(), (0, (4, 0, 5, 3, 4), -2) ) + d = Decimal( (1, (0, 0, 0), 37) ) + self.assertEqual(d.as_tuple(), (1, (0,), 37)) + d = Decimal( (1, (), 37) ) + self.assertEqual(d.as_tuple(), (1, (0,), 37)) + + #leading zeros in NaN diagnostic info should be stripped + d = Decimal( (0, (0, 0, 4, 0, 5, 3, 4), 'n') ) + self.assertEqual(d.as_tuple(), (0, (4, 0, 5, 3, 4), 'n') ) + d = Decimal( (1, (0, 0, 0), 'N') ) + self.assertEqual(d.as_tuple(), (1, (), 'N') ) + d = Decimal( (1, (), 'n') ) + self.assertEqual(d.as_tuple(), (1, (), 'n') ) + + # XXX coefficient in infinity should raise an error + if not HAVE_CDECIMAL: + d = Decimal( (0, (4, 5, 3, 4), 'F') ) + self.assertEqual(d.as_tuple(), (0, (0,), 'F')) + d = Decimal( (1, (0, 2, 7, 1), 'F') ) + self.assertEqual(d.as_tuple(), (1, (0,), 'F')) + + def test_immutability_operations(self): + # Do operations and check that it didn't change change internal objects. + # XXX Cdecimal: checked extensively in the library runtest. + if HAVE_CDECIMAL: return + + d1 = Decimal('-25e55') + b1 = Decimal('-25e55') + d2 = Decimal('33e+33') + b2 = Decimal('33e+33') + + def checkSameDec(operation, useOther=False): + if useOther: + eval("d1." + operation + "(d2)") + self.assertEqual(d1._sign, b1._sign) + self.assertEqual(d1._int, b1._int) + self.assertEqual(d1._exp, b1._exp) + self.assertEqual(d2._sign, b2._sign) + self.assertEqual(d2._int, b2._int) + self.assertEqual(d2._exp, b2._exp) + else: + eval("d1." + operation + "()") + self.assertEqual(d1._sign, b1._sign) + self.assertEqual(d1._int, b1._int) + self.assertEqual(d1._exp, b1._exp) + return + + Decimal(d1) + self.assertEqual(d1._sign, b1._sign) + self.assertEqual(d1._int, b1._int) + self.assertEqual(d1._exp, b1._exp) + + checkSameDec("__abs__") + checkSameDec("__add__", True) + checkSameDec("__divmod__", True) + checkSameDec("__eq__", True) + checkSameDec("__ne__", True) + checkSameDec("__le__", True) + checkSameDec("__lt__", True) + checkSameDec("__ge__", True) + checkSameDec("__gt__", True) + checkSameDec("__float__") + checkSameDec("__floordiv__", True) + checkSameDec("__hash__") + checkSameDec("__int__") + checkSameDec("__trunc__") + checkSameDec("__mod__", True) + checkSameDec("__mul__", True) + checkSameDec("__neg__") + checkSameDec("__bool__") + checkSameDec("__pos__") + checkSameDec("__pow__", True) + checkSameDec("__radd__", True) + checkSameDec("__rdivmod__", True) + checkSameDec("__repr__") + checkSameDec("__rfloordiv__", True) + checkSameDec("__rmod__", True) + checkSameDec("__rmul__", True) + checkSameDec("__rpow__", True) + checkSameDec("__rsub__", True) + checkSameDec("__str__") + checkSameDec("__sub__", True) + checkSameDec("__truediv__", True) + checkSameDec("adjusted") + checkSameDec("as_tuple") + checkSameDec("compare", True) + checkSameDec("max", True) + checkSameDec("min", True) + checkSameDec("normalize") + checkSameDec("quantize", True) + checkSameDec("remainder_near", True) + checkSameDec("same_quantum", True) + checkSameDec("sqrt") + checkSameDec("to_eng_string") + checkSameDec("to_integral") + + def test_subclassing(self): + # Different behaviours when subclassing Decimal + + class MyDecimal(Decimal): + pass + + d1 = MyDecimal(1) + d2 = MyDecimal(2) + d = d1 + d2 + self.assertIs(type(d), Decimal) + + d = d1.max(d2) + self.assertIs(type(d), Decimal) + + def test_implicit_context(self): + # Check results when context given implicitly. (Issue 2478) + c = getcontext() + self.assertEqual(str(Decimal(0).sqrt()), + str(c.sqrt(Decimal(0)))) + + def test_conversions_from_int(self): + # Check that methods taking a second Decimal argument will + # always accept an integer in place of a Decimal. + self.assertEqual(Decimal(4).compare(3), + Decimal(4).compare(Decimal(3))) + self.assertEqual(Decimal(4).compare_signal(3), + Decimal(4).compare_signal(Decimal(3))) + self.assertEqual(Decimal(4).compare_total(3), + Decimal(4).compare_total(Decimal(3))) + self.assertEqual(Decimal(4).compare_total_mag(3), + Decimal(4).compare_total_mag(Decimal(3))) + self.assertEqual(Decimal(10101).logical_and(1001), + Decimal(10101).logical_and(Decimal(1001))) + self.assertEqual(Decimal(10101).logical_or(1001), + Decimal(10101).logical_or(Decimal(1001))) + self.assertEqual(Decimal(10101).logical_xor(1001), + Decimal(10101).logical_xor(Decimal(1001))) + self.assertEqual(Decimal(567).max(123), + Decimal(567).max(Decimal(123))) + self.assertEqual(Decimal(567).max_mag(123), + Decimal(567).max_mag(Decimal(123))) + self.assertEqual(Decimal(567).min(123), + Decimal(567).min(Decimal(123))) + self.assertEqual(Decimal(567).min_mag(123), + Decimal(567).min_mag(Decimal(123))) + self.assertEqual(Decimal(567).next_toward(123), + Decimal(567).next_toward(Decimal(123))) + self.assertEqual(Decimal(1234).quantize(100), + Decimal(1234).quantize(Decimal(100))) + self.assertEqual(Decimal(768).remainder_near(1234), + Decimal(768).remainder_near(Decimal(1234))) + self.assertEqual(Decimal(123).rotate(1), + Decimal(123).rotate(Decimal(1))) + self.assertEqual(Decimal(1234).same_quantum(1000), + Decimal(1234).same_quantum(Decimal(1000))) + self.assertEqual(Decimal('9.123').scaleb(-100), + Decimal('9.123').scaleb(Decimal(-100))) + self.assertEqual(Decimal(456).shift(-1), + Decimal(456).shift(Decimal(-1))) + + self.assertEqual(Decimal(-12).fma(Decimal(45), 67), + Decimal(-12).fma(Decimal(45), Decimal(67))) + self.assertEqual(Decimal(-12).fma(45, 67), + Decimal(-12).fma(Decimal(45), Decimal(67))) + self.assertEqual(Decimal(-12).fma(45, Decimal(67)), + Decimal(-12).fma(Decimal(45), Decimal(67))) + + +class DecimalPythonAPItests(unittest.TestCase): + + def test_abc(self): + self.assertTrue(issubclass(Decimal, numbers.Number)) + self.assertTrue(not issubclass(Decimal, numbers.Real)) + self.assertIsInstance(Decimal(0), numbers.Number) + self.assertNotIsInstance(Decimal(0), numbers.Real) + + def test_pickle(self): + d = Decimal('-3.141590000') + p = pickle.dumps(d) + e = pickle.loads(p) + self.assertEqual(d, e) + + def test_int(self): + for x in range(-250, 250): + s = '%0.2f' % (x / 100.0) + # should work the same as for floats + self.assertEqual(int(Decimal(s)), int(float(s))) + # should work the same as to_integral in the ROUND_DOWN mode + d = Decimal(s) + r = d.to_integral(ROUND_DOWN) + self.assertEqual(Decimal(int(d)), r) + + self.assertRaises(ValueError, int, Decimal('-nan')) + self.assertRaises(ValueError, int, Decimal('snan')) + self.assertRaises(OverflowError, int, Decimal('inf')) + self.assertRaises(OverflowError, int, Decimal('-inf')) + + def test_trunc(self): + for x in range(-250, 250): + s = '%0.2f' % (x / 100.0) + # should work the same as for floats + self.assertEqual(int(Decimal(s)), int(float(s))) + # should work the same as to_integral in the ROUND_DOWN mode + d = Decimal(s) + r = d.to_integral(ROUND_DOWN) + self.assertEqual(Decimal(math.trunc(d)), r) + + def test_from_float(self): + + class MyDecimal(Decimal): + pass + + r = MyDecimal.from_float(0.1) + self.assertEqual(type(r), MyDecimal) + self.assertEqual(str(r), + '0.1000000000000000055511151231257827021181583404541015625') + bigint = 12345678901234567890123456789 + self.assertEqual(MyDecimal.from_float(bigint), MyDecimal(bigint)) + self.assertTrue(MyDecimal.from_float(float('nan')).is_qnan()) + self.assertTrue(MyDecimal.from_float(float('inf')).is_infinite()) + self.assertTrue(MyDecimal.from_float(float('-inf')).is_infinite()) + self.assertEqual(str(MyDecimal.from_float(float('nan'))), + str(Decimal('NaN'))) + self.assertEqual(str(MyDecimal.from_float(float('inf'))), + str(Decimal('Infinity'))) + self.assertEqual(str(MyDecimal.from_float(float('-inf'))), + str(Decimal('-Infinity'))) + self.assertRaises(TypeError, MyDecimal.from_float, 'abc') + for i in range(200): + x = random.expovariate(0.01) * (random.random() * 2.0 - 1.0) + self.assertEqual(x, float(MyDecimal.from_float(x))) # roundtrip + + def test_create_decimal_from_float(self): + context = Context(prec=5, rounding=ROUND_DOWN) + self.assertEqual( + context.create_decimal_from_float(math.pi), + Decimal('3.1415') + ) + context = Context(prec=5, rounding=ROUND_UP) + self.assertEqual( + context.create_decimal_from_float(math.pi), + Decimal('3.1416') + ) + context = Context(prec=5, traps=[Inexact]) + self.assertRaises( + Inexact, + context.create_decimal_from_float, + math.pi + ) + self.assertEqual(repr(context.create_decimal_from_float(-0.0)), + "Decimal('-0')") + self.assertEqual(repr(context.create_decimal_from_float(1.0)), + "Decimal('1')") + self.assertEqual(repr(context.create_decimal_from_float(10)), + "Decimal('10')") + + def test_quantize(self): + c = Context(Emax=99999, Emin=-99999) + self.assertEqual( + Decimal('7.335').quantize(Decimal('.01')), + Decimal('7.34') + ) + self.assertEqual( + Decimal('7.335').quantize(Decimal('.01'), rounding=ROUND_DOWN), + Decimal('7.33') + ) + self.assertRaises( + InvalidOperation, + Decimal("10e99999").quantize, Decimal('1e100000'), context=c + ) + if HAVE_CDECIMAL: + self.assertRaises( + TypeError, + Decimal("1.23456789").quantize, Decimal('1e-100000'), [] + ) + self.assertRaises( + TypeError, + Decimal("1.23456789").quantize, Decimal('1e-100000'), c + ) + self.assertRaises( + ValueError, + Decimal("1.23456789").quantize, Decimal('1e-100000'), 10 + ) + self.assertRaises( + TypeError, + Decimal("1.23456789").quantize, Decimal('1e-100000'), ROUND_UP, 1000 + ) + +class ContextAPItests(unittest.TestCase): + + def test_pickle(self): + c = Context() + e = pickle.loads(pickle.dumps(c)) + if HAVE_CDECIMAL: # XXX + self.assertEqual(c.prec, e.prec) + self.assertEqual(c.Emin, e.Emin) + self.assertEqual(c.Emax, e.Emax) + self.assertEqual(c.rounding, e.rounding) + self.assertEqual(c.capitals, e.capitals) + self.assertEqual(c.traps, e.traps) + self.assertEqual(c.flags, e.flags) + self.assertEqual(c._clamp, e._clamp) + else: + for k in vars(c): + v1 = vars(c)[k] + v2 = vars(e)[k] + self.assertEqual(v1, v2) + + def test_equality_with_other_types(self): + self.assertIn(Decimal(10), ['a', 1.0, Decimal(10), (1,2), {}]) + self.assertNotIn(Decimal(10), ['a', 1.0, (1,2), {}]) + + def test_copy(self): + # All copies should be deep + c = Context() + d = c.copy() + self.assertNotEqual(id(c), id(d)) + self.assertNotEqual(id(c.flags), id(d.flags)) + self.assertNotEqual(id(c.traps), id(d.traps)) + self.assertEqual(c.flags, d.flags) + + def test_abs(self): + c = Context() + d = c.abs(Decimal(-1)) + self.assertEqual(c.abs(-1), d) + self.assertRaises(TypeError, c.abs, '-1') + + def test_add(self): + c = Context() + d = c.add(Decimal(1), Decimal(1)) + self.assertEqual(c.add(1, 1), d) + self.assertEqual(c.add(Decimal(1), 1), d) + self.assertEqual(c.add(1, Decimal(1)), d) + self.assertRaises(TypeError, c.add, '1', 1) + self.assertRaises(TypeError, c.add, 1, '1') + + def test_compare(self): + c = Context() + d = c.compare(Decimal(1), Decimal(1)) + self.assertEqual(c.compare(1, 1), d) + self.assertEqual(c.compare(Decimal(1), 1), d) + self.assertEqual(c.compare(1, Decimal(1)), d) + self.assertRaises(TypeError, c.compare, '1', 1) + self.assertRaises(TypeError, c.compare, 1, '1') + + def test_compare_signal(self): + c = Context() + d = c.compare_signal(Decimal(1), Decimal(1)) + self.assertEqual(c.compare_signal(1, 1), d) + self.assertEqual(c.compare_signal(Decimal(1), 1), d) + self.assertEqual(c.compare_signal(1, Decimal(1)), d) + self.assertRaises(TypeError, c.compare_signal, '1', 1) + self.assertRaises(TypeError, c.compare_signal, 1, '1') + + def test_compare_total(self): + c = Context() + d = c.compare_total(Decimal(1), Decimal(1)) + self.assertEqual(c.compare_total(1, 1), d) + self.assertEqual(c.compare_total(Decimal(1), 1), d) + self.assertEqual(c.compare_total(1, Decimal(1)), d) + self.assertRaises(TypeError, c.compare_total, '1', 1) + self.assertRaises(TypeError, c.compare_total, 1, '1') + + def test_compare_total_mag(self): + c = Context() + d = c.compare_total_mag(Decimal(1), Decimal(1)) + self.assertEqual(c.compare_total_mag(1, 1), d) + self.assertEqual(c.compare_total_mag(Decimal(1), 1), d) + self.assertEqual(c.compare_total_mag(1, Decimal(1)), d) + self.assertRaises(TypeError, c.compare_total_mag, '1', 1) + self.assertRaises(TypeError, c.compare_total_mag, 1, '1') + + def test_copy_abs(self): + c = Context() + d = c.copy_abs(Decimal(-1)) + self.assertEqual(c.copy_abs(-1), d) + self.assertRaises(TypeError, c.copy_abs, '-1') + + def test_copy_decimal(self): + c = Context() + d = c.copy_decimal(Decimal(-1)) + self.assertEqual(c.copy_decimal(-1), d) + self.assertRaises(TypeError, c.copy_decimal, '-1') + + def test_copy_negate(self): + c = Context() + d = c.copy_negate(Decimal(-1)) + self.assertEqual(c.copy_negate(-1), d) + self.assertRaises(TypeError, c.copy_negate, '-1') + + def test_copy_sign(self): + c = Context() + d = c.copy_sign(Decimal(1), Decimal(-2)) + self.assertEqual(c.copy_sign(1, -2), d) + self.assertEqual(c.copy_sign(Decimal(1), -2), d) + self.assertEqual(c.copy_sign(1, Decimal(-2)), d) + self.assertRaises(TypeError, c.copy_sign, '1', -2) + self.assertRaises(TypeError, c.copy_sign, 1, '-2') + + def test_divide(self): + c = Context() + d = c.divide(Decimal(1), Decimal(2)) + self.assertEqual(c.divide(1, 2), d) + self.assertEqual(c.divide(Decimal(1), 2), d) + self.assertEqual(c.divide(1, Decimal(2)), d) + self.assertRaises(TypeError, c.divide, '1', 2) + self.assertRaises(TypeError, c.divide, 1, '2') + + def test_divide_int(self): + c = Context() + d = c.divide_int(Decimal(1), Decimal(2)) + self.assertEqual(c.divide_int(1, 2), d) + self.assertEqual(c.divide_int(Decimal(1), 2), d) + self.assertEqual(c.divide_int(1, Decimal(2)), d) + self.assertRaises(TypeError, c.divide_int, '1', 2) + self.assertRaises(TypeError, c.divide_int, 1, '2') + + def test_divmod(self): + c = Context() + d = c.divmod(Decimal(1), Decimal(2)) + self.assertEqual(c.divmod(1, 2), d) + self.assertEqual(c.divmod(Decimal(1), 2), d) + self.assertEqual(c.divmod(1, Decimal(2)), d) + self.assertRaises(TypeError, c.divmod, '1', 2) + self.assertRaises(TypeError, c.divmod, 1, '2') + + def test_exp(self): + c = Context() + d = c.exp(Decimal(10)) + self.assertEqual(c.exp(10), d) + self.assertRaises(TypeError, c.exp, '10') + + def test_fma(self): + c = Context() + d = c.fma(Decimal(2), Decimal(3), Decimal(4)) + self.assertEqual(c.fma(2, 3, 4), d) + self.assertEqual(c.fma(Decimal(2), 3, 4), d) + self.assertEqual(c.fma(2, Decimal(3), 4), d) + self.assertEqual(c.fma(2, 3, Decimal(4)), d) + self.assertEqual(c.fma(Decimal(2), Decimal(3), 4), d) + self.assertRaises(TypeError, c.fma, '2', 3, 4) + self.assertRaises(TypeError, c.fma, 2, '3', 4) + self.assertRaises(TypeError, c.fma, 2, 3, '4') + + def test_is_finite(self): + c = Context() + d = c.is_finite(Decimal(10)) + self.assertEqual(c.is_finite(10), d) + self.assertRaises(TypeError, c.is_finite, '10') + + def test_is_infinite(self): + c = Context() + d = c.is_infinite(Decimal(10)) + self.assertEqual(c.is_infinite(10), d) + self.assertRaises(TypeError, c.is_infinite, '10') + + def test_is_nan(self): + c = Context() + d = c.is_nan(Decimal(10)) + self.assertEqual(c.is_nan(10), d) + self.assertRaises(TypeError, c.is_nan, '10') + + def test_is_normal(self): + c = Context() + d = c.is_normal(Decimal(10)) + self.assertEqual(c.is_normal(10), d) + self.assertRaises(TypeError, c.is_normal, '10') + + def test_is_qnan(self): + c = Context() + d = c.is_qnan(Decimal(10)) + self.assertEqual(c.is_qnan(10), d) + self.assertRaises(TypeError, c.is_qnan, '10') + + def test_is_signed(self): + c = Context() + d = c.is_signed(Decimal(10)) + self.assertEqual(c.is_signed(10), d) + self.assertRaises(TypeError, c.is_signed, '10') + + def test_is_snan(self): + c = Context() + d = c.is_snan(Decimal(10)) + self.assertEqual(c.is_snan(10), d) + self.assertRaises(TypeError, c.is_snan, '10') + + def test_is_subnormal(self): + c = Context() + d = c.is_subnormal(Decimal(10)) + self.assertEqual(c.is_subnormal(10), d) + self.assertRaises(TypeError, c.is_subnormal, '10') + + def test_is_zero(self): + c = Context() + d = c.is_zero(Decimal(10)) + self.assertEqual(c.is_zero(10), d) + self.assertRaises(TypeError, c.is_zero, '10') + + def test_ln(self): + c = Context() + d = c.ln(Decimal(10)) + self.assertEqual(c.ln(10), d) + self.assertRaises(TypeError, c.ln, '10') + + def test_log10(self): + c = Context() + d = c.log10(Decimal(10)) + self.assertEqual(c.log10(10), d) + self.assertRaises(TypeError, c.log10, '10') + + def test_logb(self): + c = Context() + d = c.logb(Decimal(10)) + self.assertEqual(c.logb(10), d) + self.assertRaises(TypeError, c.logb, '10') + + def test_logical_and(self): + c = Context() + d = c.logical_and(Decimal(1), Decimal(1)) + self.assertEqual(c.logical_and(1, 1), d) + self.assertEqual(c.logical_and(Decimal(1), 1), d) + self.assertEqual(c.logical_and(1, Decimal(1)), d) + self.assertRaises(TypeError, c.logical_and, '1', 1) + self.assertRaises(TypeError, c.logical_and, 1, '1') + + def test_logical_invert(self): + c = Context() + d = c.logical_invert(Decimal(1000)) + self.assertEqual(c.logical_invert(1000), d) + self.assertRaises(TypeError, c.logical_invert, '1000') + + def test_logical_or(self): + c = Context() + d = c.logical_or(Decimal(1), Decimal(1)) + self.assertEqual(c.logical_or(1, 1), d) + self.assertEqual(c.logical_or(Decimal(1), 1), d) + self.assertEqual(c.logical_or(1, Decimal(1)), d) + self.assertRaises(TypeError, c.logical_or, '1', 1) + self.assertRaises(TypeError, c.logical_or, 1, '1') + + def test_logical_xor(self): + c = Context() + d = c.logical_xor(Decimal(1), Decimal(1)) + self.assertEqual(c.logical_xor(1, 1), d) + self.assertEqual(c.logical_xor(Decimal(1), 1), d) + self.assertEqual(c.logical_xor(1, Decimal(1)), d) + self.assertRaises(TypeError, c.logical_xor, '1', 1) + self.assertRaises(TypeError, c.logical_xor, 1, '1') + + def test_max(self): + c = Context() + d = c.max(Decimal(1), Decimal(2)) + self.assertEqual(c.max(1, 2), d) + self.assertEqual(c.max(Decimal(1), 2), d) + self.assertEqual(c.max(1, Decimal(2)), d) + self.assertRaises(TypeError, c.max, '1', 2) + self.assertRaises(TypeError, c.max, 1, '2') + + def test_max_mag(self): + c = Context() + d = c.max_mag(Decimal(1), Decimal(2)) + self.assertEqual(c.max_mag(1, 2), d) + self.assertEqual(c.max_mag(Decimal(1), 2), d) + self.assertEqual(c.max_mag(1, Decimal(2)), d) + self.assertRaises(TypeError, c.max_mag, '1', 2) + self.assertRaises(TypeError, c.max_mag, 1, '2') + + def test_min(self): + c = Context() + d = c.min(Decimal(1), Decimal(2)) + self.assertEqual(c.min(1, 2), d) + self.assertEqual(c.min(Decimal(1), 2), d) + self.assertEqual(c.min(1, Decimal(2)), d) + self.assertRaises(TypeError, c.min, '1', 2) + self.assertRaises(TypeError, c.min, 1, '2') + + def test_min_mag(self): + c = Context() + d = c.min_mag(Decimal(1), Decimal(2)) + self.assertEqual(c.min_mag(1, 2), d) + self.assertEqual(c.min_mag(Decimal(1), 2), d) + self.assertEqual(c.min_mag(1, Decimal(2)), d) + self.assertRaises(TypeError, c.min_mag, '1', 2) + self.assertRaises(TypeError, c.min_mag, 1, '2') + + def test_minus(self): + c = Context() + d = c.minus(Decimal(10)) + self.assertEqual(c.minus(10), d) + self.assertRaises(TypeError, c.minus, '10') + + def test_multiply(self): + c = Context() + d = c.multiply(Decimal(1), Decimal(2)) + self.assertEqual(c.multiply(1, 2), d) + self.assertEqual(c.multiply(Decimal(1), 2), d) + self.assertEqual(c.multiply(1, Decimal(2)), d) + self.assertRaises(TypeError, c.multiply, '1', 2) + self.assertRaises(TypeError, c.multiply, 1, '2') + + def test_next_minus(self): + c = Context() + d = c.next_minus(Decimal(10)) + self.assertEqual(c.next_minus(10), d) + self.assertRaises(TypeError, c.next_minus, '10') + + def test_next_plus(self): + c = Context() + d = c.next_plus(Decimal(10)) + self.assertEqual(c.next_plus(10), d) + self.assertRaises(TypeError, c.next_plus, '10') + + def test_next_toward(self): + c = Context() + d = c.next_toward(Decimal(1), Decimal(2)) + self.assertEqual(c.next_toward(1, 2), d) + self.assertEqual(c.next_toward(Decimal(1), 2), d) + self.assertEqual(c.next_toward(1, Decimal(2)), d) + self.assertRaises(TypeError, c.next_toward, '1', 2) + self.assertRaises(TypeError, c.next_toward, 1, '2') + + def test_normalize(self): + c = Context() + d = c.normalize(Decimal(10)) + self.assertEqual(c.normalize(10), d) + self.assertRaises(TypeError, c.normalize, '10') + + def test_number_class(self): + c = Context() + self.assertEqual(c.number_class(123), c.number_class(Decimal(123))) + self.assertEqual(c.number_class(0), c.number_class(Decimal(0))) + self.assertEqual(c.number_class(-45), c.number_class(Decimal(-45))) + + def test_powmod(self): + if not HAVE_CDECIMAL: + return + c = Context() + d = c.powmod(Decimal(1), Decimal(4), Decimal(2)) + self.assertEqual(c.powmod(1, 4, 2), d) + self.assertEqual(c.powmod(Decimal(1), 4, 2), d) + self.assertEqual(c.powmod(1, Decimal(4), 2), d) + self.assertEqual(c.powmod(1, 4, Decimal(2)), d) + self.assertEqual(c.powmod(Decimal(1), Decimal(4), 2), d) + self.assertRaises(TypeError, c.powmod, '1', 4, 2) + self.assertRaises(TypeError, c.powmod, 1, '4', 2) + self.assertRaises(TypeError, c.powmod, 1, 4, '2') + + def test_plus(self): + c = Context() + d = c.plus(Decimal(10)) + self.assertEqual(c.plus(10), d) + self.assertRaises(TypeError, c.plus, '10') + + def test_quantize(self): + c = Context() + d = c.quantize(Decimal(1), Decimal(2)) + self.assertEqual(c.quantize(1, 2), d) + self.assertEqual(c.quantize(Decimal(1), 2), d) + self.assertEqual(c.quantize(1, Decimal(2)), d) + self.assertRaises(TypeError, c.quantize, '1', 2) + self.assertRaises(TypeError, c.quantize, 1, '2') + + def test_remainder(self): + c = Context() + d = c.remainder(Decimal(1), Decimal(2)) + self.assertEqual(c.remainder(1, 2), d) + self.assertEqual(c.remainder(Decimal(1), 2), d) + self.assertEqual(c.remainder(1, Decimal(2)), d) + self.assertRaises(TypeError, c.remainder, '1', 2) + self.assertRaises(TypeError, c.remainder, 1, '2') + + def test_remainder_near(self): + c = Context() + d = c.remainder_near(Decimal(1), Decimal(2)) + self.assertEqual(c.remainder_near(1, 2), d) + self.assertEqual(c.remainder_near(Decimal(1), 2), d) + self.assertEqual(c.remainder_near(1, Decimal(2)), d) + self.assertRaises(TypeError, c.remainder_near, '1', 2) + self.assertRaises(TypeError, c.remainder_near, 1, '2') + + def test_rotate(self): + c = Context() + d = c.rotate(Decimal(1), Decimal(2)) + self.assertEqual(c.rotate(1, 2), d) + self.assertEqual(c.rotate(Decimal(1), 2), d) + self.assertEqual(c.rotate(1, Decimal(2)), d) + self.assertRaises(TypeError, c.rotate, '1', 2) + self.assertRaises(TypeError, c.rotate, 1, '2') + + def test_sqrt(self): + c = Context() + d = c.sqrt(Decimal(10)) + self.assertEqual(c.sqrt(10), d) + self.assertRaises(TypeError, c.sqrt, '10') + + def test_same_quantum(self): + c = Context() + d = c.same_quantum(Decimal(1), Decimal(2)) + self.assertEqual(c.same_quantum(1, 2), d) + self.assertEqual(c.same_quantum(Decimal(1), 2), d) + self.assertEqual(c.same_quantum(1, Decimal(2)), d) + self.assertRaises(TypeError, c.same_quantum, '1', 2) + self.assertRaises(TypeError, c.same_quantum, 1, '2') + + def test_scaleb(self): + c = Context() + d = c.scaleb(Decimal(1), Decimal(2)) + self.assertEqual(c.scaleb(1, 2), d) + self.assertEqual(c.scaleb(Decimal(1), 2), d) + self.assertEqual(c.scaleb(1, Decimal(2)), d) + self.assertRaises(TypeError, c.scaleb, '1', 2) + self.assertRaises(TypeError, c.scaleb, 1, '2') + + def test_shift(self): + c = Context() + d = c.shift(Decimal(1), Decimal(2)) + self.assertEqual(c.shift(1, 2), d) + self.assertEqual(c.shift(Decimal(1), 2), d) + self.assertEqual(c.shift(1, Decimal(2)), d) + self.assertRaises(TypeError, c.shift, '1', 2) + self.assertRaises(TypeError, c.shift, 1, '2') + + def test_subtract(self): + c = Context() + d = c.subtract(Decimal(1), Decimal(2)) + self.assertEqual(c.subtract(1, 2), d) + self.assertEqual(c.subtract(Decimal(1), 2), d) + self.assertEqual(c.subtract(1, Decimal(2)), d) + self.assertRaises(TypeError, c.subtract, '1', 2) + self.assertRaises(TypeError, c.subtract, 1, '2') + + def test_to_eng_string(self): + c = Context() + d = c.to_eng_string(Decimal(10)) + self.assertEqual(c.to_eng_string(10), d) + self.assertRaises(TypeError, c.to_eng_string, '10') + + def test_to_sci_string(self): + c = Context() + d = c.to_sci_string(Decimal(10)) + self.assertEqual(c.to_sci_string(10), d) + self.assertRaises(TypeError, c.to_sci_string, '10') + + def test_to_integral_exact(self): + c = Context() + d = c.to_integral_exact(Decimal(10)) + self.assertEqual(c.to_integral_exact(10), d) + self.assertRaises(TypeError, c.to_integral_exact, '10') + + def test_to_integral_value(self): + c = Context() + d = c.to_integral_value(Decimal(10)) + self.assertEqual(c.to_integral_value(10), d) + self.assertRaises(TypeError, c.to_integral_value, '10') + self.assertRaises(TypeError, c.to_integral_value, 10, 'x') + +class WithStatementTest(unittest.TestCase): + # Can't do these as docstrings until Python 2.6 + # as doctest can't handle __future__ statements + + def test_localcontext(self): + # Use a copy of the current context in the block + orig_ctx = getcontext() + with localcontext() as enter_ctx: + set_ctx = getcontext() + final_ctx = getcontext() + self.assertIs(orig_ctx, final_ctx, 'did not restore context correctly') + self.assertIsNot(orig_ctx, set_ctx, 'did not copy the context') + self.assertIs(set_ctx, enter_ctx, '__enter__ returned wrong context') + + def test_localcontextarg(self): + # Use a copy of the supplied context in the block + orig_ctx = getcontext() + new_ctx = Context(prec=42) + with localcontext(new_ctx) as enter_ctx: + set_ctx = getcontext() + final_ctx = getcontext() + self.assertIs(orig_ctx, final_ctx, 'did not restore context correctly') + self.assertEqual(set_ctx.prec, new_ctx.prec, 'did not set correct context') + self.assertIsNot(new_ctx, set_ctx, 'did not copy the context') + self.assertIs(set_ctx, enter_ctx, '__enter__ returned wrong context') + + def test_nested_with_statements(self): + # Use a copy of the supplied context in the block + orig_ctx = getcontext() + orig_ctx.clear_flags() + new_ctx = Context(Emax=384) + with localcontext() as c1: + self.assertEqual(c1.flags, orig_ctx.flags) + self.assertEqual(c1.traps, orig_ctx.traps) + c1.traps[Clamped] = True + c1.Emin = -383 + self.assertRaises(Clamped, c1.create_decimal, '0e-999') + self.assertTrue(c1.flags[Clamped]) + with localcontext(new_ctx) as c2: + self.assertEqual(c2.flags, new_ctx.flags) + self.assertEqual(c2.traps, new_ctx.traps) + self.assertRaises(Overflow, c2.power, Decimal('3.4e200'), 2) + self.assertFalse(c2.flags[Clamped]) + self.assertTrue(c2.flags[Overflow]) + del c2 + self.assertFalse(c1.flags[Overflow]) + del c1 + self.assertNotEqual(orig_ctx.Emin, -383) + self.assertFalse(orig_ctx.flags[Clamped]) + self.assertFalse(orig_ctx.flags[Overflow]) + self.assertFalse(new_ctx.flags[Clamped]) + self.assertFalse(new_ctx.flags[Overflow]) + + def test_with_statements_gc1(self): + with localcontext() as c1: + del c1 + with localcontext() as c2: + del c2 + with localcontext() as c3: + del c3 + with localcontext() as c4: + del c4 + + def test_with_statements_gc2(self): + with localcontext() as c1: + with localcontext(c1) as c2: + del c1 + with localcontext(c2) as c3: + del c2 + with localcontext(c3) as c4: + del c3 + del c4 + + def test_with_statements_gc3(self): + with localcontext() as c1: + del c1 + n1 = Context(prec=1) + setcontext(n1) + with localcontext(n1) as c2: + del n1 + self.assertEqual(c2.prec, 1) + del c2 + n2 = Context(prec=2) + setcontext(n2) + del n2 + self.assertEqual(getcontext().prec, 2) + n3 = Context(prec=3) + setcontext(n3) + self.assertEqual(getcontext().prec, 3) + with localcontext(n3) as c3: + del n3 + self.assertEqual(c3.prec, 3) + del c3 + n4 = Context(prec=4) + setcontext(n4) + del n4 + self.assertEqual(getcontext().prec, 4) + with localcontext() as c4: + self.assertEqual(c4.prec, 4) + del c4 + +class ContextFlags(unittest.TestCase): + def test_flags_irrelevant(self): + # check that the result (numeric result + flags raised) of an + # arithmetic operation doesn't depend on the current flags + + context = Context(prec=9, Emin = -425000000, Emax = 425000000, + rounding=ROUND_HALF_EVEN, traps=[], flags=[]) + + # operations that raise various flags, in the form (function, arglist) + operations = [ + (context._apply, [Decimal("100E-425000010")]), + (context.sqrt, [Decimal(2)]), + (context.add, [Decimal("1.23456789"), Decimal("9.87654321")]), + (context.multiply, [Decimal("1.23456789"), Decimal("9.87654321")]), + (context.subtract, [Decimal("1.23456789"), Decimal("9.87654321")]), + ] + + # try various flags individually, then a whole lot at once + flagsets = [[Inexact], [Rounded], [Underflow], [Clamped], [Subnormal], + [Inexact, Rounded, Underflow, Clamped, Subnormal]] + + for fn, args in operations: + # find answer and flags raised using a clean context + context.clear_flags() + ans = fn(*args) + flags = [k for k, v in context.flags.items() if v] + + for extra_flags in flagsets: + # set flags, before calling operation + context.clear_flags() + for flag in extra_flags: + raise_error(context, flag) # XXX + new_ans = fn(*args) + + # flags that we expect to be set after the operation + expected_flags = list(flags) + for flag in extra_flags: + if flag not in expected_flags: + expected_flags.append(flag) + expected_flags.sort(key=id) + + # flags we actually got + new_flags = [k for k,v in context.flags.items() if v] + new_flags.sort(key=id) + + self.assertEqual(ans, new_ans, + "operation produces different answers depending on flags set: " + + "expected %s, got %s." % (ans, new_ans)) + self.assertEqual(new_flags, expected_flags, + "operation raises different flags depending on flags set: " + + "expected %s, got %s" % (expected_flags, new_flags)) + + def test_float_operation(self): + if not HAVE_CDECIMAL: + return + context = Context() + self.assertFalse(context.flags[FloatOperation]) + self.assertFalse(context.traps[FloatOperation]) + self.assertFalse(context._flags&DecFloatOperation) + self.assertFalse(context._traps&DecFloatOperation) + + context.settraps([Inexact, FloatOperation]) + self.assertEqual(context._traps, DecInexact|DecFloatOperation) + self.assertTrue(context.traps[FloatOperation]) + self.assertTrue(context.traps[Inexact]) + +class SpecialContexts(unittest.TestCase): + def test_context_templates(self): + if HAVE_CDECIMAL: + self.assertEqual( + BasicContext._traps, + DecIEEEInvalidOperation|DecDivisionByZero|DecOverflow| + DecUnderflow|DecClamped + ) + + basic_context_prec = BasicContext.prec + extended_context_prec = ExtendedContext.prec + + BasicContext.prec = ExtendedContext.prec = 441 + + for template in BasicContext, ExtendedContext: + setcontext(template) + c = getcontext() + self.assertIsNot(c, template) + self.assertEqual(c.prec, 441) + + BasicContext.prec = basic_context_prec + ExtendedContext.prec = extended_context_prec + + def test_default_context(self): + if HAVE_CDECIMAL: + self.assertEqual( + DefaultContext._traps, + DecIEEEInvalidOperation|DecDivisionByZero|DecOverflow + ) + + default_context_prec = DefaultContext.prec + + c = getcontext() + saveprec = c.prec + + DefaultContext.prec = 961 + c = getcontext() + self.assertEqual(c.prec, saveprec) + + setcontext(DefaultContext) + c = getcontext() + self.assertIsNot(c, DefaultContext) + self.assertEqual(c.prec, 961) + + DefaultContext.prec = default_context_prec + + def test_ieee_context(self): + if not HAVE_CDECIMAL: + return + + def assert_rest(self, context): + self.assertEqual(context.clamp, 1) + for v in context.traps.values(): + self.assertFalse(v) + for v in context.flags.values(): + self.assertFalse(v) + + c = IEEEContext(DECIMAL32) + self.assertEqual(c.prec, 7) + self.assertEqual(c.Emax, 96) + self.assertEqual(c.Emin, -95) + assert_rest(self, c) + + c = IEEEContext(DECIMAL64) + self.assertEqual(c.prec, 16) + self.assertEqual(c.Emax, 384) + self.assertEqual(c.Emin, -383) + assert_rest(self, c) + + c = IEEEContext(DECIMAL128) + self.assertEqual(c.prec, 34) + self.assertEqual(c.Emax, 6144) + self.assertEqual(c.Emin, -6143) + assert_rest(self, c) + + # Invalid values + self.assertRaises(OverflowError, IEEEContext, 2**63) + self.assertRaises(ValueError, IEEEContext, -1) + self.assertRaises(ValueError, IEEEContext, 1024) + +class Coverage(unittest.TestCase): + + def test_invalid_context(self): + if not HAVE_CDECIMAL: + return + + c = DefaultContext.copy() + + int_max = 2**63-1 if HAVE_CONFIG_64 else 2**31-1 + gt_max_emax = 10**18 if HAVE_CONFIG_64 else 10**9 + + # OverflowError, general ValueError + for attr in ('prec', 'rounding', 'Emin', 'Emax', 'capitals', 'clamp', + '_flags', '_traps', '_allcr'): + self.assertRaises(OverflowError, setattr, c, attr, int_max+1) + self.assertRaises(OverflowError, setattr, c, attr, -int_max-2) + if sys.platform != 'win32': + self.assertRaises(ValueError, setattr, c, attr, int_max) + self.assertRaises(ValueError, setattr, c, attr, -int_max-1) + + # OverflowError: unsafe_prec, unsafe_emin, unsafe_emax + self.assertRaises(OverflowError, getattr(c, 'unsafe_setprec'), int_max+1) + self.assertRaises(OverflowError, getattr(c, 'unsafe_setemax'), int_max+1) + self.assertRaises(OverflowError, getattr(c, 'unsafe_setemin'), -int_max-2) + + # Specific: prec, Emax + for attr in ['prec', 'Emax']: + setattr(c, attr, 999999) + self.assertEqual(getattr(c, attr), 999999) + self.assertRaises(ValueError, setattr, c, attr, -1) + self.assertRaises(ValueError, setattr, c, attr, gt_max_emax) + self.assertRaises(TypeError, setattr, c, attr, 'xyz') + + # Specific: Emin + setattr(c, 'Emin', -999999) + self.assertEqual(getattr(c, 'Emin'), -999999) + self.assertRaises(ValueError, setattr, c, 'Emin', 1) + self.assertRaises(ValueError, setattr, c, 'Emin', -gt_max_emax) + self.assertRaises(TypeError, setattr, c, 'Emin', (1,2,3)) + + # Specific: rounding + self.assertRaises(ValueError, setattr, c, 'rounding', -1) + self.assertRaises(ValueError, setattr, c, 'rounding', 9) + self.assertRaises(TypeError, setattr, c, 'rounding', 1.0) + + # Specific: capitals, clamp, _allcr + for attr in ['capitals', 'clamp', '_allcr']: + self.assertRaises(ValueError, setattr, c, attr, -1) + self.assertRaises(ValueError, setattr, c, attr, 2) + self.assertRaises(TypeError, setattr, c, attr, [1,2,3]) + if HAVE_CONFIG_64: + self.assertRaises(ValueError, setattr, c, attr, 2**32) + self.assertRaises(ValueError, setattr, c, attr, 2**32+1) + + # Specific: _flags, _traps + for attr in ['_flags', '_traps']: + self.assertRaises(ValueError, setattr, c, attr, 999999) + self.assertRaises(TypeError, setattr, c, attr, 'x') + + # SignalDict + self.assertRaises(ValueError, c.flags.__setitem__, 801, 0) + self.assertRaises(ValueError, c.traps.__setitem__, 801, 0) + self.assertRaises(ValueError, c.flags.__delitem__, Overflow) + self.assertRaises(ValueError, c.traps.__delitem__, InvalidOperation) + self.assertRaises(TypeError, setattr, c, 'flags', ['x']) + self.assertRaises(TypeError, setattr, c,'traps', ['y']) + self.assertRaises(ValueError, setattr, c, 'flags', {0:1}) + self.assertRaises(ValueError, setattr, c, 'traps', {0:1}) + + self.assertRaises(ValueError, c.setflags, ['x']) + self.assertRaises(ValueError, c.settraps, ['y']) + self.assertRaises(TypeError, c.setflags, 'x') + self.assertRaises(TypeError, c.settraps, 'y') + + # SignalDict cannot be deleted + self.assertRaises(ValueError, c.__delattr__, 'flags') + self.assertRaises(ValueError, c.__delattr__, 'traps') + + # Invalid attributes + self.assertRaises(TypeError, getattr, c, 9) + self.assertRaises(TypeError, setattr, c, 9) + + # Invalid values in constructor + self.assertRaises(ValueError, Context, prec=gt_max_emax) + self.assertRaises(ValueError, Context, Emax=gt_max_emax) + self.assertRaises(ValueError, Context, Emin=-gt_max_emax) + self.assertRaises(ValueError, Context, rounding=999999) + self.assertRaises(ValueError, Context, clamp=2) + self.assertRaises(ValueError, Context, capitals=-1) + self.assertRaises(ValueError, Context, flags=["P"]) + self.assertRaises(ValueError, Context, traps=["Q"]) + self.assertRaises(ValueError, Context, _allcr=2) + + # Overflow in conversion + self.assertRaises(OverflowError, Context, prec=int_max+1) + self.assertRaises(OverflowError, Context, Emax=int_max+1) + self.assertRaises(OverflowError, Context, Emin=-int_max-2) + self.assertRaises(OverflowError, Context, rounding=int_max+1) + self.assertRaises(OverflowError, Context, clamp=int_max+1) + self.assertRaises(OverflowError, Context, capitals=int_max+1) + self.assertRaises(OverflowError, Context, _allcr=int_max+1) + + # Type error in conversion + self.assertRaises(TypeError, Context, flags=(0,1)) + self.assertRaises(TypeError, Context, traps=(1,0)) + + def test_context_repr(self): + if not HAVE_CDECIMAL: + return + + c = DefaultContext.copy() + + c.prec = 425000000 + c.Emax = 425000000 + c.Emin = -425000000 + c.rounding = ROUND_HALF_DOWN + c.capitals = 0 + c.clamp = 1 + for sig in OrderedSignals: + c.flags[sig] = True + c.traps[sig] = True + c.flags[FloatOperation] = True + c.traps[FloatOperation] = True + + s = c.__repr__() + t = "Context(prec=425000000, rounding=ROUND_HALF_DOWN, " \ + "Emin=-425000000, Emax=425000000, capitals=0, clamp=1, " \ + "flags=[Clamped, InvalidOperation, DivisionByZero, Inexact, " \ + "FloatOperation, Overflow, Rounded, Subnormal, Underflow], " \ + "traps=[Clamped, InvalidOperation, DivisionByZero, Inexact, " \ + "FloatOperation, Overflow, Rounded, Subnormal, Underflow])" + self.assertEqual(s, t) + + def test_valid_context(self): + if not HAVE_CDECIMAL: + return + + c = DefaultContext.copy() + + # Exercise all getters and setters + c.prec = 34 + c.rounding = ROUND_HALF_UP + c.Emax = 3000 + c.Emin = -3000 + c.capitals = 1 + c.clamp = 0 + c._flags = DecUnderflow + c._traps = DecClamped + c._allcr = 0 + + self.assertEqual(c.prec, 34) + self.assertEqual(c.rounding, ROUND_HALF_UP) + self.assertEqual(c.Emin, -3000) + self.assertEqual(c.Emax, 3000) + self.assertEqual(c.capitals, 1) + self.assertEqual(c.clamp, 0) + self.assertEqual(c._flags, DecUnderflow) + self.assertEqual(c._traps, DecClamped) + self.assertEqual(c._allcr, 0) + + self.assertEqual(c.Etiny(), -3033) + self.assertEqual(c.Etop(), 2967) + + # Set traps/flags from list + c.settraps([Clamped, Underflow]) + self.assertEqual(c._traps, DecClamped|DecUnderflow) + + c.setflags([Inexact, Rounded, Subnormal]) + self.assertEqual(c._flags, DecInexact|DecRounded|DecSubnormal) + + # Exercise all unsafe setters + c.unsafe_setprec(999999999) + c.unsafe_setemax(999999999) + c.unsafe_setemin(-999999999) + + self.assertEqual(c.prec, 999999999) + self.assertEqual(c.Emax, 999999999) + self.assertEqual(c.Emin, -999999999) + + def test_apply(self): + if not HAVE_CDECIMAL: + return + + with localcontext() as c: + c.prec = 5 + c.Emax = 99 + c.Emin = -99 + + d = c.copy() + d.prec = 4 + + x = Decimal("123456") + self.assertEqual(str(x.apply()), "1.2346E+5") + self.assertEqual(str(c.apply(x)), "1.2346E+5") + + self.assertEqual(str(x.apply(d)), "1.235E+5") + self.assertEqual(str(d.apply(x)), "1.235E+5") + + self.assertRaises(TypeError, x.apply, "p") + self.assertRaises(TypeError, x.apply, "p", "q") + self.assertRaises(TypeError, c.apply, "p") + + def test_integral(self): + if HAVE_CDECIMAL: + x = Decimal(10) + self.assertEqual(x.to_integral(), 10) + self.assertRaises(TypeError, x.to_integral, '10') + self.assertRaises(TypeError, x.to_integral, 10, 'x') + self.assertRaises(ValueError, x.to_integral, 10) + + self.assertEqual(x.to_integral_value(), 10) + self.assertRaises(TypeError, x.to_integral_value, '10') + self.assertRaises(TypeError, x.to_integral_value, 10, 'x') + self.assertRaises(ValueError, x.to_integral_value, 10) + + self.assertEqual(x.to_integral_exact(), 10) + self.assertRaises(TypeError, x.to_integral_exact, '10') + self.assertRaises(TypeError, x.to_integral_exact, 10, 'x') + self.assertRaises(ValueError, x.to_integral_exact, 10) + + with localcontext() as c: + x = Decimal("99999999999999999999999999.9").to_integral_value(ROUND_UP) + self.assertEqual(x, Decimal('100000000000000000000000000')) + + x = Decimal("99999999999999999999999999.9").to_integral_exact(ROUND_UP) + self.assertEqual(x, Decimal('100000000000000000000000000')) + + c.traps[Inexact] = True + self.assertRaises(Inexact, Decimal("999.9").to_integral_exact, ROUND_UP) + + def test_round(self): + # Python3 behavior: round() returns Decimal + c = getcontext() + c.prec = 28 + int_max = 2**63-1 if HAVE_CONFIG_64 else 2**31-1 + + self.assertEqual(str(Decimal("9.99").__round__()), "10") + self.assertEqual(str(Decimal("9.99e-5").__round__()), "0") + self.assertEqual(str(Decimal("1.23456789").__round__(5)), "1.23457") + self.assertEqual(str(Decimal("1.2345").__round__(10)), "1.2345000000") + self.assertEqual(str(Decimal("1.2345").__round__(-10)), "0E+10") + + self.assertRaises(TypeError, Decimal("1.23").__round__, "5") + self.assertRaises(TypeError, Decimal("1.23").__round__, 5, 8) + + if HAVE_CDECIMAL: + with localcontext() as c: + c.traps[InvalidOperation] = True + self.assertRaises(InvalidOperation, Decimal("1.23").__round__, + -int_max-1) + self.assertRaises(InvalidOperation, Decimal("1.23").__round__, + int_max) + self.assertRaises(InvalidOperation, Decimal("1").__round__, + int(MAX_EMAX+1)) + self.assertRaises(InvalidOperation, Decimal("1").__round__, + -int(MIN_ETINY-1)) + self.assertRaises(OverflowError, Decimal("1.23").__round__, + -int_max-2) + self.assertRaises(OverflowError, Decimal("1.23").__round__, + int_max+1) + + def test_format(self): + if not HAVE_CDECIMAL: + return + + self.assertRaises(TypeError, Decimal(1).__format__, "=10.10", {}, 9) + self.assertRaises(TypeError, Decimal(1).__format__, "=10.10", 9) + self.assertRaises(TypeError, Decimal(1).__format__, []) + + with localcontext() as c: + c.traps[InvalidOperation] = True + c.traps[Rounded] = True + self.assertRaises(ValueError, Decimal(1).__format__, "<>=10.10") + maxsize = 2**63-1 if HAVE_CONFIG_64 else 2**31-1 + self.assertRaises(InvalidOperation, Decimal("1.23456789").__format__, + "=%d.1" % maxsize) + + def test_funcs(self): + if not HAVE_CDECIMAL: + return + + # Invalid arguments + self.assertRaises(TypeError, pow, Decimal(1), 2, "3") + self.assertRaises(TypeError, Decimal(9).number_class, "x", "y") + self.assertRaises(TypeError, Decimal(9).divmod, 8, "x", "y") + self.assertRaises(TypeError, Decimal(9).same_quantum, 3, "x", "y") + self.assertRaises(TypeError, Decimal(9).to_sci, 3, "x", "y") + self.assertRaises(TypeError, Decimal(9).to_eng, 3, "x", "y") + + self.assertEqual(Decimal("1.234e2007").sign(), 1) + self.assertEqual(Decimal("-1.234e2007").sign(), -1) + + with localcontext() as c: + c.clear_traps() + + # Invalid arguments + self.assertRaises(TypeError, c.copy_sign, Decimal(1), "x", "y") + self.assertRaises(TypeError, c.canonical, 200) + self.assertRaises(TypeError, c.is_canonical, 200) + self.assertRaises(TypeError, c.divmod, 9, 8, "x", "y") + self.assertRaises(TypeError, c.same_quantum, 9, 3, "x", "y") + + self.assertEqual(str(c.canonical(Decimal(200))), '200') + self.assertEqual(c.radix(), 10) + + c.traps[DivisionByZero] = True + self.assertRaises(DivisionByZero, Decimal(9).__divmod__, 0) + self.assertRaises(DivisionByZero, Decimal(9).divmod, 0) + self.assertRaises(DivisionByZero, c.divmod, 9, 0) + self.assertTrue(c.flags[InvalidOperation]) + + c.clear_flags() + c.traps[InvalidOperation] = True + self.assertRaises(InvalidOperation, Decimal(9).__divmod__, 0) + self.assertRaises(InvalidOperation, Decimal(9).divmod, 0) + self.assertRaises(InvalidOperation, c.divmod, 9, 0) + self.assertTrue(c.flags[DivisionByZero]) + + c.traps[InvalidOperation] = True + c.prec = 2 + self.assertRaises(InvalidOperation, pow, Decimal(1000), 1, 501) + + c.prec = 10 + x = Decimal(2).invroot() + self.assertEqual(str(x), '0.7071067812') + + x = c.invroot(3) + self.assertEqual(str(x), '0.5773502692') + + c.prec = 28 + x = Decimal(2).power(8) + self.assertEqual(str(x), '256') + + x = Decimal(2).powmod(8, 31) + self.assertEqual(str(x), '8') + + def test_signal_dict(self): + if not HAVE_CDECIMAL: + return + + import itertools + def assertIsExclusivelySet(signal, signal_dict): + for sig in signal_dict: + if sig == signal: + self.assertTrue(signal_dict[sig]) + else: + self.assertFalse(signal_dict[sig]) + + c = DefaultContext.copy() + + # Signal dict methods + self.assertTrue(Overflow in c.traps) + self.assertTrue(c.traps.has_key(Overflow)) + c.clear_traps() + for k in c.traps.keys(): + c.traps[k] = True + for v in c.traps.values(): + self.assertTrue(v) + c.clear_traps() + for k, v in c.traps.items(): + self.assertFalse(v) + + self.assertFalse(c.flags.get(Overflow)) + self.assertIs(c.flags.get("x"), None) + self.assertEqual(c.flags.get("x", "y"), "y") + self.assertRaises(TypeError, c.flags.get, "x", "y", "z") + + self.assertEqual(len(c.flags), len(c.traps)) + s = sys.getsizeof(c.flags) + s = sys.getsizeof(c.traps) + s = c.flags.__repr__() + + # Set flags/traps. + c.clear_flags() + c._flags = DecClamped + self.assertTrue(c.flags[Clamped]) + + c.clear_traps() + c._traps = DecInvalidOperation + self.assertTrue(c.traps[InvalidOperation]) + + # Set flags/traps from dictionary. + c.clear_flags() + d = c.flags.copy() + d[DivisionByZero] = True + c.flags = d + assertIsExclusivelySet(DivisionByZero, c.flags) + + c.clear_traps() + d = c.traps.copy() + d[Underflow] = True + c.traps = d + assertIsExclusivelySet(Underflow, c.traps) + + # Random constructors + IntSignals = { + Clamped: DecClamped, + Rounded: DecRounded, + Inexact: DecInexact, + Subnormal: DecSubnormal, + Underflow: DecUnderflow, + Overflow: DecOverflow, + DivisionByZero: DecDivisionByZero, + InvalidOperation: DecIEEEInvalidOperation + } + IntCond = [ + DecDivisionImpossible, DecDivisionUndefined, DecFpuError, + DecInvalidContext, DecInvalidOperation, DecMallocError, + DecConversionSyntax, + ] + + for r in range(len(OrderedSignals)): + for t in range(len(OrderedSignals)): + for round in RoundingDict.values(): + flags = random.sample(OrderedSignals, r) + traps = random.sample(OrderedSignals, t) + prec = random.randrange(1, 10000) + emin = random.randrange(-10000, 0) + emax = random.randrange(0, 10000) + clamp = random.randrange(0, 2) + caps = random.randrange(0, 2) + cr = random.randrange(0, 2) + c = Context(prec=prec, rounding=round, Emin=emin, Emax=emax, + capitals=caps, clamp=clamp, flags=list(flags), + traps=list(traps), _allcr=cr) + + self.assertEqual(c.prec, prec) + self.assertEqual(c.rounding, round) + self.assertEqual(c.Emin, emin) + self.assertEqual(c.Emax, emax) + self.assertEqual(c.capitals, caps) + self.assertEqual(c.clamp, clamp) + self.assertEqual(c._allcr, cr) + + f = 0 + for x in flags: + f |= IntSignals[x] + self.assertEqual(c._flags, f) + + f = 0 + for x in traps: + f |= IntSignals[x] + self.assertEqual(c._traps, f) + + for cond in IntCond: + c._flags = cond + self.assertTrue(c._flags&DecIEEEInvalidOperation) + assertIsExclusivelySet(InvalidOperation, c.flags) + + for cond in IntCond: + c._traps = cond + self.assertTrue(c._traps&DecIEEEInvalidOperation) + assertIsExclusivelySet(InvalidOperation, c.traps) + + def test_bignum(self): + b1 = 10**35 + b2 = 10**36 + with localcontext() as c: + c.prec = 1000000 + for i in range(5): + a = random.randrange(b1, b2) + b = random.randrange(1000, 1200) + x = a ** b + y = Decimal(a) ** Decimal(b) + self.assertEqual(x, y) + +def test_main(arith=False, verbose=None, todo_tests=None, debug=None): + """ Execute the tests. + + Runs all arithmetic tests if arith is True or if the "decimal" resource + is enabled in regrtest.py + """ + + init() + global TEST_ALL, DEBUG + TEST_ALL = arith or is_resource_enabled('decimal') + DEBUG = debug + + if todo_tests is None: + test_classes = [ + DecimalExplicitConstructionTest, + DecimalImplicitConstructionTest, + DecimalArithmeticOperatorsTest, + DecimalFormatTest, + DecimalUseOfContextTest, + DecimalUsabilityTest, + DecimalPythonAPItests, + ContextAPItests, + DecimalTest, + WithStatementTest, + ContextFlags, + SpecialContexts, + Coverage + ] + else: + test_classes = [DecimalTest] + + # Dynamically build custom test definition for each file in the test + # directory and add the definitions to the DecimalTest class. This + # procedure insures that new files do not get skipped. + for filename in os.listdir(directory): + if '.decTest' not in filename or filename.startswith("."): + continue + head, tail = filename.split('.') + if todo_tests is not None and head not in todo_tests: + continue + tester = lambda self, f=filename: self.eval_file(directory + f) + setattr(DecimalTest, 'test_' + head, tester) + del filename, head, tail, tester + + + try: + run_unittest(*test_classes) + if todo_tests is None: + if HAVE_CDECIMAL: + import cdecimal as DecimalModule + else: + import decimal as DecimalModule + run_doctest(DecimalModule, verbose) + finally: + setcontext(ORIGINAL_CONTEXT) + +if __name__ == '__main__': + import optparse + p = optparse.OptionParser("test_decimal.py [--debug] [{--skip | test1 [test2 [...]]}]") + p.add_option('--debug', '-d', action='store_true', help='shows the test number and context before each test') + p.add_option('--skip', '-s', action='store_true', help='skip over 90% of the arithmetic tests') + (opt, args) = p.parse_args() + + if opt.skip: + test_main(arith=False, verbose=True) + elif args: + test_main(arith=True, verbose=True, todo_tests=args, debug=opt.debug) + else: + test_main(arith=True, verbose=True) diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/LIBTEST.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/LIBTEST.txt Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,152 @@ + + +## ====================================================================== +## Prepare: copy source files +## ====================================================================== + +# Unix: +cp ../../../Modules/cdecimal/* . + +# Windows: +copy ..\..\..\Modules\cdecimal\* . + + +# ====================================================================== +# Unix: short library tests +# ====================================================================== + +./configure +make # gmake +make check + + +# ====================================================================== +# Unix: long library tests +# ====================================================================== + +./configure +make # gmake +cd tests && runalltests.sh + + +# ====================================================================== +# Unix: all configurations +# ====================================================================== + +# +# Here is the list of possible configurations: +# +# 1. x64 - 64-bit OS with x86_64 processor (AMD, Intel) +# +# 2. uint128 - 64-bit OS, compiler has __uint128_t (should be +# the case for gcc) +# +# 3. ansi64 - 64-bit OS, double width multiplication and +# division in ANSI C. +# +# 3. ppro - 32-bit OS with any x86 processor that has at +# least PentiumPro capabilities +# +# 5. ansi32 - 32-bit or 64-bit OS, produces 32-bit library +# +# 6. ansi-legacy - 32-bit OS, compiler without uint64_t +# +# TESTING ONLY: +# +# 7. full_coverage - 64bit OS, produces 64-bit library, +# using CONFIG_32. +# + +# On amd64 with multilib it is possible to run all configs. Otherwise, +# edit runallconfigs.sh and delete configs as appropriate. +cd tests && runallconfigs.sh + +# With Valgrind: +cd tests && runallconfigs.sh --valgrind + + +# ====================================================================== +# Unix: code coverage tests +# ====================================================================== + +# These tests require gcc/gcov and take quite long. To achieve 100% +# coverage of the various multiplication functions, 4-8GB of RAM is +# required for CONFIG_32, 1TB for CONFIG_64. +# +# So, realistically it is only possible to get 100% coverage using +# ./configure MACHINE=full_coverage on a 64-bit machine with 8GB of +# memory. +# +# !!! MACHINE=full_coverage is for testing only and does not work +# for pycoverage. + +# Library coverage: +./configure +make libcoverage # gmake +python tests/covreport.py +make distclean + +# 100% library coverage (64-bit OS): +patch < tests/fullcov_header.patch +./configure MACHINE=full_coverage +make libcoverage # gmake +python tests/covreport.py +make distclean +patch -R < tests/fullcov_header.patch + +# Module coverage: +./configure +make pycoverage # gmake +python tests/covreport.py +make distclean + +# lib/pycoverage: +./configure +make coverage # gmake +python tests/covreport.py +make distclean + + +# ====================================================================== +# 64-bit Windows +# ====================================================================== + +copy Makefile.vc Makefile + +# Find the path to vcvarsamd64.bat (or vcvars64.bat) and execute it. Example: +"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64\vcvarsamd64.bat" + +# Build static library: +nmake MACHINE=x64 +# Short tests +nmake MACHINE=x64 check +# Long tests +make MACHINE=x64 extended +cd tests && runalltests.bat +# Long tests requires gmp, edit paths to gmp libs in Makefile: +make MACHINE=x64 extended_gmp +cd tests && runalltests.bat + + +# ====================================================================== +# 32-bit Windows +# ====================================================================== + +copy Makefile.vc Makefile + +# Find the path to vcvars32.bat and execute it. Example: +"C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat" + +# Build static library: +nmake MACHINE=ppro +# Short tests +nmake MACHINE=ppro check +# Long tests +make MACHINE=ppro extended +cd tests && runalltests.bat +# Long tests requires gmp, edit paths to gmp libs in Makefile: +make MACHINE=x64 extended_gmp +cd tests && runalltests.bat + + + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/Makefile.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/Makefile.in Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,262 @@ + +# ============================================================================== +# Unix Makefile for libmpdec +# ============================================================================== + +include vars.mk + +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +LIBSTATIC = libmpdec.a +LIBSONAME = @LIBSHARED@ +LIBSHARED = @LIBSHARED@ + +CC = @CC@ +LD = @CC@ +AR = @AR@ +GCOV ?= gcov +INC= -I../../../ -I../../../Include +prefix = @prefix@ +exec_prefix = @exec_prefix@ +includedir = @includedir@ +libdir = @libdir@ +datarootdir = @datarootdir@ +docdir = @docdir@ + +MPD_HEADER = @MPD_HEADER@ +MPD_WARN = @MPD_WARN@ +MPD_CONFIG = @MPD_CONFIG@ +MPD_OPT = @MPD_OPT@ + +MPD_CCOV = @MPD_CCOV@ +MPD_LDCOV = @MPD_LDCOV@ +MPD_PGEN = @MPD_PGEN@ +MPD_PUSE = @MPD_PUSE@ +MPD_PREC = @MPD_PREC@ +MPD_DPREC = @MPD_DPREC@ + +ifneq (, $(findstring debug, $(MAKECMDGOALS))) + CFLAGS = $(MPD_WARN) $(MPD_CONFIG) -O0 -g -fpic +endif +ifeq ($(MAKECMDGOALS), check) + ifdef SAVED_CFLAGS + CFLAGS = $(SAVED_CFLAGS) + endif + ifdef SAVED_LDFLAGS + LDFLAGS = $(SAVED_LDFLAGS) + endif +endif +ifeq ($(MAKECMDGOALS), libcoverage) + CFLAGS = $(MPD_WARN) $(MPD_CONFIG) $(MPD_CCOV) + LDFLAGS = $(MPD_LDCOV) +endif +ifeq ($(MAKECMDGOALS), pycoverage) + CFLAGS = $(MPD_WARN) $(MPD_CONFIG) $(MPD_CCOV) + LDFLAGS = $(MPD_LDCOV) +endif +ifeq ($(MAKECMDGOALS), coverage) + CFLAGS = $(MPD_WARN) $(MPD_CONFIG) $(MPD_CCOV) + LDFLAGS = $(MPD_LDCOV) +endif + +CONFIGURE_CFLAGS = @CONFIGURE_CFLAGS@ +CFLAGS ?= $(CONFIGURE_CFLAGS) + +CONFIGURE_LDFLAGS = @CONFIGURE_LDFLAGS@ +LDFLAGS ?= $(CONFIGURE_LDFLAGS) + +ifeq ($(MAKECMDGOALS), profile_gen) + CFLAGS += $(MPD_PGEN) + LDFLAGS += $(MPD_PGEN) +endif +ifeq ($(MAKECMDGOALS), profile_use) + CFLAGS += $(MPD_PUSE) + LDFLAGS += $(MPD_PUSE) +endif + +CC := $(strip $(CC)) +CFLAGS := $(strip $(CFLAGS)) +LDFLAGS := $(strip $(LDFLAGS)) + +NEWVARS = +ifneq ($(SAVED_CC), $(CC)) + NEWVARS = NEWVARS +endif +ifneq ($(SAVED_CFLAGS), $(CFLAGS)) + NEWVARS = NEWVARS +endif +ifneq ($(SAVED_LDFLAGS), $(LDFLAGS)) + NEWVARS = NEWVARS +endif + + +default: $(LIBSTATIC) $(LIBSHARED) +debug: default + + +OBJS := basearith.o context.o constants.o convolute.o crt.o mpdecimal.o \ + mpsignal.o difradix2.o fnt.o fourstep.o io.o memory.o numbertheory.o \ + sixstep.o transpose.o + +$(LIBSTATIC): Makefile vars.mk $(OBJS) + $(AR) rc $(LIBSTATIC) $(OBJS) + ranlib $(LIBSTATIC) + +$(LIBSHARED): Makefile vars.mk $(OBJS) + $(LD) $(LDFLAGS) -shared -Wl,-soname,$(LIBSONAME) -o $(LIBSHARED) $(OBJS) -lm + + +$(NEWVARS): + +vars.mk: $(NEWVARS) + @echo "SAVED_CC=$(CC)" > vars.mk + @echo "SAVED_CFLAGS=$(CFLAGS)" >> vars.mk + @echo "SAVED_LDFLAGS=$(LDFLAGS)" >> vars.mk + + +basearith.o:\ +Makefile vars.mk basearith.c mpdecimal.h constants.h memory.h \ +typearith.h basearith.h + $(CC) $(INC) $(CFLAGS) -c basearith.c + +constants.o:\ +Makefile vars.mk constants.c mpdecimal.h constants.h + $(CC) $(INC) $(CFLAGS) -c constants.c + +context.o:\ +Makefile vars.mk context.c mpdecimal.h + $(CC) $(INC) $(CFLAGS) -c context.c + +convolute.o:\ +Makefile vars.mk convolute.c mpdecimal.h bits.h constants.h fnt.h fourstep.h \ +numbertheory.h sixstep.h umodarith.h typearith.h convolute.h vccompat.h + $(CC) $(INC) $(CFLAGS) -c convolute.c + +crt.o:\ +Makefile vars.mk crt.c mpdecimal.h numbertheory.h constants.h umodarith.h \ +typearith.h crt.h + $(CC) $(INC) $(CFLAGS) -c crt.c + +difradix2.o:\ +Makefile vars.mk difradix2.c mpdecimal.h bits.h numbertheory.h constants.h \ +umodarith.h typearith.h difradix2.h vccompat.h + $(CC) $(INC) $(CFLAGS) -c difradix2.c + +fnt.o:\ +Makefile vars.mk fnt.c bits.h mpdecimal.h difradix2.h numbertheory.h \ +constants.h fnt.h vccompat.h + $(CC) $(INC) $(CFLAGS) -c fnt.c + +fourstep.o:\ +Makefile vars.mk fourstep.c mpdecimal.h numbertheory.h constants.h sixstep.h \ +transpose.h umodarith.h typearith.h fourstep.h + $(CC) $(INC) $(CFLAGS) -c fourstep.c + +io.o:\ +Makefile vars.mk io.c mpdecimal.h bits.h constants.h memory.h typearith.h \ +io.h vccompat.h + $(CC) $(INC) $(CFLAGS) -c io.c + +memory.o:\ +Makefile vars.mk memory.c mpdecimal.h typearith.h memory.h + $(CC) $(INC) $(CFLAGS) -c memory.c + +mpdecimal.o:\ +Makefile vars.mk mpdecimal.c basearith.h mpdecimal.h typearith.h bits.h \ +convolute.h crt.h memory.h umodarith.h constants.h mptest.h mptypes.h \ +vccompat.h + $(CC) $(INC) $(CFLAGS) -c mpdecimal.c + +mpsignal.o:\ +Makefile vars.mk mpdecimal.c mpdecimal.h vccompat.h + $(CC) $(INC) $(CFLAGS) -c mpsignal.c + +numbertheory.o:\ +Makefile vars.mk numbertheory.c mpdecimal.h bits.h umodarith.h constants.h \ +typearith.h numbertheory.h vccompat.h + $(CC) $(INC) $(CFLAGS) -c numbertheory.c + +sixstep.o:\ +Makefile vars.mk sixstep.c mpdecimal.h bits.h difradix2.h numbertheory.h \ +constants.h mptypes.h transpose.h umodarith.h typearith.h sixstep.h \ +vccompat.h + $(CC) $(INC) $(CFLAGS) -c sixstep.c + +transpose.o:\ +Makefile vars.mk transpose.c mpdecimal.h bits.h constants.h typearith.h \ +transpose.h vccompat.h + $(CC) $(INC) $(CFLAGS) -c transpose.c + + +# pycoverage +PYTHON3EXEC=../../../../python +cdecimal.o:\ +Makefile vars.mk cdecimal.c mpdecimal.h docstrings.h memory.h mptypes.h + $(CC) $(INC) -Wno-missing-field-initializers $(CFLAGS) -pthread -c cdecimal.c + +cdecimal.so:\ +Makefile vars.mk cdecimal.o $(LIBSTATIC) + $(CC) $(INC) $(LDFLAGS) -pthread -shared -o cdecimal.so cdecimal.o $(LIBSTATIC) +# end pycoverage + + +check: $(LIBSTATIC) FORCE + cd tests && $(MAKE) "CFLAGS=$(CFLAGS)" "LDFLAGS=$(LDFLAGS)" && ./runshort.sh + +extended:\ +Makefile $(LIBSTATIC) + cd tests && $(MAKE) extended + +build_libcoverage: clean $(LIBSTATIC) + cd tests && $(MAKE) build_libcoverage + +build_pycoverage: build_libcoverage cdecimal.so + +libcoverage: build_libcoverage + cd tests && ./runshort.sh && ./cov && ./test_transpose && ./fntcov + for file in *.c; do $(GCOV) -l "$$file"; done + +pycoverage: build_pycoverage + cd python && cp ../cdecimal.so . && ./gettests.sh && $(PYTHON3EXEC) ../../test_cdecimal.py && $(PYTHON3EXEC) deccheck.py + for file in *.c; do $(GCOV) -l "$$file"; done + +coverage: build_libcoverage build_pycoverage libcoverage pycoverage + + +FORCE: + +bench: FORCE $(LIBSTATIC) + $(CC) $(INC) $(CFLAGS) -o bench bench.c $(LIBSTATIC) -lm + +profile_gen: clean bench + ./bench $(MPD_PREC) 1000 + ./bench $(MPD_DPREC) 1000 + rm -f *.o *.gch $(LIBSTATIC) $(LIBSHARED) bench runtest + +profile_use: bench + ./bench $(MPD_PREC) 1000 + ./bench $(MPD_DPREC) 1000 + +profile: + $(MAKE) profile_gen + $(MAKE) profile_use + +install: FORCE + mkdir -p $(DESTDIR)$(includedir) && cp mpdecimal.h $(DESTDIR)$(includedir) + mkdir -p $(DESTDIR)$(libdir) && cp $(LIBSTATIC) $(LIBSHARED) $(DESTDIR)$(libdir) + mkdir -p $(DESTDIR)$(docdir) && cp -R doc/* $(DESTDIR)$(docdir) + +clean: FORCE + rm -f *.o *.so *.gch *.gcda *.gcno *.gcov *.dyn *.dpi *.lock \ + $(LIBSTATIC) $(LIBSHARED) bench + rm -rf build + cd python && rm -f cdecimal*.so *.pyc + cd tests && if [ -f Makefile ]; then $(MAKE) clean; else exit 0; fi + +distclean: clean + rm -rf config.h config.log config.status Makefile + echo "" > vars.mk + cd tests && rm -rf Makefile testdata + cd python && rm -rf decimaltestdata build __pycache__ + + + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/Makefile.vc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/Makefile.vc Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,228 @@ + +# ====================================================================== +# Visual C (nmake) Makefile for libmpdec +# ====================================================================== + + +INSTALLDIR = . +LIBSTATIC = libmpdec-@RELEASE_VERSION@.lib +LIBIMPORT = libmpdec-@RELEASE_VERSION@.dll.lib +LIBSHARED = libmpdec-@RELEASE_VERSION@.dll + + +OBJS = basearith.obj context.obj constants.obj convolute.obj crt.obj \ + mpdecimal.obj mpsignal.obj difradix2.obj fnt.obj fourstep.obj \ + io.obj memory.obj numbertheory.obj sixstep.obj transpose.obj + + +MPD_PREC = 9 +MPD_DPREC = 18 +GMPLIB = "C:\Program Files (x86)\gmp\gmp.lib" +GMPINC = "C:\Program Files (x86)\gmp" + +!if "$(MACHINE)" == "x64" +CONFIG = /DCONFIG_64 /DMASM +MPD_PREC = 19 +MPD_DPREC = 38 +GMPLIB = "C:\Program Files\gmp\gmp.lib" +GMPINC = "C:\Program Files\gmp" +OBJS = $(OBJS) vcdiv64.obj +!endif +!if "$(MACHINE)" == "ansi64" +CONFIG = /DCONFIG_64 /DANSI +MPD_PREC = 19 +MPD_DPREC = 38 +GMPLIB = "C:\Program Files\gmp\gmp.lib" +GMPINC = "C:\Program Files\gmp" +!endif +!if "$(MACHINE)" == "full_coverage" +CONFIG = /DCONFIG_32 /DANSI +GMPLIB = "C:\Program Files\gmp\gmp.lib" +GMPINC = "C:\Program Files\gmp" +!endif +!if "$(MACHINE)" == "ppro" +CONFIG = /DCONFIG_32 /DPPRO /DMASM +!endif +!if "$(MACHINE)" == "ansi32" +CONFIG = /DCONFIG_32 /DANSI +!endif +!if "$(MACHINE)" == "ansi-legacy" +CONFIG = /DCONFIG_32 /DANSI /DLEGACY_COMPILER +!endif + +!if "$(DLL)" == "1" +BFLAGS= /DBUILD_DLL +UFLAGS= /DUSE_DLL +LFLAGS= $(LFLAGS) /DLL +BUILDLIB = $(LIBSHARED) +USELIB = $(LIBIMPORT) +!if "$(DEBUG)" == "1" +OPT = /MDd /Od /Zi +!else +OPT = /MD /Ox /GS /EHsc +!endif +!else +BUILDLIB = $(LIBSTATIC) +USELIB = $(LIBSTATIC) +!if "$(DEBUG)" == "1" +OPT = /MTd /Od /Zi +!else +OPT = /MT /Ox /GS /EHsc +!endif +!endif + +CFLAGS = /W3 /D_CRT_SECURE_NO_WARNINGS /nologo $(CONFIG) $(OPT) + + +default: $(BUILDLIB) + + +$(LIBSTATIC): Makefile $(OBJS) + -@if exist $@ del $(LIBSTATIC) + lib $(LFLAGS) /out:$(LIBSTATIC) $(OBJS) + + +$(LIBSHARED): Makefile $(OBJS) + -@if exist $@ del $(LIBSHARED) + link $(LFLAGS) /out:$(LIBSHARED) /implib:$(LIBIMPORT) $(OBJS) + mt -manifest $(LIBSHARED).manifest -outputresource:$(LIBSHARED);2 + + +basearith.obj:\ +Makefile basearith.c constants.h mpdecimal.h memory.h typearith.h \ +basearith.h + $(CC) $(BFLAGS) $(CFLAGS) $(PFLAGS) -c basearith.c + +constants.obj:\ +Makefile constants.c mpdecimal.h constants.h + $(CC) $(BFLAGS) $(CFLAGS) $(PFLAGS) -c constants.c + +context.obj:\ +Makefile context.c mpdecimal.h + $(CC) $(BFLAGS) $(CFLAGS) $(PFLAGS) -c context.c + +convolute.obj:\ +Makefile convolute.c bits.h mpdecimal.h constants.h fnt.h fourstep.h \ +numbertheory.h sixstep.h umodarith.h typearith.h convolute.h vccompat.h + $(CC) $(BFLAGS) $(CFLAGS) $(PFLAGS) -c convolute.c + +crt.obj:\ +Makefile crt.c mpdecimal.h numbertheory.h constants.h umodarith.h \ +typearith.h crt.h + $(CC) $(BFLAGS) $(CFLAGS) $(PFLAGS) -c crt.c + +difradix2.obj:\ +Makefile difradix2.c bits.h mpdecimal.h numbertheory.h constants.h \ +umodarith.h typearith.h difradix2.h vccompat.h + $(CC) $(BFLAGS) $(CFLAGS) $(PFLAGS) -c difradix2.c + +fnt.obj:\ +Makefile fnt.c bits.h mpdecimal.h difradix2.h numbertheory.h constants.h \ +fnt.h vccompat.h + $(CC) $(BFLAGS) $(CFLAGS) $(PFLAGS) -c fnt.c + +fourstep.obj:\ +Makefile fourstep.c mpdecimal.h numbertheory.h constants.h sixstep.h \ +transpose.h umodarith.h typearith.h fourstep.h + $(CC) $(BFLAGS) $(CFLAGS) $(PFLAGS) -c fourstep.c + +io.obj:\ +Makefile io.c bits.h mpdecimal.h constants.h memory.h typearith.h io.h \ +vccompat.h + $(CC) $(BFLAGS) $(CFLAGS) $(PFLAGS) -c io.c + +memory.obj:\ +Makefile memory.c mpdecimal.h typearith.h memory.h + $(CC) $(BFLAGS) $(CFLAGS) $(PFLAGS) -c memory.c + +mpdecimal.obj:\ +Makefile mpdecimal.c basearith.h mpdecimal.h typearith.h bits.h \ +convolute.h crt.h memory.h umodarith.h constants.h mptest.h mptypes.h \ +vccompat.h + $(CC) $(BFLAGS) $(CFLAGS) $(PFLAGS) -c mpdecimal.c + +mpsignal.obj:\ +Makefile mpdecimal.c mpdecimal.h vccompat.h + $(CC) $(BFLAGS) $(CFLAGS) $(PFLAGS) -c mpsignal.c + +numbertheory.obj:\ +Makefile numbertheory.c bits.h mpdecimal.h umodarith.h constants.h \ +typearith.h numbertheory.h vccompat.h + $(CC) $(BFLAGS) $(CFLAGS) $(PFLAGS) -c numbertheory.c + +sixstep.obj:\ +Makefile sixstep.c bits.h mpdecimal.h difradix2.h numbertheory.h \ +constants.h mptypes.h transpose.h umodarith.h typearith.h sixstep.h \ +vccompat.h + $(CC) $(BFLAGS) $(CFLAGS) $(PFLAGS) -c sixstep.c + +transpose.obj:\ +Makefile transpose.c bits.h mpdecimal.h constants.h typearith.h \ +transpose.h vccompat.h + $(CC) $(BFLAGS) $(CFLAGS) $(PFLAGS) -c transpose.c + +vcdiv64.obj:\ +Makefile vcdiv64.asm + ml64 /c /Cx vcdiv64.asm + + +check:\ +$(BUILDLIB) + -@copy /y $(BUILDLIB) tests + -@cd tests + -@copy /y Makefile.vc Makefile + -@nmake UFLAGS="$(UFLAGS)" CFLAGS="$(CFLAGS)" USELIB="$(USELIB)" + -@runshort.bat + +extended:\ +Makefile $(BUILDLIB) + -@copy /y $(BUILDLIB) tests + -@cd tests + -@copy /y Makefile.vc Makefile + -@nmake UFLAGS="$(UFLAGS)" CFLAGS="$(CFLAGS)" USELIB="$(USELIB)" extended + +extended_gmp:\ +Makefile $(BUILDLIB) + -@copy /y $(BUILDLIB) tests + -@cd tests + -@copy /y Makefile.vc Makefile + -@nmake UFLAGS="$(UFLAGS)" CFLAGS="$(CFLAGS)" USELIB="$(USELIB)" GMPINC=$(GMPINC) GMPLIB=$(GMPLIB) extended_gmp + + +FORCE: + +bench.exe: Makefile bench.obj + $(CC) $(UFLAGS) $(CFLAGS) $(PFLAGS) bench.obj $(USELIB) + +bench.obj: FORCE + $(CC) $(UFLAGS) $(CFLAGS) $(PFLAGS) -c bench.c + +profile: FORCE + nmake clean + nmake "DLL=1" "PFLAGS=/GL" "LFLAGS=/DLL /LTCG:PGI" + nmake "DLL=1" "PFLAGS=/GL" bench.exe + bench.exe $(MPD_PREC) 1000 + bench.exe $(MPD_DPREC) 1000 + del /Q *.dll bench.exe + link /DLL /LTCG:PGO /out:$(LIBSHARED) /implib:$(LIBIMPORT) $(OBJS) + mt -manifest $(LIBSHARED).manifest -outputresource:$(LIBSHARED);2 + $(CC) $(UFLAGS) $(CFLAGS) $(PFLAGS) bench.c $(USELIB) + bench.exe $(MPD_PREC) 1000 + bench.exe $(MPD_DPREC) 1000 + +clean: FORCE + -@if exist *.obj del *.obj + -@if exist *.dll del *.dll + -@if exist *.exp del *.exp + -@if exist *.lib del *.lib + -@if exist *.ilk del *.ilk + -@if exist *.pdb del *.pdb + -@if exist *.pgc del *.pgc + -@if exist *.pgd del *.pgd + -@if exist *.manifest del *.manifest + -@if exist *.exe del *.exe + -@if exist python\cdecimal.pyd del python\cdecimal.pyd + -@if exist python\*.pyc del python\*.pyc + -@cd tests && copy /y Makefile.vc Makefile && nmake clean + + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/PYTEST.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/PYTEST.txt Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,19 @@ + + +Assuming that the module has been built as part of the Python build: + + +cd python + +# gettests.bat +./gettests.sh + +../../../../python deccheck.py [--short|--medium|--long|--all] +../../../../python ctx-deccheck.py [--short|--medium|--long|--all] + + +Small benchmark (requires gmpy): + +../../../../python bench.py + + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/config.h.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/config.h.in Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,100 @@ +/* config.h.in. Generated from configure.in by autoheader. */ + +/* Define if we can use x64 gcc inline assembler. */ +#undef HAVE_GCC_ASM_FOR_X64 + +/* Define if we can use x87 gcc inline assembler. */ +#undef HAVE_GCC_ASM_FOR_X87 + +/* Define if glibc has incorrect _FORTIFY_SOURCE wrappers for memmove and + bcopy. */ +#undef HAVE_GLIBC_MEMMOVE_BUG + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define if gcc has the ipa-pure-const bug. */ +#undef HAVE_IPA_PURE_CONST_BUG + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define if your compiler provides __uint128_t. */ +#undef HAVE_UINT128_T + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* The size of `size_t', as computed by sizeof. */ +#undef SIZEOF_SIZE_T + +/* The size of `__uint128_t', as computed by sizeof. */ +#undef SIZEOF___UINT128_T + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +#undef _UINT32_T + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +#undef _UINT64_T + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +#undef int32_t + +/* Define to the type of a signed integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +#undef int64_t + +/* Define to `unsigned int' if does not define. */ +#undef size_t + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +#undef uint32_t + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +#undef uint64_t diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/configure --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/configure Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,5427 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.67 for mpdecimal @RELEASE_VERSION@. +# +# Report bugs to . +# +# +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software +# Foundation, Inc. +# +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + # We cannot yet assume a decent shell, so we have to provide a + # neutralization value for shells without unset; and this also + # works around shells that cannot unset nonexistent variables. + BASH_ENV=/dev/null + ENV=/dev/null + (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." + else + $as_echo "$0: Please tell bug-autoconf@gnu.org and +$0: mpdecimal-bugs@bytereef.org about your system, +$0: including any error possibly output before this +$0: message. Then install a modern shell, or manually run +$0: the script under such a shell if you do have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + + + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -p' + fi +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +test -n "$DJDIR" || exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= + +# Identity of this package. +PACKAGE_NAME='mpdecimal' +PACKAGE_TARNAME='mpdecimal' +PACKAGE_VERSION='@RELEASE_VERSION@' +PACKAGE_STRING='mpdecimal @RELEASE_VERSION@' +PACKAGE_BUGREPORT='mpdecimal-bugs@bytereef.org' +PACKAGE_URL='http://www.bytereef.org/mpdecimal/index.html' + +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='LTLIBOBJS +LIBOBJS +CONFIGURE_LDFLAGS +CONFIGURE_CFLAGS +MPD_DPREC +MPD_PREC +MPD_PUSE +MPD_PGEN +MPD_LDCOV +MPD_CCOV +MPD_OPT +MPD_CONFIG +MPD_WARN +MPD_HEADER +AR +GMPPATH +GMPDEPS +EGREP +GREP +CPP +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC +LIBSHARED +MACHINE +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_URL +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' +ac_subst_files='' +ac_user_opts=' +enable_option_checking +' + ac_precious_vars='build_alias +host_alias +target_alias +MACHINE +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; + + -without-* | --without-*) + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + as_fn_error $? "missing argument to $ac_option" +fi + +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used" >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + as_fn_error $? "working directory cannot be determined" +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + as_fn_error $? "pwd does not report name of working directory" + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures mpdecimal @RELEASE_VERSION@ to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking ...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/mpdecimal] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of mpdecimal @RELEASE_VERSION@:";; + esac + cat <<\_ACEOF + +Some influential environment variables: + MACHINE force configuration: x64, uint128, ansi64, ppro, ansi32, + ansi-legacy + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CPP C preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to . +mpdecimal home page: . +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +mpdecimal configure @RELEASE_VERSION@ +generated by GNU Autoconf 2.67 + +Copyright (C) 2010 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_c_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if eval "test \"\${$3+set}\"" = set; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval "test \"\${$3+set}\"" = set; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.i conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} +( $as_echo "## ------------------------------------------ ## +## Report this to mpdecimal-bugs@bytereef.org ## +## ------------------------------------------ ##" + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval "test \"\${$3+set}\"" = set; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_header_mongrel + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval "test \"\${$3+set}\"" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_header_compile + +# ac_fn_c_check_type LINENO TYPE VAR INCLUDES +# ------------------------------------------- +# Tests whether TYPE exists after having included INCLUDES, setting cache +# variable VAR accordingly. +ac_fn_c_check_type () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval "test \"\${$3+set}\"" = set; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=no" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof ($2)) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof (($2))) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + eval "$3=yes" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_type + +# ac_fn_c_find_intX_t LINENO BITS VAR +# ----------------------------------- +# Finds a signed integer type with width BITS, setting cache variable VAR +# accordingly. +ac_fn_c_find_intX_t () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for int$2_t" >&5 +$as_echo_n "checking for int$2_t... " >&6; } +if eval "test \"\${$3+set}\"" = set; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=no" + # Order is important - never check a type that is potentially smaller + # than half of the expected target width. + for ac_type in int$2_t 'int' 'long int' \ + 'long long int' 'short int' 'signed char'; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default + enum { N = $2 / 2 - 1 }; +int +main () +{ +static int test_array [1 - 2 * !(0 < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1))]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default + enum { N = $2 / 2 - 1 }; +int +main () +{ +static int test_array [1 - 2 * !(($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1) + < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 2))]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + case $ac_type in #( + int$2_t) : + eval "$3=yes" ;; #( + *) : + eval "$3=\$ac_type" ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if eval test \"x\$"$3"\" = x"no"; then : + +else + break +fi + done +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_find_intX_t + +# ac_fn_c_find_uintX_t LINENO BITS VAR +# ------------------------------------ +# Finds an unsigned integer type with width BITS, setting cache variable VAR +# accordingly. +ac_fn_c_find_uintX_t () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5 +$as_echo_n "checking for uint$2_t... " >&6; } +if eval "test \"\${$3+set}\"" = set; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=no" + # Order is important - never check a type that is potentially smaller + # than half of the expected target width. + for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \ + 'unsigned long long int' 'unsigned short int' 'unsigned char'; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + case $ac_type in #( + uint$2_t) : + eval "$3=yes" ;; #( + *) : + eval "$3=\$ac_type" ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if eval test \"x\$"$3"\" = x"no"; then : + +else + break +fi + done +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_find_uintX_t + +# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES +# -------------------------------------------- +# Tries to find the compile-time value of EXPR in a program that includes +# INCLUDES, setting VAR accordingly. Returns whether the value could be +# computed +ac_fn_c_compute_int () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_lo=0 ac_mid=0 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=$ac_mid; break +else + as_fn_arith $ac_mid + 1 && ac_lo=$as_val + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=-1 ac_mid=-1 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_lo=$ac_mid; break +else + as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + ac_lo= ac_hi= +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=$ac_mid +else + as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in #(( +?*) eval "$3=\$ac_lo"; ac_retval=0 ;; +'') ac_retval=1 ;; +esac + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +static long int longval () { return $2; } +static unsigned long int ulongval () { return $2; } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (($2) < 0) + { + long int i = longval (); + if (i != ($2)) + return 1; + fprintf (f, "%ld", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ($2)) + return 1; + fprintf (f, "%lu", i); + } + /* Do not output a trailing newline, as this causes \r\n confusion + on some platforms. */ + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + echo >>conftest.val; read $3 &5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by mpdecimal $as_me @RELEASE_VERSION@, which was +generated by GNU Autoconf 2.67. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" + done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; + 2) + as_fn_append ac_configure_args1 " '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + as_fn_append ac_configure_args " '$ac_arg'" + ;; + esac + done +done +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + $as_echo "## ---------------- ## +## Cache variables. ## +## ---------------- ##" + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + $as_echo "## ----------------- ## +## Output variables. ## +## ----------------- ##" + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + $as_echo "## ------------------- ## +## File substitutions. ## +## ------------------- ##" + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + $as_echo "## ----------- ## +## confdefs.h. ## +## ----------- ##" + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +$as_echo "/* confdefs.h */" > confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE +if test -n "$CONFIG_SITE"; then + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac +elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +else + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site +fi +for ac_site_file in "$ac_site_file1" "$ac_site_file2" +do + test "x$ac_site_file" = xNONE && continue + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5; } + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) as_fn_append ac_configure_args " '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 +fi +## -------------------- ## +## Main body of script. ## +## -------------------- ## + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +ac_config_headers="$ac_config_headers config.h" + +ac_config_files="$ac_config_files Makefile tests/Makefile" + + + +LIBSHARED=libmpdec.so.$PACKAGE_VERSION + + +# Language and compiler: +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +saved_cflags=$CFLAGS +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { { ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +ac_exeext=$ac_cv_exeext + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details" "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if test "${ac_cv_objext+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if test "${ac_cv_c_compiler_gnu+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if test "${ac_cv_prog_cc_g+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if test "${ac_cv_prog_cc_c89+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +CFLAGS=$saved_cflags + +# System and machine type: +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking system as reported by uname -s" >&5 +$as_echo_n "checking system as reported by uname -s... " >&6; } +ac_sys_system=`uname -s` +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_sys_system" >&5 +$as_echo "$ac_sys_system" >&6; } + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking machine type as reported by uname -m" >&5 +$as_echo_n "checking machine type as reported by uname -m... " >&6; } +ac_sys_machine=`uname -m` +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_sys_machine" >&5 +$as_echo "$ac_sys_machine" >&6; } + +# Checks for header files: + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if test "${ac_cv_path_GREP+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if test "${ac_cv_path_EGREP+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if test "${ac_cv_header_stdc+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +for ac_header in inttypes.h stdint.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +# Type availability checks: +ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" +if test "x$ac_cv_type_size_t" = x""yes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define size_t unsigned int +_ACEOF + +fi + +ac_fn_c_find_intX_t "$LINENO" "32" "ac_cv_c_int32_t" +case $ac_cv_c_int32_t in #( + no|yes) ;; #( + *) + +cat >>confdefs.h <<_ACEOF +#define int32_t $ac_cv_c_int32_t +_ACEOF +;; +esac + +ac_fn_c_find_intX_t "$LINENO" "64" "ac_cv_c_int64_t" +case $ac_cv_c_int64_t in #( + no|yes) ;; #( + *) + +cat >>confdefs.h <<_ACEOF +#define int64_t $ac_cv_c_int64_t +_ACEOF +;; +esac + +ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t" +case $ac_cv_c_uint32_t in #( + no|yes) ;; #( + *) + +$as_echo "#define _UINT32_T 1" >>confdefs.h + + +cat >>confdefs.h <<_ACEOF +#define uint32_t $ac_cv_c_uint32_t +_ACEOF +;; + esac + +ac_fn_c_find_uintX_t "$LINENO" "64" "ac_cv_c_uint64_t" +case $ac_cv_c_uint64_t in #( + no|yes) ;; #( + *) + +$as_echo "#define _UINT64_T 1" >>confdefs.h + + +cat >>confdefs.h <<_ACEOF +#define uint64_t $ac_cv_c_uint64_t +_ACEOF +;; + esac + +ac_fn_c_check_type "$LINENO" "__uint128_t" "ac_cv_type___uint128_t" "$ac_includes_default" +if test "x$ac_cv_type___uint128_t" = x""yes; then : + +$as_echo "#define HAVE_UINT128_T 1" >>confdefs.h + +fi + + +# Sizes of various types: +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of size_t" >&5 +$as_echo_n "checking size of size_t... " >&6; } +if test "${ac_cv_sizeof_size_t+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (size_t))" "ac_cv_sizeof_size_t" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_size_t" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (size_t) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_size_t=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_size_t" >&5 +$as_echo "$ac_cv_sizeof_size_t" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_SIZE_T $ac_cv_sizeof_size_t +_ACEOF + + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of __uint128_t" >&5 +$as_echo_n "checking size of __uint128_t... " >&6; } +if test "${ac_cv_sizeof___uint128_t+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (__uint128_t))" "ac_cv_sizeof___uint128_t" "$ac_includes_default"; then : + +else + if test "$ac_cv_type___uint128_t" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (__uint128_t) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof___uint128_t=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof___uint128_t" >&5 +$as_echo "$ac_cv_sizeof___uint128_t" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF___UINT128_T $ac_cv_sizeof___uint128_t +_ACEOF + + + +# x64 with gcc asm: +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for x64 gcc inline assembler" >&5 +$as_echo_n "checking for x64 gcc inline assembler... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + __asm__ __volatile__ ("movq %rcx, %rax"); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + have_gcc_asm_for_x64=yes +else + have_gcc_asm_for_x64=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_asm_for_x64" >&5 +$as_echo "$have_gcc_asm_for_x64" >&6; } +if test "$have_gcc_asm_for_x64" = yes; then + +$as_echo "#define HAVE_GCC_ASM_FOR_X64 1" >>confdefs.h + +fi + +# x87 with gcc asm: +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for x87 gcc inline assembler" >&5 +$as_echo_n "checking for x87 gcc inline assembler... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + unsigned short cw; + __asm__ __volatile__ ("fnstcw %0" : "=m" (cw)); + __asm__ __volatile__ ("fldcw %0" : : "m" (cw)); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + have_gcc_asm_for_x87=yes +else + have_gcc_asm_for_x87=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_asm_for_x87" >&5 +$as_echo "$have_gcc_asm_for_x87" >&6; } +if test "$have_gcc_asm_for_x87" = yes; then + +$as_echo "#define HAVE_GCC_ASM_FOR_X87 1" >>confdefs.h + +fi + +# gmp for extended tests: +GMPDEPS= +GMPPATH= +saved_ldflags="$LDFLAGS" +saved_cflags="$CFLAGS" +LDFLAGS=-lgmp +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gmp" >&5 +$as_echo_n "checking for gmp... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include + +int +main () +{ + + mpz_t x; + mpz_init(x); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + have_gmp=yes +else + have_gmp=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test $have_gmp = no; then + LDFLAGS="-L/usr/local/lib -lgmp" + CFLAGS="-I/usr/local/include" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + +int +main () +{ + + mpz_t x; + mpz_init(x); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + have_gmp=yes +else + have_gmp=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + if test $have_gmp = yes; then + GMPPATH=/usr/local + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gmp" >&5 +$as_echo "$have_gmp" >&6; } +LDFLAGS="$saved_ldflags" +CFLAGS="$saved_cflags" + +if test $have_gmp = yes; then + GMPDEPS="mpd_mpz_add mpd_mpz_divmod mpd_mpz_mul mpd_mpz_sub" +fi + + + +# _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect: +# http://sourceware.org/ml/libc-alpha/2010-12/msg00009.html +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for glibc _FORTIFY_SOURCE/memmove bug" >&5 +$as_echo_n "checking for glibc _FORTIFY_SOURCE/memmove bug... " >&6; } +saved_cflags="$CFLAGS" +CFLAGS="-O2 -D_FORTIFY_SOURCE=2" +if test "$cross_compiling" = yes; then : + have_glibc_memmove_bug=undefined +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +void foo(void *p, void *q) { memmove(p, q, 19); } +int main() { + char a[32] = "123456789000000000"; + foo(&a[9], a); + if (strcmp(a, "123456789123456789000000000") != 0) + return 1; + foo(a, &a[9]); + if (strcmp(a, "123456789000000000") != 0) + return 1; + return 0; +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + have_glibc_memmove_bug=no +else + have_glibc_memmove_bug=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +CFLAGS="$saved_cflags" +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_glibc_memmove_bug" >&5 +$as_echo "$have_glibc_memmove_bug" >&6; } +if test "$have_glibc_memmove_bug" = yes; then + +$as_echo "#define HAVE_GLIBC_MEMMOVE_BUG 1" >>confdefs.h + +fi + +# suncc is dectected as cc: +case $ac_sys_system in +sun*|Sun*) + case $CC in + cc) + CC=suncc + ;; + esac +esac + +# Compiler dependent settings: +AR=ar +MPD_WARN="-Wall" +MPD_OPT="-O2 -fpic" +MPD_PGEN= +MPD_PUSE= +MPD_CCOV= +MPD_LDCOV= +case $CC in + *gcc*) + MPD_WARN="-Wall -W -Wno-unknown-pragmas" + MPD_OPT="-O2 -fpic -s" + MPD_PGEN="-fprofile-generate -fprofile-values" + MPD_PUSE="-fprofile-use -freorder-blocks" + MPD_CCOV="-DTEST_COVERAGE -O0 -g -fno-inline -fprofile-arcs -ftest-coverage -fpic" + MPD_LDCOV="-fprofile-arcs" + ;; + *icc*) + AR=xiar + MPD_WARN="-Wall -Wno-unknown-pragmas" + MPD_OPT="-O2 -fpic -s" + MPD_PGEN="-wd11505 -prof-gen" + MPD_PUSE="-wd11505 -prof-use" + ;; + *clang*) + MPD_WARN="-Wall -W -Wno-unknown-pragmas" + MPD_OPT="-O2 -fpic" + ;; + *suncc*) + MPD_WARN= + MPD_OPT="-O2 -fpic -s" + ;; +esac + +# Auto-detect machine dependent settings: +M64= +M32= +if test -n "$MACHINE"; then + M64="-m64 " + M32="-m32 " + case "$MACHINE" in + x64|uint128|ansi64|full_coverage|ppro|ansi32|ansi-legacy|universal) + : ;; + *) + echo "configure: error: invalid MACHINE variable: $MACHINE" + exit 1 ;; + esac +elif test $ac_cv_sizeof_size_t -eq 8; then + if test $have_gcc_asm_for_x64 = yes; then + MACHINE="x64" + elif test $ac_cv_sizeof__uint128_t -eq 8; then + MACHINE="uint128" + else + MACHINE="ansi64" + fi +else + MACHINE="ansi32" + if test $have_gcc_asm_for_x87 = yes; then + case $CC in + *gcc*|*clang*) # icc >= 11.0 works as well + case $ac_sys_system in + darwin*|Darwin*) + ;; + *) + MACHINE="ppro" + ;; + esac + ;; + esac + fi +fi + +# Set configuration variables: +MPD_PREC=9 +MPD_DPREC=18 +CONFIGURE_LDFLAGS= +case "$MACHINE" in + x64) + MPD_CONFIG=$M64"-DCONFIG_64 -DASM" + CONFIGURE_LDFLAGS=$M64 + MPD_PREC=19 + MPD_DPREC=38 + ;; + uint128) + MPD_CONFIG=$M64"-DCONFIG_64 -DANSI -DHAVE_UINT128_T" + CONFIGURE_LDFLAGS=$M64 + MPD_PREC=19 + MPD_DPREC=38 + ;; + ansi64) + MPD_CONFIG=$M64"-DCONFIG_64 -DANSI" + CONFIGURE_LDFLAGS=$M64 + MPD_PREC=19 + MPD_DPREC=38 + ;; + full_coverage) + # Formerly ansi64c32, for testing only! + MPD_CONFIG=$M64"-DCONFIG_32 -DANSI" + CONFIGURE_LDFLAGS=$M64 + ;; + ppro) + MPD_CONFIG=$M32"-DCONFIG_32 -DPPRO -DASM" + CONFIGURE_LDFLAGS=$M32 + # Some versions of gcc miscompile inline asm: + # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491 + # http://gcc.gnu.org/ml/gcc/2010-11/msg00366.html + case $CC in + *gcc*) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcc ipa-pure-const bug" >&5 +$as_echo_n "checking for gcc ipa-pure-const bug... " >&6; } + saved_cflags="$CFLAGS" + CFLAGS="-O2" + if test "$cross_compiling" = yes; then : + have_ipa_pure_const_bug=undefined +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + __attribute__((noinline)) int + foo(int *p) { + int r; + asm ( "movl \$6, (%1)\n\t" + "xorl %0, %0\n\t" + : "=r" (r) : "r" (p) : "memory" + ); + return r; + } + int main() { + int p = 8; + if ((foo(&p) ? : p) != 6) + return 1; + return 0; + } + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + have_ipa_pure_const_bug=no +else + have_ipa_pure_const_bug=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + CFLAGS="$saved_cflags" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_ipa_pure_const_bug" >&5 +$as_echo "$have_ipa_pure_const_bug" >&6; } + if test "$have_ipa_pure_const_bug" = yes; then + MPD_CONFIG="$MPD_CONFIG -fno-ipa-pure-const" + +$as_echo "#define HAVE_IPA_PURE_CONST_BUG 1" >>confdefs.h + + fi + ;; + esac + ;; + ansi32) + MPD_CONFIG=$M32"-DCONFIG_32 -DANSI" + CONFIGURE_LDFLAGS=$M32 + ;; + ansi-legacy) + MPD_CONFIG=$M32"-DCONFIG_32 -DANSI -DLEGACY_COMPILER" + CONFIGURE_LDFLAGS=$M32 + ;; + universal) + MPD_CONFIG="-DUNIVERSAL" +esac + + +# Substitute variables and generate output: + + + + + + + + + + + + + +if test -z "$CFLAGS"; then + CONFIGURE_CFLAGS="$MPD_WARN $MPD_CONFIG $MPD_OPT" +else + CONFIGURE_CFLAGS="$MPD_CONFIG -fpic $CFLAGS" +fi +if test "$have_glibc_memmove_bug" = yes; then + CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -U_FORTIFY_SOURCE" +fi + +if test -n "$LDFLAGS"; then + CONFIGURE_LDFLAGS="$LDFLAGS" +fi + + + + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + test "x$cache_file" != "x/dev/null" && + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} + cat confcache >$cache_file + else + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +U= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + +: ${CONFIG_STATUS=./config.status} +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -p' + fi +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by mpdecimal $as_me @RELEASE_VERSION@, which was +generated by GNU Autoconf 2.67. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + +case $ac_config_headers in *" +"*) set x $ac_config_headers; shift; ac_config_headers=$*;; +esac + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Report bugs to . +mpdecimal home page: ." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" +ac_cs_version="\\ +mpdecimal config.status @RELEASE_VERSION@ +configured by $0, generated by GNU Autoconf 2.67, + with options \\"\$ac_cs_config\\" + +Copyright (C) 2010 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +test -n "\$AWK" || AWK=awk +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_HEADERS " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + as_fn_error $? "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; + --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "tests/Makefile") CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= + trap 'exit_status=$? + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$tmp/subs1.awk" && +_ACEOF + + +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\)..*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\)..*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' >$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 +_ACEOF + +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// +s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" + +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$tmp/defines.awk" <<\_ACAWK || +BEGIN { +_ACEOF + +# Transform confdefs.h into an awk script `defines.awk', embedded as +# here-document in config.status, that substitutes the proper values into +# config.h.in to produce config.h. + +# Create a delimiter string that does not exist in confdefs.h, to ease +# handling of long lines. +ac_delim='%!_!# ' +for ac_last_try in false false :; do + ac_t=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_t"; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +# For the awk script, D is an array of macro values keyed by name, +# likewise P contains macro parameters if any. Preserve backslash +# newline sequences. + +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +sed -n ' +s/.\{148\}/&'"$ac_delim"'/g +t rset +:rset +s/^[ ]*#[ ]*define[ ][ ]*/ / +t def +d +:def +s/\\$// +t bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3"/p +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p +d +:bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3\\\\\\n"\\/p +t cont +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p +t cont +d +:cont +n +s/.\{148\}/&'"$ac_delim"'/g +t clear +:clear +s/\\$// +t bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/"/p +d +:bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p +b cont +' >$CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { + line = \$ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&2;} + + rm -f "$tmp/stdin" + case $ac_file in + -) cat "$tmp/out" && rm -f "$tmp/out";; + *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; + esac \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" + } >"$tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + fi + else + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 + fi + ;; + + + esac + +done # for ac_tag + + +as_fn_exit 0 +_ACEOF +ac_clean_files=$ac_clean_files_save + +test $ac_write_fail = 0 || + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || as_fn_exit 1 +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi + + +GLIBC_MEMMOVE_BUG_WARN=" +***************************** WARNING ********************************* + +Detected glibc _FORTIFY_SOURCE/memmove bug. See: + + http://sourceware.org/ml/libc-alpha/2010-12/msg00009.html + +Enabling -U_FORTIFY_SOURCE workaround. If -D_FORTIFY_SOURCE is also +present in the command line, make sure that the order of the two +options is: + + ... -D_FORTIFY_SOURCE=2 ... -U_FORTIFY_SOURCE ... + +A better solution is to upgrade glibc or to report the bug to your +OS vendor. + +***************************** WARNING ********************************* +" +if test "$have_glibc_memmove_bug" = yes; then + echo "$GLIBC_MEMMOVE_BUG_WARN" +fi + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/configure.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/configure.in Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,353 @@ +dnl Some parts taken from Python's configure.in. + +AC_PREREQ([2.67]) +AC_INIT(mpdecimal, @RELEASE_VERSION@, mpdecimal-bugs@bytereef.org, mpdecimal, http://www.bytereef.org/mpdecimal/index.html) +AC_CONFIG_HEADER(config.h) +AC_CONFIG_FILES([Makefile tests/Makefile]) +AC_ARG_VAR(MACHINE, [force configuration: x64, uint128, ansi64, ppro, ansi32, ansi-legacy]) + +LIBSHARED=libmpdec.so.$PACKAGE_VERSION +AC_SUBST(LIBSHARED) + +# Language and compiler: +AC_LANG_C +saved_cflags=$CFLAGS +AC_PROG_CC +CFLAGS=$saved_cflags + +# System and machine type: +AC_MSG_CHECKING(system as reported by uname -s) +ac_sys_system=`uname -s` +AC_MSG_RESULT($ac_sys_system) + +AC_MSG_CHECKING(machine type as reported by uname -m) +ac_sys_machine=`uname -m` +AC_MSG_RESULT($ac_sys_machine) + +# Checks for header files: +AC_HEADER_STDC +AC_CHECK_HEADERS(inttypes.h stdint.h) + +# Type availability checks: +AC_TYPE_SIZE_T +AC_TYPE_INT32_T +AC_TYPE_INT64_T +AC_TYPE_UINT32_T +AC_TYPE_UINT64_T +AC_CHECK_TYPE(__uint128_t, AC_DEFINE(HAVE_UINT128_T, 1, + [Define if your compiler provides __uint128_t.]),,) + +# Sizes of various types: +AC_CHECK_SIZEOF(size_t, 4) +AC_CHECK_SIZEOF(__uint128_t, 8) + +# x64 with gcc asm: +AC_MSG_CHECKING(for x64 gcc inline assembler) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ + __asm__ __volatile__ ("movq %rcx, %rax"); +]])],[have_gcc_asm_for_x64=yes],[have_gcc_asm_for_x64=no]) +AC_MSG_RESULT($have_gcc_asm_for_x64) +if test "$have_gcc_asm_for_x64" = yes; then + AC_DEFINE(HAVE_GCC_ASM_FOR_X64, 1, + [Define if we can use x64 gcc inline assembler.]) +fi + +# x87 with gcc asm: +AC_MSG_CHECKING(for x87 gcc inline assembler) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ + unsigned short cw; + __asm__ __volatile__ ("fnstcw %0" : "=m" (cw)); + __asm__ __volatile__ ("fldcw %0" : : "m" (cw)); +]])],[have_gcc_asm_for_x87=yes],[have_gcc_asm_for_x87=no]) +AC_MSG_RESULT($have_gcc_asm_for_x87) +if test "$have_gcc_asm_for_x87" = yes; then + AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1, + [Define if we can use x87 gcc inline assembler.]) +fi + +# gmp for extended tests: +GMPDEPS= +GMPPATH= +saved_ldflags="$LDFLAGS" +saved_cflags="$CFLAGS" +LDFLAGS=-lgmp +AC_MSG_CHECKING(for gmp) +AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#include +]], [[ + mpz_t x; + mpz_init(x); +]])], [have_gmp=yes], [have_gmp=no]) +if test $have_gmp = no; then + LDFLAGS="-L/usr/local/lib -lgmp" + CFLAGS="-I/usr/local/include" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + #include + ]], [[ + mpz_t x; + mpz_init(x); + ]])], [have_gmp=yes], [have_gmp=no]) + if test $have_gmp = yes; then + GMPPATH=/usr/local + fi +fi +AC_MSG_RESULT($have_gmp) +LDFLAGS="$saved_ldflags" +CFLAGS="$saved_cflags" + +if test $have_gmp = yes; then + GMPDEPS="mpd_mpz_add mpd_mpz_divmod mpd_mpz_mul mpd_mpz_sub" +fi +AC_SUBST(GMPDEPS) +AC_SUBST(GMPPATH) + +# _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect: +# http://sourceware.org/ml/libc-alpha/2010-12/msg00009.html +AC_MSG_CHECKING(for glibc _FORTIFY_SOURCE/memmove bug) +saved_cflags="$CFLAGS" +CFLAGS="-O2 -D_FORTIFY_SOURCE=2" +AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include +#include +#include +void foo(void *p, void *q) { memmove(p, q, 19); } +int main() { + char a[32] = "123456789000000000"; + foo(&a[9], a); + if (strcmp(a, "123456789123456789000000000") != 0) + return 1; + foo(a, &a[9]); + if (strcmp(a, "123456789000000000") != 0) + return 1; + return 0; +} +]])], +[have_glibc_memmove_bug=no], +[have_glibc_memmove_bug=yes], +[have_glibc_memmove_bug=undefined]) +CFLAGS="$saved_cflags" +AC_MSG_RESULT($have_glibc_memmove_bug) +if test "$have_glibc_memmove_bug" = yes; then + AC_DEFINE(HAVE_GLIBC_MEMMOVE_BUG, 1, + [Define if glibc has incorrect _FORTIFY_SOURCE wrappers + for memmove and bcopy.]) +fi + +# suncc is dectected as cc: +case $ac_sys_system in +sun*|Sun*) + case $CC in + cc) + CC=suncc + ;; + esac +esac + +# Compiler dependent settings: +AR=ar +MPD_WARN="-Wall" +MPD_OPT="-O2 -fpic" +MPD_PGEN= +MPD_PUSE= +MPD_CCOV= +MPD_LDCOV= +case $CC in + *gcc*) + MPD_WARN="-Wall -W -Wno-unknown-pragmas" + MPD_OPT="-O2 -fpic -s" + MPD_PGEN="-fprofile-generate -fprofile-values" + MPD_PUSE="-fprofile-use -freorder-blocks" + MPD_CCOV="-DTEST_COVERAGE -O0 -g -fno-inline -fprofile-arcs -ftest-coverage -fpic" + MPD_LDCOV="-fprofile-arcs" + ;; + *icc*) + AR=xiar + MPD_WARN="-Wall -Wno-unknown-pragmas" + MPD_OPT="-O2 -fpic -s" + MPD_PGEN="-wd11505 -prof-gen" + MPD_PUSE="-wd11505 -prof-use" + ;; + *clang*) + MPD_WARN="-Wall -W -Wno-unknown-pragmas" + MPD_OPT="-O2 -fpic" + ;; + *suncc*) + MPD_WARN= + MPD_OPT="-O2 -fpic -s" + ;; +esac + +# Auto-detect machine dependent settings: +M64= +M32= +if test -n "$MACHINE"; then + M64="-m64 " + M32="-m32 " + case "$MACHINE" in + x64|uint128|ansi64|full_coverage|ppro|ansi32|ansi-legacy|universal) + : ;; + *) + echo "configure: error: invalid MACHINE variable: $MACHINE" + exit 1 ;; + esac +elif test $ac_cv_sizeof_size_t -eq 8; then + if test $have_gcc_asm_for_x64 = yes; then + MACHINE="x64" + elif test $ac_cv_sizeof__uint128_t -eq 8; then + MACHINE="uint128" + else + MACHINE="ansi64" + fi +else + MACHINE="ansi32" + if test $have_gcc_asm_for_x87 = yes; then + case $CC in + *gcc*|*clang*) # icc >= 11.0 works as well + case $ac_sys_system in + darwin*|Darwin*) + ;; + *) + MACHINE="ppro" + ;; + esac + ;; + esac + fi +fi + +# Set configuration variables: +MPD_PREC=9 +MPD_DPREC=18 +CONFIGURE_LDFLAGS= +case "$MACHINE" in + x64) + MPD_CONFIG=$M64"-DCONFIG_64 -DASM" + CONFIGURE_LDFLAGS=$M64 + MPD_PREC=19 + MPD_DPREC=38 + ;; + uint128) + MPD_CONFIG=$M64"-DCONFIG_64 -DANSI -DHAVE_UINT128_T" + CONFIGURE_LDFLAGS=$M64 + MPD_PREC=19 + MPD_DPREC=38 + ;; + ansi64) + MPD_CONFIG=$M64"-DCONFIG_64 -DANSI" + CONFIGURE_LDFLAGS=$M64 + MPD_PREC=19 + MPD_DPREC=38 + ;; + full_coverage) + # Formerly ansi64c32, for testing only! + MPD_CONFIG=$M64"-DCONFIG_32 -DANSI" + CONFIGURE_LDFLAGS=$M64 + ;; + ppro) + MPD_CONFIG=$M32"-DCONFIG_32 -DPPRO -DASM" + CONFIGURE_LDFLAGS=$M32 + # Some versions of gcc miscompile inline asm: + # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491 + # http://gcc.gnu.org/ml/gcc/2010-11/msg00366.html + case $CC in + *gcc*) + AC_MSG_CHECKING(for gcc ipa-pure-const bug) + saved_cflags="$CFLAGS" + CFLAGS="-O2" + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + __attribute__((noinline)) int + foo(int *p) { + int r; + asm ( "movl \$6, (%1)\n\t" + "xorl %0, %0\n\t" + : "=r" (r) : "r" (p) : "memory" + ); + return r; + } + int main() { + int p = 8; + if ((foo(&p) ? : p) != 6) + return 1; + return 0; + } + ]])], + [have_ipa_pure_const_bug=no], + [have_ipa_pure_const_bug=yes], + [have_ipa_pure_const_bug=undefined]) + CFLAGS="$saved_cflags" + AC_MSG_RESULT($have_ipa_pure_const_bug) + if test "$have_ipa_pure_const_bug" = yes; then + MPD_CONFIG="$MPD_CONFIG -fno-ipa-pure-const" + AC_DEFINE(HAVE_IPA_PURE_CONST_BUG, 1, + [Define if gcc has the ipa-pure-const bug.]) + fi + ;; + esac + ;; + ansi32) + MPD_CONFIG=$M32"-DCONFIG_32 -DANSI" + CONFIGURE_LDFLAGS=$M32 + ;; + ansi-legacy) + MPD_CONFIG=$M32"-DCONFIG_32 -DANSI -DLEGACY_COMPILER" + CONFIGURE_LDFLAGS=$M32 + ;; + universal) + MPD_CONFIG="-DUNIVERSAL" +esac + + +# Substitute variables and generate output: +AC_SUBST(AR) +AC_SUBST(MPD_HEADER) +AC_SUBST(MPD_WARN) +AC_SUBST(MPD_CONFIG) +AC_SUBST(MPD_OPT) + +AC_SUBST(MPD_CCOV) +AC_SUBST(MPD_LDCOV) +AC_SUBST(MPD_PGEN) +AC_SUBST(MPD_PUSE) +AC_SUBST(MPD_PREC) +AC_SUBST(MPD_DPREC) + +if test -z "$CFLAGS"; then + CONFIGURE_CFLAGS="$MPD_WARN $MPD_CONFIG $MPD_OPT" +else + CONFIGURE_CFLAGS="$MPD_CONFIG -fpic $CFLAGS" +fi +if test "$have_glibc_memmove_bug" = yes; then + CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -U_FORTIFY_SOURCE" +fi + +if test -n "$LDFLAGS"; then + CONFIGURE_LDFLAGS="$LDFLAGS" +fi + +AC_SUBST(CONFIGURE_CFLAGS) +AC_SUBST(CONFIGURE_LDFLAGS) + +AC_OUTPUT + +GLIBC_MEMMOVE_BUG_WARN=" +***************************** WARNING ********************************* + +Detected glibc _FORTIFY_SOURCE/memmove bug. See: + + http://sourceware.org/ml/libc-alpha/2010-12/msg00009.html + +Enabling -U_FORTIFY_SOURCE workaround. If -D_FORTIFY_SOURCE is also +present in the command line, make sure that the order of the two +options is: + + ... -D_FORTIFY_SOURCE=2 ... -U_FORTIFY_SOURCE ... + +A better solution is to upgrade glibc or to report the bug to your +OS vendor. + +***************************** WARNING ********************************* +" +if test "$have_glibc_memmove_bug" = yes; then + echo "$GLIBC_MEMMOVE_BUG_WARN" +fi + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/python/bench.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/python/bench.py Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,145 @@ +#!/usr/bin/env python + +# +# Copyright (C) 2001-2010 Python Software Foundation. All Rights Reserved. +# Modified and extended by Stefan Krah. +# + + +import time +from math import log, ceil +import decimal +import cdecimal +from gmpy import mpf, mpz, set_minprec + + +Decimal = decimal.Decimal +Cdecimal = cdecimal.Decimal + + +# Pi function from the decimal.py documentation +def pi_native(prec=None): + """native float""" + lasts, t, s, n, na, d, da = 0, 3.0, 3, 1, 0, 0, 24 + while s != lasts: + lasts = s + n, na = n+na, na+8 + d, da = d+da, da+32 + t = (t * n) / d + s += t + return s + +def pi_decimal(prec): + """Decimal""" + decimal.getcontext().prec = prec + lasts, t, s, n, na, d, da = Decimal(0), Decimal(3), Decimal(3), Decimal(1), Decimal(0), Decimal(0), Decimal(24) + while s != lasts: + lasts = s + n, na = n+na, na+8 + d, da = d+da, da+32 + t = (t * n) / d + s += t + return s + +def pi_Cdecimal(prec): + """cdecimal.Cdecimal""" + cdecimal.getcontext().prec = prec + lasts, t, s, n, na, d, da = Cdecimal(0), Cdecimal(3), Cdecimal(3), Cdecimal(1), Cdecimal(0), Cdecimal(0), Cdecimal(24) + while s != lasts: + lasts = s + n, na = n+na, na+8 + d, da = d+da, da+32 + t = (t * n) / d + s += t + return s + +def pi_mpf(prec): + """gmp.mpf""" + set_minprec(prec) + lasts, t, s, n, na, d, da = mpf(0), mpf(3), mpf(3), mpf(1), mpf(0), mpf(0), mpf(24) + while s != lasts: + lasts = s + n, na = n+na, na+8 + d, da = d+da, da+32 + t = (t * n) / d + s += t + return s + + +def factorial(n, m): + if (n > m): + return factorial(m, n) + elif m == 0: + return 1 + elif n == m: + return n + else: + return factorial(n, (n+m)//2) * factorial((n+m)//2 + 1, m) + + +d = { + "native": pi_native, + "cdecimal": pi_Cdecimal, + "gmpy": pi_mpf, + "decimal": pi_decimal, +} + + +def prec_to_bits(prec): + return ceil(prec * log(10) / log(2)) + + + +print("\n# ======================================================================") +print("# Calculating pi, 10000 iterations") +print("# ======================================================================\n") + +for prec in [9, 19, 38, 100]: + print("\nPrecision: %d decimal digits\n" % prec) + for name in ["native", "cdecimal", "gmpy", "decimal"]: + if prec > 19 and (name == "native" or name == "decimal"): + continue + p = prec + if name == "gmpy": + p = int(prec_to_bits(prec)) + func = d[name] + start = time.time() + for i in range(10000): + x = func(p) + print("%s:" % name) + print("result: %s" % str(x)) + print("time: %fs\n" % (time.time()-start)) + + +print("\n# ======================================================================") +print("# Factorial") +print("# ======================================================================\n") + +cdecimal.getcontext().prec = cdecimal.MAX_PREC + +for n in [100000, 1000000, 10000000, 100000000]: + + print("n = %d\n" % n) + + start_calc = time.time() + x = factorial(Cdecimal(n), 0) + end_calc = time.time() + start_conv = time.time() + sx = str(x) + end_conv = time.time() + print("cdecimal:") + print("calculation time: %fs" % (end_calc-start_calc)) + print("conversion time: %fs\n" % (end_conv-start_conv)) + + start_calc = time.time() + y = factorial(mpz(n), 0) + end_calc = time.time() + start_conv = time.time() + sy = str(y) + end_conv = time.time() + + print("gmpy:") + print("calculation time: %fs" % (end_calc-start_calc)) + print("conversion time: %fs\n\n" % (end_conv-start_conv)) + + assert(sx == sy) diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/python/ctx-deccheck.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/python/ctx-deccheck.py Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,1075 @@ +#!/usr/bin/env python + +# +# Copyright (c) 2008-2010 Stefan Krah. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + +# Usage: python ctx-deccheck.py [--short|--medium|--long|--all] + + +import cdecimal, decimal +import sys, inspect +from copy import copy +from randdec import * + + +EXIT_STATUS = 0 +py_minor = sys.version_info[1] +py_micro = sys.version_info[2] + + +# Translate symbols. +deccond = { + cdecimal.Clamped: decimal.Clamped, + cdecimal.ConversionSyntax: decimal.ConversionSyntax, + cdecimal.DivisionByZero: decimal.DivisionByZero, + cdecimal.DivisionImpossible: decimal.InvalidOperation, + cdecimal.DivisionUndefined: decimal.DivisionUndefined, + cdecimal.Inexact: decimal.Inexact, + cdecimal.InvalidContext: decimal.InvalidContext, + cdecimal.InvalidOperation: decimal.InvalidOperation, + cdecimal.Overflow: decimal.Overflow, + cdecimal.Rounded: decimal.Rounded, + cdecimal.Subnormal: decimal.Subnormal, + cdecimal.Underflow: decimal.Underflow, +} + +mpdcond = { + decimal.Clamped: cdecimal.Clamped, + decimal.ConversionSyntax: cdecimal.ConversionSyntax, + decimal.DivisionByZero: cdecimal.DivisionByZero, + decimal.InvalidOperation: cdecimal.DivisionImpossible, + decimal.DivisionUndefined: cdecimal.DivisionUndefined, + decimal.Inexact: cdecimal.Inexact, + decimal.InvalidContext: cdecimal.InvalidContext, + decimal.InvalidOperation: cdecimal.InvalidOperation, + decimal.Overflow: cdecimal.Overflow, + decimal.Rounded: cdecimal.Rounded, + decimal.Subnormal: cdecimal.Subnormal, + decimal.Underflow: cdecimal.Underflow +} + +decround = { + cdecimal.ROUND_UP: decimal.ROUND_UP, + cdecimal.ROUND_DOWN: decimal.ROUND_DOWN, + cdecimal.ROUND_CEILING: decimal.ROUND_CEILING, + cdecimal.ROUND_FLOOR: decimal.ROUND_FLOOR, + cdecimal.ROUND_HALF_UP: decimal.ROUND_HALF_UP, + cdecimal.ROUND_HALF_DOWN: decimal.ROUND_HALF_DOWN, + cdecimal.ROUND_HALF_EVEN: decimal.ROUND_HALF_EVEN, + cdecimal.ROUND_05UP: decimal.ROUND_05UP +} + + +class Context(object): + """Provides a convenient way of syncing the cdecimal and decimal contexts""" + + __slots__ = ['f', 'd'] + + def __init__(self, mpdctx=cdecimal.getcontext()): + """Initialization is from the cdecimal context""" + self.f = mpdctx + self.d = decimal.getcontext() + self.d.prec = self.f.prec + self.d.Emin = self.f.Emin + self.d.Emax = self.f.Emax + self.d.rounding = decround[self.f.rounding] + self.d.capitals = self.f.capitals + self.settraps([sig for sig in self.f.traps if self.f.traps[sig]]) + self.setstatus([sig for sig in self.f.flags if self.f.flags[sig]]) + self.d._clamp = self.f._clamp + + def getprec(self): + assert(self.f.prec == self.d.prec) + return self.f.prec + + def setprec(self, val): + self.f.prec = val + self.d.prec = val + + def getemin(self): + assert(self.f.Emin == self.d.Emin) + return self.f.Emin + + def setemin(self, val): + self.f.Emin = val + self.d.Emin = val + + def getemax(self): + assert(self.f.Emax == self.d.Emax) + return self.f.Emax + + def setemax(self, val): + self.f.Emax = val + self.d.Emax = val + + def getround(self): + return self.d.rounding + + def setround(self, val): + self.f.rounding = val + self.d.rounding = decround[val] + + def getcapitals(self): + assert(self.f.capitals == self.d.capitals) + return self.f.capitals + + def setcapitals(self, val): + self.f.capitals = val + self.d.capitals = val + + def getclamp(self): + assert(self.f._clamp == self.d._clamp) + return self.f._clamp + + def setclamp(self, val): + self.f._clamp = val + self.d._clamp = val + + prec = property(getprec, setprec) + Emin = property(getemin, setemin) + Emax = property(getemax, setemax) + rounding = property(getround, setround) + clamp = property(getclamp, setclamp) + capitals = property(getcapitals, setcapitals) + + def clear_traps(self): + self.f.clear_traps() + for trap in self.d.traps: + self.d.traps[trap] = False + + def clear_status(self): + self.f.clear_flags() + self.d.clear_flags() + + def settraps(self, lst): # cdecimal signal list + self.clear_traps() + for signal in lst: + self.f.traps[signal] = True + self.d.traps[deccond[signal]] = True + + def setstatus(self, lst): # cdecimal signal list + self.clear_status() + for signal in lst: + self.f.flags[signal] = True + self.d.flags[deccond[signal]] = True + + def assert_eq_status(self): + """assert equality of cdecimal and decimal status""" + for signal in self.f.flags: + if signal == cdecimal.FloatOperation: + continue + if self.f.flags[signal] == (not self.d.flags[deccond[signal]]): + return False + return True + + +# We don't want exceptions so that we can compare the status flags. +context = Context() +context.Emin = cdecimal.MIN_EMIN +context.Emax = cdecimal.MAX_EMAX +context.clear_traps() + + +_exc_fmt = "\ +cdecimal_sci: %s\n\ +decimal_sci: %s\n\ +cdecimal_eng: %s\n\ +decimal_eng: %s\n" + +_exc_fmt_tuple = "\ +cdecimal_tuple: %s\n\ +decimal_tuple: %s\n" + +_exc_fmt_obj = "\ +cdecimal: %s\n\ +decimal: %s\n\n" + +class CdecException(ArithmeticError): + def __init__(self, result, funcname, operands, fctxstr, dctxstr): + self.errstring = "Error in %s(%s" % (funcname, operands[0].dec) + for op in operands[1:]: + if op: self.errstring += ", %s" % op.dec + self.errstring += "):\n\n" + if isinstance(result, cdec): + self.errstring += _exc_fmt % (str(result.mpd), + str(result.dec), + result.mpd.to_eng(), + result.dec.to_eng_string()) + mpd_tuple = result.mpd.as_tuple() + dec_tuple = result.dec.as_tuple() + if mpd_tuple != dec_tuple: + self.errstring += _exc_fmt_tuple % (str(mpd_tuple), + str(dec_tuple)) + else: + self.errstring += _exc_fmt_obj % (str(result[0]), str(result[1])) + self.errstring += "%s\n%s\n\n" % (fctxstr, dctxstr) + def __str__(self): + return self.errstring + + +class dHandlerCdec: + """For cdec return values: + + Handle known disagreements between decimal.py and cdecimal.so. + This is just a temporary measure against cluttered output. + Detection is crude and possibly unreliable.""" + + def __init__(self): + self.logb_round_if_gt_prec = 0 + self.ulpdiff = 0 + self.powmod_zeros = 0 + self.total_mag_nan = 0 + self.quantize_status = 0 + self.maxctx = decimal.Context(Emax=10**18, Emin=-10**18) + + def default(self, result, operands): + return False + + def harrison_ulp(self, dec): + """Harrison ULP: ftp://ftp.inria.fr/INRIA/publication/publi-pdf/RR/RR-5504.pdf""" + a = dec.next_plus() + b = dec.next_minus() + return abs(a - b) + + def standard_ulp(self, dec, prec): + return decimal._dec_from_triple(0, '1', dec._exp+len(dec._int)-prec) + + def rounding_direction(self, x, mode): + """Determine the effective direction of the rounding when + the exact result x is rounded according to mode. + Return -1 for downwards, 0 for undirected, 1 for upwards, + 2 for ROUND_05UP.""" + d = decimal + cmp = 1 if x.compare_total(d.Decimal("+0")) >= 0 else -1 + + if mode in (d.ROUND_HALF_EVEN, d.ROUND_HALF_UP, d.ROUND_HALF_DOWN): + return 0 + elif mode == d.ROUND_CEILING: + return 1 + elif mode == d.ROUND_FLOOR: + return -1 + elif mode == d.ROUND_UP: + return cmp + elif mode == d.ROUND_DOWN: + return -cmp + elif mode == d.ROUND_05UP: + return 2 + else: + raise ValueError("Unexpected rounding mode: %s" % mode) + + def check_ulpdiff(self, exact, rounded): + # current precision + p = context.d.prec + + # Convert infinities to the largest representable number + 1. + x = exact + if exact.is_infinite(): + x = decimal._dec_from_triple(exact._sign, '10', context.d.Emax) + y = rounded + if rounded.is_infinite(): + y = decimal._dec_from_triple(rounded._sign, '10', context.d.Emax) + + # err = (rounded - exact) / ulp(rounded) + self.maxctx.prec = p * 2 + t = self.maxctx.subtract(y, x) + if context.f._flags & cdecimal.DecClamped or \ + context.f._flags & cdecimal.DecUnderflow: + # The standard ulp does not work in Underflow territory. + ulp = self.harrison_ulp(y) + else: + ulp = self.standard_ulp(y, p) + # Error in ulps. + err = self.maxctx.divide(t, ulp) + + d = decimal + dir = self.rounding_direction(x, context.d.rounding) + if dir == 0: + if d.Decimal("-0.6") < err < d.Decimal("0.6"): + return True + elif dir == 1: # directed, upwards + if d.Decimal("-0.1") < err < d.Decimal("1.1"): + return True + elif dir == -1: # directed, downwards + if d.Decimal("-1.1") < err < d.Decimal("0.1"): + return True + else: # ROUND_05UP + if d.Decimal("-1.1") < err < d.Decimal("1.1"): + return True + + print("ulp: %s error: %s exact: %s mpd_rounded: %s" + % (ulp, err, exact, rounded)) + return False + + def un_resolve_ulp(self, result, funcname, operands): + """Check if results of cdecimal's exp, ln and log10 functions are + within the allowed ulp ranges. This function is only called if + context.f._allcr is 0.""" + # "exact" result, double precision, half_even + self.maxctx.prec = context.d.prec * 2 + op = operands[0].dec + exact = getattr(op, funcname)(context=self.maxctx) + + # cdecimal's rounded result + s = str(result.mpd) + rounded = decimal.Decimal(s) + + self.ulpdiff += 1 + return self.check_ulpdiff(exact, rounded) + + def bin_resolve_ulp(self, result, funcname, operands): + """Check if results of cdecimal's power function are within the + allowed ulp ranges.""" + # "exact" result, double precision, half_even + self.maxctx.prec = context.d.prec * 2 + op1 = operands[0].dec + op2 = operands[1].dec + exact = getattr(op1, funcname)(op2, context=self.maxctx) + + # cdecimal's rounded result + s = str(result.mpd) + rounded = decimal.Decimal(s) + + self.ulpdiff += 1 + return self.check_ulpdiff(exact, rounded) + + def exp(self, result, operands): + if result.mpd.is_nan() or result.dec.is_nan(): + return False + if context.f._allcr: + return False + return self.un_resolve_ulp(result, "exp", operands) + + def log10(self, result, operands): + if result.mpd.is_nan() or result.dec.is_nan(): + return False + if context.f._allcr: + return False + return self.un_resolve_ulp(result, "log10", operands) + + def ln(self, result, operands): + if result.mpd.is_nan() or result.dec.is_nan(): + return False + if context.f._allcr: + return False + return self.un_resolve_ulp(result, "ln", operands) + + def __pow__(self, result, operands): + if operands[2] is not None: # three argument __pow__ + # issue7049: third arg must fit into precision + if (operands[0].mpd.is_zero() != operands[1].mpd.is_zero()): + if (result.mpd == 0 or result.mpd == 1) and result.dec.is_nan(): + if (not context.f.flags[cdecimal.InvalidOperation]) and \ + context.d.flags[decimal.InvalidOperation]: + self.powmod_zeros += 1 + return True + # issue7049: ideal exponent + if decimal.Decimal(str(result.mpd)) == result.dec: + return True + elif result.mpd.is_nan() or result.dec.is_nan(): + return False + elif context.f.flags[cdecimal.Rounded] and \ + context.f.flags[cdecimal.Inexact] and \ + context.d.flags[decimal.Rounded] and \ + context.d.flags[decimal.Inexact]: + # decimal.py: correctly-rounded pow() + return self.bin_resolve_ulp(result, "__pow__", operands) + else: + return False + power = __pow__ + + if py_minor < 2: + def rotate(self, result, operands): + """truncate excess digits before the operation""" + if len(operands[0].dec._int) > context.f.prec: + return True + return False + shift = rotate + + def compare_total_mag(self, result, operands): + if operands[0].mpd.is_nan() and operands[1].mpd.is_nan() and \ + abs(result.mpd) == 1 and abs(result.dec) == 1: + self.total_mag_nan += 1 + return True + return False + compare_total = compare_total_mag + + def logb(self, result, operands): + if context.f.flags[cdecimal.Rounded] and \ + (not context.d.flags[decimal.Rounded]): + self.logb_round_if_gt_prec += 1 + return True + return False + + +class dHandlerObj(): + """For non-decimal return values: + + Handle known disagreements between decimal.py and cdecimal.so. + Currently there are none.""" + + def __init__(self): + pass + + def default(self, result, operands): + return False + __eq__ = __ne__ = __ge__ = __gt__ = __le__ = __lt__ = \ + __repr__ = __str__ = default + + if py_minor <= 1: + # Fixed in release31-maint, but a lot of distributed + # versions do not have the fix yet. + def is_normal(self, result, operands): + # Issue7099 + if operands[0].mpd.is_normal(): + return True + + +dhandler_cdec = dHandlerCdec() +def cdec_known_disagreement(result, funcname, operands): + return getattr(dhandler_cdec, funcname, dhandler_cdec.default)(result, operands) + +dhandler_obj = dHandlerObj() +def obj_known_disagreement(result, funcname, operands): + return getattr(dhandler_obj, funcname, dhandler_obj.default)(result, operands) + + +def verify(result, funcname, operands): + """Verifies that after operation 'funcname' with operand(s) 'operands' + result[0] and result[1] as well as the context flags have the same + values.""" + global EXIT_STATUS + if result[0] != result[1] or not context.assert_eq_status(): + if obj_known_disagreement(result, funcname, operands): + return # skip known disagreements + EXIT_STATUS = 1 + raise CdecException(result, funcname, operands, + str(context.f), str(context.d)) + + +class cdec(object): + """Joins cdecimal.so and decimal.py for redundant calculations with error + checking. Always calls the context methods of cdecimal and decimal. This + is not very clean, but an easy way of adapting deccheck.py for testing + context methods.""" + + __slots__ = ['mpd', 'dec'] + + def __new__(cls, value=None): + self = object.__new__(cls) + self.mpd = None + self.dec = None + if value is not None: + context.clear_status() + if isinstance(value, float): + self.mpd = context.f.create_decimal_from_float(value) + self.dec = context.d.create_decimal_from_float(value) + else: + self.mpd = context.f.create_decimal(value) + self.dec = context.d.create_decimal(value) + self.verify('__xnew__', (value,)) + return self + + def verify(self, funcname, operands): + """Verifies that after operation 'funcname' with operand(s) 'operands' + self.mpd and self.dec as well as the context flags have the same + values.""" + global EXIT_STATUS + mpdstr = str(self.mpd) + decstr = str(self.dec) + mpdstr_eng = self.mpd.to_eng_string() + decstr_eng = self.dec.to_eng_string() + if mpdstr != decstr or mpdstr_eng != decstr_eng or \ + not context.assert_eq_status(): + if cdec_known_disagreement(self, funcname, operands): + return # skip known disagreements + EXIT_STATUS = 1 + raise CdecException(self, funcname, operands, + str(context.f), str(context.d)) + + def unaryfunc(self, funcname): + "unary function returning a cdec, uses the context methods" + context.clear_status() + c = cdec() + c.mpd = getattr(context.f, funcname)(self.mpd) + c.dec = getattr(context.d, funcname)(self.dec) + c.verify(funcname, (self,)) + return c + + def obj_unaryfunc(self, funcname): + "unary function returning an object other than a cdec" + context.clear_status() + r_mpd = getattr(context.f, funcname)(self.mpd) + r_dec = getattr(context.d, funcname)(self.dec) + verify((r_mpd, r_dec), funcname, (self,)) + return r_mpd + + def binaryfunc(self, other, funcname): + "binary function returning a cdec, uses the context methods" + context.clear_status() + c = cdec() + other_mpd = other_dec = other + if isinstance(other, cdec): + other_mpd = other.mpd + other_dec = other.dec + c.mpd = getattr(context.f, funcname)(self.mpd, other_mpd) + c.dec = getattr(context.d, funcname)(self.dec, other_dec) + c.verify(funcname, (self, other)) + return c + + def obj_binaryfunc(self, other, funcname): + "binary function returning an object other than a cdec" + context.clear_status() + other_mpd = other_dec = other + if isinstance(other, cdec): + other_mpd = other.mpd + other_dec = other.dec + r_mpd = getattr(context.f, funcname)(self.mpd, other_mpd) + r_dec = getattr(context.d, funcname)(self.dec, other_dec) + verify((r_mpd, r_dec), funcname, (self, other)) + return r_mpd + + def ternaryfunc(self, other, third, funcname): + "ternary function returning a cdec, uses the context methods" + context.clear_status() + c = cdec() + other_mpd = other_dec = other + if isinstance(other, cdec): + other_mpd = other.mpd + other_dec = other.dec + third_mpd = third_dec = third + if isinstance(third, cdec): + third_mpd = third.mpd + third_dec = third.dec + if funcname == 'power': + if (third is not None): + c.mpd = context.f.powmod(self.mpd, other_mpd, third_mpd) + else: + c.mpd = context.f.pow(self.mpd, other_mpd) + else: + c.mpd = getattr(context.f, funcname)(self.mpd, other_mpd, third_mpd) + c.dec = getattr(context.d, funcname)(self.dec, other_dec, third_dec) + c.verify(funcname, (self, other, third)) + return c + + def __repr__(self): + self.obj_unaryfunc('__repr__') + return "cdec('" + str(self.mpd) + "')" + + def __str__(self): + self.obj_unaryfunc('__str__') + return str(self.mpd) + + def abs(self): + return self.unaryfunc('abs') + + def add(self, other): + return self.binaryfunc(other, 'add') + + def compare(self, other): + return self.binaryfunc(other, 'compare') + + def compare_signal(self, other): + return self.binaryfunc(other, 'compare_signal') + + def compare_total(self, other): + return self.binaryfunc(other, 'compare_total') + + def compare_total_mag(self, other): + return self.binaryfunc(other, 'compare_total_mag') + + def copy_abs(self): + return self.unaryfunc('copy_abs') + + def copy_decimal(self): + return self.unaryfunc('copy_decimal') + + def copy_negate(self): + return self.unaryfunc('copy_negate') + + def copy_sign(self, other): + return self.binaryfunc(other, 'copy_sign') + + def create_decimal(self): + return self.unaryfunc('create_decimal') + + def divide(self, other): + return self.binaryfunc(other, 'divide') + + def divide_int(self, other): + return self.binaryfunc(other, 'divide_int') + + def divmod(self, other): + context.clear_status() + q = cdec() + r = cdec() + other_mpd = other_dec = other + if isinstance(other, cdec): + other_mpd = other.mpd + other_dec = other.dec + q.mpd, r.mpd = context.f.divmod(self.mpd, other_mpd) + q.dec, r.dec = context.d.divmod(self.dec, other_dec) + q.verify('divmod', (self, other)) + r.verify('divmod', (self, other)) + return (q, r) + + def exp(self): + return self.unaryfunc('exp') + + def fma(self, other, third): + return self.ternaryfunc(other, third, 'fma') + + # imag + # invroot + + def is_canonical(self): + return self.obj_unaryfunc('is_canonical') + + def is_finite(self): + return self.obj_unaryfunc('is_finite') + + def is_infinite(self): + return self.obj_unaryfunc('is_infinite') + + def is_nan(self): + return self.obj_unaryfunc('is_nan') + + def is_normal(self): + return self.obj_unaryfunc('is_normal') + + def is_qnan(self): + return self.obj_unaryfunc('is_qnan') + + def is_signed(self): + return self.obj_unaryfunc('is_signed') + + def is_snan(self): + return self.obj_unaryfunc('is_snan') + + def is_subnormal(self): + return self.obj_unaryfunc('is_subnormal') + + def is_zero(self): + return self.obj_unaryfunc('is_zero') + + def ln(self): + return self.unaryfunc('ln') + + def log10(self): + return self.unaryfunc('log10') + + def logb(self): + return self.unaryfunc('logb') + + def logical_and(self, other): + return self.binaryfunc(other, 'logical_and') + + def logical_invert(self): + return self.unaryfunc('logical_invert') + + def logical_or(self, other): + return self.binaryfunc(other, 'logical_or') + + def logical_xor(self, other): + return self.binaryfunc(other, 'logical_xor') + + def max(self, other): + return self.binaryfunc(other, 'max') + + def max_mag(self, other): + return self.binaryfunc(other, 'max_mag') + + def min(self, other): + return self.binaryfunc(other, 'min_mag') + + def min_mag(self, other): + return self.binaryfunc(other, 'min_mag') + + def minus(self): + return self.unaryfunc('minus') + + def multiply(self, other): + return self.binaryfunc(other, 'multiply') + + def next_minus(self): + return self.unaryfunc('next_minus') + + def next_plus(self): + return self.unaryfunc('next_plus') + + def next_toward(self, other): + return self.binaryfunc(other, 'next_toward') + + def normalize(self): + return self.unaryfunc('normalize') + + def number_class(self): + return self.obj_unaryfunc('number_class') + + def plus(self): + return self.unaryfunc('plus') + + def power(self, other, mod=None): + return self.ternaryfunc(other, mod, 'power') + + # powmod: same as __pow__ or power with three arguments + + def quantize(self, other): + return self.binaryfunc(other, 'quantize') + + # real + # reduce: same as normalize + + def remainder(self, other): + return self.binaryfunc(other, 'remainder') + + def remainder_near(self, other): + return self.binaryfunc(other, 'remainder_near') + + def rotate(self, other): + return self.binaryfunc(other, 'rotate') + + def same_quantum(self, other): + return self.obj_binaryfunc(other, 'same_quantum') + + def scaleb(self, other): + return self.binaryfunc(other, 'scaleb') + + def shift(self, other): + return self.binaryfunc(other, 'shift') + + # sign + + def sqrt(self): + return self.unaryfunc('sqrt') + + def subtract(self, other): + return self.binaryfunc(other, 'subtract') + + def to_eng_string(self): + return self.obj_unaryfunc('to_eng_string') + + def to_integral(self): + return self.unaryfunc('to_integral') + + def to_integral_exact(self): + return self.unaryfunc('to_integral_exact') + + def to_integral_value(self): + return self.unaryfunc('to_integral_value') + + def to_sci_string(self): + return self.obj_unaryfunc('to_sci_string') + + +def log(fmt, args=None): + if args: + sys.stdout.write(''.join((fmt, '\n')) % args) + else: + sys.stdout.write(''.join((str(fmt), '\n'))) + sys.stdout.flush() + +def test_unary(method, prec_lst, iter): + log("testing %s ...", method) + for prec in prec_lst: + log(" prec: %d", prec) + context.prec = prec + for rounding in sorted(decround): + context.rounding = rounding + rprec = 10**prec + exprange = context.f.Emax + if method in ['__int__', '__long__', '__trunc__', 'to_integral', \ + 'to_integral_value', 'to_integral_value']: + exprange = 9999 + for a in un_close_to_pow10(prec, exprange, iter): + try: + x = cdec(a) + getattr(x, method)() + except CdecException as err: + log(err) + for a in un_close_numbers(prec, exprange, -exprange, iter): + try: + x = cdec(a) + getattr(x, method)() + except CdecException as err: + log(err) + for a in un_incr_digits_tuple(prec, exprange, iter): + try: + x = cdec(a) + getattr(x, method)() + except CdecException as err: + log(err) + for i in range(1000): + try: + s = randdec(prec, exprange) + x = cdec(s) + getattr(x, method)() + except CdecException as err: + log(err) + except OverflowError: + pass + try: + s = randtuple(prec, exprange) + x = cdec(s) + getattr(x, method)() + except CdecException as err: + log(err) + except OverflowError: + pass + +def test_un_logical(method, prec_lst, iter): + log("testing %s ...", method) + for prec in prec_lst: + log(" prec: %d", prec) + context.prec = prec + for rounding in sorted(decround): + context.rounding = rounding + for a in logical_un_incr_digits(prec, iter): + try: + x = cdec(a) + getattr(x, method)() + except CdecException as err: + log(err) + for i in range(1000): + try: + s = randdec(prec, 999999) + x = cdec(s) + getattr(x, method)() + except CdecException as err: + log(err) + except OverflowError: + pass + +def test_binary(method, prec_lst, iter): + log("testing %s ...", method) + for prec in prec_lst: + log(" prec: %d", prec) + context.prec = prec + for rounding in sorted(decround): + context.rounding = rounding + exprange = context.f.Emax + if method in ['__pow__', '__rpow__', 'power']: + exprange = 9999 + for a, b in bin_close_to_pow10(prec, exprange, iter): + try: + x = cdec(a) + y = cdec(b) + getattr(x, method)(y) + except CdecException as err: + log(err) + for a, b in bin_close_numbers(prec, exprange, -exprange, iter): + try: + x = cdec(a) + y = cdec(b) + getattr(x, method)(y) + except CdecException as err: + log(err) + for a, b in bin_incr_digits(prec, exprange, iter): + try: + x = cdec(a) + y = cdec(b) + getattr(x, method)(y) + except CdecException as err: + log(err) + for i in range(1000): + s1 = randdec(prec, exprange) + s2 = randdec(prec, exprange) + try: + x = cdec(s1) + y = cdec(s2) + getattr(x, method)(y) + except CdecException as err: + log(err) + +def test_bin_logical(method, prec_lst, iter): + log("testing %s ...", method) + for prec in prec_lst: + log(" prec: %d", prec) + context.prec = prec + for rounding in sorted(decround): + context.rounding = rounding + for a, b in logical_bin_incr_digits(prec, iter): + try: + x = cdec(a) + y = cdec(b) + getattr(x, method)(y) + except CdecException as err: + log(err) + for i in range(1000): + s1 = randdec(prec, 999999) + s2 = randdec(prec, 999999) + try: + x = cdec(s1) + y = cdec(s2) + getattr(x, method)(y) + except CdecException as err: + log(err) + +def test_ternary(method, prec_lst, iter): + log("testing %s ...", method) + for prec in prec_lst: + log(" prec: %d", prec) + context.prec = prec + for rounding in sorted(decround): + context.rounding = rounding + exprange = context.f.Emax + if method in ['__pow__', 'power']: + exprange = 9999 + for a, b, c in tern_close_numbers(prec, exprange, -exprange, iter): + try: + x = cdec(a) + y = cdec(b) + z = cdec(c) + getattr(x, method)(y, z) + except CdecException as err: + log(err) + for a, b, c in tern_incr_digits(prec, exprange, iter): + try: + x = cdec(a) + y = cdec(b) + z = cdec(c) + getattr(x, method)(y, z) + except CdecException as err: + log(err) + for i in range(1000): + s1 = randdec(prec, 2*exprange) + s2 = randdec(prec, 2*exprange) + s3 = randdec(prec, 2*exprange) + try: + x = cdec(s1) + y = cdec(s2) + z = cdec(s3) + getattr(x, method)(y, z) + except CdecException as err: + log(err) + +def test_from_float(prec_lst): + log("testing create_decimal_from_float ...") + for prec in prec_lst: + log(" prec: %d", prec) + context.prec = prec + for rounding in sorted(decround): + context.rounding = rounding + exprange = 384 + for i in range(1000): + intpart = str(random.randrange(100000000000000000000000000000000000000)) + fracpart = str(random.randrange(100000000000000000000000000000000000000)) + exp = str(random.randrange(-384, 384)) + fstring = intpart + '.' + fracpart + 'e' + exp + f = float(fstring) + try: + c = cdec(f) + except CdecException as err: + log(err) + + +if __name__ == '__main__': + + import time + + samples = 1 + iterations = 1 + + if '--short' in sys.argv: + samples = 1 + iterations = 1 + elif '--medium' in sys.argv: + samples = 1 + iterations = None + elif '--long' in sys.argv: + samples = 5 + iterations = None + elif '--all' in sys.argv: + samples = 100 + iterations = None + + all_context_methods = set(dir(cdecimal.getcontext()) + dir(decimal.getcontext())) + all_cdec_methods = [m for m in dir(cdec) if m in all_context_methods] + untested_methods = [m for m in all_context_methods if not (m in all_cdec_methods)] + + unary_methods = [] + binary_methods = [] + ternary_methods = [] + for m in all_cdec_methods: + try: + l = len(inspect.getargspec(getattr(cdec, m))[0]) + except TypeError: + continue + if l == 1: + unary_methods.append(m) + elif l == 2: + binary_methods.append(m) + elif l == 3: + ternary_methods.append(m) + else: + raise ValueError((m, l)) + + unary_methods.remove('__repr__') + unary_methods.remove('__str__') + binary_methods.remove('__new__') + untested_methods.append('__repr__') + untested_methods.append('__str__') + untested_methods.append('__new__') + untested_methods.remove('create_decimal_from_float') + + binary_methods.append('power') + + untested_methods.sort() + unary_methods.sort() + binary_methods.sort() + ternary_methods.sort() + + + x = int(time.time()) + random.seed(x) + log("\nRandom seed: %d\n\n", x) + log("Skipping tests: \n\n%s\n", untested_methods) + + + for method in unary_methods: + prec_lst = sorted(random.sample(range(1, 101), samples)) + test_unary(method, prec_lst, iterations) + + for method in binary_methods: + prec_lst = sorted(random.sample(range(1, 101), samples)) + test_binary(method, prec_lst, iterations) + + for method in ternary_methods: + prec_lst = sorted(random.sample(range(1, 101), samples)) + test_ternary(method, prec_lst, iterations) + + prec_lst = sorted(random.sample(range(1, 101), samples)) + test_un_logical('logical_invert', prec_lst, iterations) + + for method in ['logical_and', 'logical_or', 'logical_xor']: + prec_lst = sorted(random.sample(range(1, 101), samples)) + test_bin_logical(method, prec_lst, iterations) + + prec_lst = sorted(random.sample(range(1, 101), samples)) + test_from_float(prec_lst) + + + sys.exit(EXIT_STATUS) diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/python/deccheck.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/python/deccheck.py Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,1537 @@ +#!/usr/bin/env python + +# +# Copyright (c) 2008-2010 Stefan Krah. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + + +# +# The cdec (for "check decimal") class checks cdecimal.so against decimal.py. +# A cdec object consists of a cdecimal.Decimal and a decimal.Decimal. Every +# operation is carried out on both types. If the results don't match, an +# exception is raised. +# +# Usage: python deccheck.py [--short|--medium|--long|--all] +# + + +import cdecimal, decimal +import sys, inspect +import array + +from copy import copy +from randdec import * +from randfloat import * + + +EXIT_STATUS = 0 +py_minor = sys.version_info[1] +py_micro = sys.version_info[2] + + +# Translate symbols. +deccond = { + cdecimal.Clamped: decimal.Clamped, + cdecimal.ConversionSyntax: decimal.ConversionSyntax, + cdecimal.DivisionByZero: decimal.DivisionByZero, + cdecimal.DivisionImpossible: decimal.InvalidOperation, + cdecimal.DivisionUndefined: decimal.DivisionUndefined, + cdecimal.Inexact: decimal.Inexact, + cdecimal.InvalidContext: decimal.InvalidContext, + cdecimal.InvalidOperation: decimal.InvalidOperation, + cdecimal.Overflow: decimal.Overflow, + cdecimal.Rounded: decimal.Rounded, + cdecimal.Subnormal: decimal.Subnormal, + cdecimal.Underflow: decimal.Underflow, +} + +mpdcond = { + decimal.Clamped: cdecimal.Clamped, + decimal.ConversionSyntax: cdecimal.ConversionSyntax, + decimal.DivisionByZero: cdecimal.DivisionByZero, + decimal.InvalidOperation: cdecimal.DivisionImpossible, + decimal.DivisionUndefined: cdecimal.DivisionUndefined, + decimal.Inexact: cdecimal.Inexact, + decimal.InvalidContext: cdecimal.InvalidContext, + decimal.InvalidOperation: cdecimal.InvalidOperation, + decimal.Overflow: cdecimal.Overflow, + decimal.Rounded: cdecimal.Rounded, + decimal.Subnormal: cdecimal.Subnormal, + decimal.Underflow: cdecimal.Underflow +} + +decround = { + cdecimal.ROUND_UP: decimal.ROUND_UP, + cdecimal.ROUND_DOWN: decimal.ROUND_DOWN, + cdecimal.ROUND_CEILING: decimal.ROUND_CEILING, + cdecimal.ROUND_FLOOR: decimal.ROUND_FLOOR, + cdecimal.ROUND_HALF_UP: decimal.ROUND_HALF_UP, + cdecimal.ROUND_HALF_DOWN: decimal.ROUND_HALF_DOWN, + cdecimal.ROUND_HALF_EVEN: decimal.ROUND_HALF_EVEN, + cdecimal.ROUND_05UP: decimal.ROUND_05UP +} + + +class Context(object): + """Provides a convenient way of syncing the cdecimal and decimal contexts""" + + __slots__ = ['f', 'd'] + + def __init__(self, mpdctx=cdecimal.getcontext()): + """Initialization is from the cdecimal context""" + self.f = mpdctx + self.d = decimal.getcontext() + self.d.prec = self.f.prec + self.d.Emin = self.f.Emin + self.d.Emax = self.f.Emax + self.d.rounding = decround[self.f.rounding] + self.d.capitals = self.f.capitals + self.settraps([sig for sig in self.f.traps if self.f.traps[sig]]) + self.setstatus([sig for sig in self.f.flags if self.f.flags[sig]]) + self.d._clamp = self.f._clamp + + def getprec(self): + assert(self.f.prec == self.d.prec) + return self.f.prec + + def setprec(self, val): + self.f.prec = val + self.d.prec = val + + def getemin(self): + assert(self.f.Emin == self.d.Emin) + return self.f.Emin + + def setemin(self, val): + self.f.Emin = val + self.d.Emin = val + + def getemax(self): + assert(self.f.Emax == self.d.Emax) + return self.f.Emax + + def setemax(self, val): + self.f.Emax = val + self.d.Emax = val + + def getround(self): + return self.d.rounding + + def setround(self, val): + self.f.rounding = val + self.d.rounding = decround[val] + + def getcapitals(self): + assert(self.f.capitals == self.d.capitals) + return self.f.capitals + + def setcapitals(self, val): + self.f.capitals = val + self.d.capitals = val + + def getclamp(self): + assert(self.f._clamp == self.d._clamp) + return self.f._clamp + + def setclamp(self, val): + self.f._clamp = val + self.d._clamp = val + + prec = property(getprec, setprec) + Emin = property(getemin, setemin) + Emax = property(getemax, setemax) + rounding = property(getround, setround) + clamp = property(getclamp, setclamp) + capitals = property(getcapitals, setcapitals) + + def clear_traps(self): + self.f.clear_traps() + for trap in self.d.traps: + self.d.traps[trap] = False + + def clear_status(self): + self.f.clear_flags() + self.d.clear_flags() + + def settraps(self, lst): # cdecimal signal list + self.clear_traps() + for signal in lst: + self.f.traps[signal] = True + self.d.traps[deccond[signal]] = True + + def setstatus(self, lst): # cdecimal signal list + self.clear_status() + for signal in lst: + self.f.flags[signal] = True + self.d.flags[deccond[signal]] = True + + def assert_eq_status(self): + """assert equality of cdecimal and decimal status""" + for signal in self.f.flags: + if signal == cdecimal.FloatOperation: + continue + if self.f.flags[signal] == (not self.d.flags[deccond[signal]]): + return False + return True + + +# We don't want exceptions so that we can compare the status flags. +context = Context() +context.Emin = cdecimal.MIN_EMIN +context.Emax = cdecimal.MAX_EMAX +context.clear_traps() + +# When creating decimals, cdecimal is ultimately limited by the maximum +# context values. We emulate this restriction for decimal.py. +maxcontext = decimal.Context( + prec=cdecimal.MAX_PREC, + Emin=cdecimal.MIN_EMIN, + Emax=cdecimal.MAX_EMAX, + rounding=decimal.ROUND_HALF_UP, + capitals=1 +) +maxcontext._clamp = 0 + +def decimal_new(value): + maxcontext.traps = copy(context.d.traps) + maxcontext.clear_flags() + dec = maxcontext.create_decimal(value) + if maxcontext.flags[decimal.Inexact] or \ + maxcontext.flags[decimal.Rounded]: + dec = decimal.Decimal("NaN") + context.d.flags[decimal.InvalidOperation] = True + return dec + + +_exc_fmt = "\ +cdecimal_sci: %s\n\ +decimal_sci: %s\n\ +cdecimal_eng: %s\n\ +decimal_eng: %s\n" + +_exc_fmt_tuple = "\ +cdecimal_tuple: %s\n\ +decimal_tuple: %s\n" + +_exc_fmt_obj = "\ +cdecimal: %s\n\ +decimal: %s\n\n" + +class CdecException(ArithmeticError): + def __init__(self, result, funcname, operands, fctxstr, dctxstr): + self.errstring = "Error in %s(%s" % (funcname, operands[0]) + for op in operands[1:]: + self.errstring += ", %s" % op + self.errstring += "):\n\n" + if isinstance(result, cdec): + self.errstring += _exc_fmt % (str(result.mpd), + str(result.dec), + result.mpd.to_eng(), + result.dec.to_eng_string()) + mpd_tuple = result.mpd.as_tuple() + dec_tuple = result.dec.as_tuple() + if mpd_tuple != dec_tuple: + self.errstring += _exc_fmt_tuple % (str(mpd_tuple), + str(dec_tuple)) + else: + self.errstring += _exc_fmt_obj % (str(result[0]), str(result[1])) + self.errstring += "%s\n%s\n\n" % (fctxstr, dctxstr) + def __str__(self): + return self.errstring + + +class dHandlerCdec: + """For cdec return values: + + Handle known disagreements between decimal.py and cdecimal.so. + This is just a temporary measure against cluttered output. + Detection is crude and possibly unreliable.""" + + def __init__(self): + self.logb_round_if_gt_prec = 0 + self.ulpdiff = 0 + self.powmod_zeros = 0 + self.total_mag_nan = 0 + self.quantize_status = 0 + self.max_status = 0 + self.maxctx = decimal.Context(Emax=10**18, Emin=-10**18) + + def default(self, result, operands): + return False + + def harrison_ulp(self, dec): + """Harrison ULP: ftp://ftp.inria.fr/INRIA/publication/publi-pdf/RR/RR-5504.pdf""" + a = dec.next_plus() + b = dec.next_minus() + return abs(a - b) + + def standard_ulp(self, dec, prec): + return decimal._dec_from_triple(0, '1', dec._exp+len(dec._int)-prec) + + def rounding_direction(self, x, mode): + """Determine the effective direction of the rounding when + the exact result x is rounded according to mode. + Return -1 for downwards, 0 for undirected, 1 for upwards, + 2 for ROUND_05UP.""" + d = decimal + cmp = 1 if x.compare_total(d.Decimal("+0")) >= 0 else -1 + + if mode in (d.ROUND_HALF_EVEN, d.ROUND_HALF_UP, d.ROUND_HALF_DOWN): + return 0 + elif mode == d.ROUND_CEILING: + return 1 + elif mode == d.ROUND_FLOOR: + return -1 + elif mode == d.ROUND_UP: + return cmp + elif mode == d.ROUND_DOWN: + return -cmp + elif mode == d.ROUND_05UP: + return 2 + else: + raise ValueError("Unexpected rounding mode: %s" % mode) + + def check_ulpdiff(self, exact, rounded): + # current precision + p = context.d.prec + + # Convert infinities to the largest representable number + 1. + x = exact + if exact.is_infinite(): + x = decimal._dec_from_triple(exact._sign, '10', context.d.Emax) + y = rounded + if rounded.is_infinite(): + y = decimal._dec_from_triple(rounded._sign, '10', context.d.Emax) + + # err = (rounded - exact) / ulp(rounded) + self.maxctx.prec = p * 2 + t = self.maxctx.subtract(y, x) + if context.f._flags & cdecimal.DecClamped or \ + context.f._flags & cdecimal.DecUnderflow: + # The standard ulp does not work in Underflow territory. + ulp = self.harrison_ulp(y) + else: + ulp = self.standard_ulp(y, p) + # Error in ulps. + err = self.maxctx.divide(t, ulp) + + d = decimal + dir = self.rounding_direction(x, context.d.rounding) + if dir == 0: + if d.Decimal("-0.6") < err < d.Decimal("0.6"): + return True + elif dir == 1: # directed, upwards + if d.Decimal("-0.1") < err < d.Decimal("1.1"): + return True + elif dir == -1: # directed, downwards + if d.Decimal("-1.1") < err < d.Decimal("0.1"): + return True + else: # ROUND_05UP + if d.Decimal("-1.1") < err < d.Decimal("1.1"): + return True + + print("ulp: %s error: %s exact: %s mpd_rounded: %s" + % (ulp, err, exact, rounded)) + return False + + def un_resolve_ulp(self, result, funcname, operands): + """Check if results of cdecimal's exp, ln and log10 functions are + within the allowed ulp ranges. This function is only called if + context.f._allcr is 0.""" + # "exact" result, double precision, half_even + self.maxctx.prec = context.d.prec * 2 + op = operands[0].dec + exact = getattr(op, funcname)(context=self.maxctx) + + # cdecimal's rounded result + s = str(result.mpd) + rounded = decimal.Decimal(s) + + self.ulpdiff += 1 + return self.check_ulpdiff(exact, rounded) + + def bin_resolve_ulp(self, result, funcname, operands): + """Check if results of cdecimal's power function are within the + allowed ulp ranges.""" + # "exact" result, double precision, half_even + self.maxctx.prec = context.d.prec * 2 + op1 = operands[0].dec + op2 = operands[1].dec + exact = getattr(op1, funcname)(op2, context=self.maxctx) + + # cdecimal's rounded result + s = str(result.mpd) + rounded = decimal.Decimal(s) + + self.ulpdiff += 1 + return self.check_ulpdiff(exact, rounded) + + def exp(self, result, operands): + if result.mpd.is_nan() or result.dec.is_nan(): + return False + if context.f._allcr: + return False + return self.un_resolve_ulp(result, "exp", operands) + + def log10(self, result, operands): + if result.mpd.is_nan() or result.dec.is_nan(): + return False + if context.f._allcr: + return False + return self.un_resolve_ulp(result, "log10", operands) + + def ln(self, result, operands): + if result.mpd.is_nan() or result.dec.is_nan(): + return False + if context.f._allcr: + return False + return self.un_resolve_ulp(result, "ln", operands) + + def __pow__(self, result, operands): + if operands[2] is not None: # three argument __pow__ + # issue7049: third arg must fit into precision + if (operands[0].mpd.is_zero() != operands[1].mpd.is_zero()): + if (result.mpd == 0 or result.mpd == 1) and result.dec.is_nan(): + if (not context.f.flags[cdecimal.InvalidOperation]) and \ + context.d.flags[decimal.InvalidOperation]: + self.powmod_zeros += 1 + return True + # issue7049: ideal exponent + if decimal.Decimal(str(result.mpd)) == result.dec: + return True + elif result.mpd.is_nan() or result.dec.is_nan(): + return False + elif context.f.flags[cdecimal.Rounded] and \ + context.f.flags[cdecimal.Inexact] and \ + context.d.flags[decimal.Rounded] and \ + context.d.flags[decimal.Inexact]: + # decimal.py: correctly-rounded pow() + return self.bin_resolve_ulp(result, "__pow__", operands) + else: + return False + power = __pow__ + + def __radd__(self, result, operands): + """decimal.py gives preference to the first nan""" + if operands[0].mpd.is_nan() and operands[1].mpd.is_nan() and \ + result.mpd.is_nan() and result.dec.is_nan(): + return True + return False + __rmul__ = __radd__ + + if py_minor <= 1: + def rotate(self, result, operands): + """truncate excess digits before the operation""" + if len(operands[0].dec._int) > context.f.prec: + return True + return False + shift = rotate + + def compare_total_mag(self, result, operands): + if operands[0].mpd.is_nan() and operands[1].mpd.is_nan() and \ + abs(result.mpd) == 1 and abs(result.dec) == 1: + self.total_mag_nan += 1 + return True + return False + compare_total = compare_total_mag + + def logb(self, result, operands): + if context.f.flags[cdecimal.Rounded] and \ + (not context.d.flags[decimal.Rounded]): + self.logb_round_if_gt_prec += 1 + return True + return False + + +class dHandlerObj(): + """For non-decimal return values: + + Handle known disagreements between decimal.py and cdecimal.so.""" + + def __init__(self): + pass + + def default(self, result, operands): + return False + __ge__ = __gt__ = __le__ = __lt__ = __repr__ = __str__ = default + + if py_minor >= 2: + __ne__ = __eq__ = default + + if py_minor <= 1: + def __eq__(self, result, operands): + """cdecimal raises for all sNaN comparisons""" + if operands[0].mpd.is_snan() or operands[1].mpd.is_snan(): + return True + __ne__ = __eq__ + + if py_minor <= 1: + # Fixed in release31-maint, but a lot of distributed + # versions do not have the fix yet. + def is_normal(self, result, operands): + # Issue7099 + if operands[0].mpd.is_normal(): + return True + + +dhandler_cdec = dHandlerCdec() +def cdec_known_disagreement(result, funcname, operands): + return getattr(dhandler_cdec, funcname, dhandler_cdec.default)(result, operands) + +dhandler_obj = dHandlerObj() +def obj_known_disagreement(result, funcname, operands): + return getattr(dhandler_obj, funcname, dhandler_obj.default)(result, operands) + + +def verify(result, funcname, operands): + """Verifies that after operation 'funcname' with operand(s) 'operands' + result[0] and result[1] as well as the context flags have the same + values.""" + global EXIT_STATUS + if result[0] != result[1] or not context.assert_eq_status(): + if obj_known_disagreement(result, funcname, operands): + return # skip known disagreements + EXIT_STATUS = 1 + raise CdecException(result, funcname, operands, + str(context.f), str(context.d)) + + +class cdec(object): + """Joins cdecimal.so and decimal.py for redundant calculations + with error checking.""" + + __slots__ = ['mpd', 'dec'] + + def __new__(cls, value=None): + self = object.__new__(cls) + self.mpd = None + self.dec = None + if value is not None: + context.clear_status() + if py_minor <= 1 and isinstance(value, float): + self.mpd = cdecimal.Decimal.from_float(value) + self.dec = decimal.Decimal.from_float(value) + else: + self.mpd = cdecimal.Decimal(value) + self.dec = decimal_new(value) + self.verify('__xnew__', (value,)) + return self + + def verify(self, funcname, operands): + """Verifies that after operation 'funcname' with operand(s) 'operands' + self.mpd and self.dec as well as the context flags have the same + values.""" + global EXIT_STATUS + mpdstr = str(self.mpd) + decstr = str(self.dec) + mpdstr_eng = self.mpd.to_eng_string() + decstr_eng = self.dec.to_eng_string() + mpd_tuple = self.mpd.as_tuple() + dec_tuple = self.dec.as_tuple() + if mpd_tuple != dec_tuple: # XXX + if mpd_tuple[2] == 'F' and dec_tuple[2] == 'F' and \ + mpd_tuple[1] == () and dec_tuple[1] == (0,): + return + if mpdstr != decstr or mpdstr_eng != decstr_eng or mpd_tuple != dec_tuple \ + or not context.assert_eq_status(): + if cdec_known_disagreement(self, funcname, operands): + return # skip known disagreements + EXIT_STATUS = 1 + raise CdecException(self, funcname, operands, + str(context.f), str(context.d)) + + def unaryfunc(self, funcname): + "unary function returning a cdec" + context.clear_status() + c = cdec() + c.mpd = getattr(self.mpd, funcname)() + c.dec = getattr(self.dec, funcname)() + c.verify(funcname, (self,)) + return c + + def unaryfunc_ctx(self, funcname): + "unary function returning a cdec, uses the context methods of decimal.py" + context.clear_status() + c = cdec() + c.mpd = getattr(self.mpd, funcname)() + c.dec = getattr(context.d, funcname)(self.dec) + c.verify(funcname, (self,)) + return c + + def obj_unaryfunc(self, funcname): + "unary function returning an object other than a cdec" + context.clear_status() + r_mpd = getattr(self.mpd, funcname)() + r_dec = getattr(self.dec, funcname)() + verify((r_mpd, r_dec), funcname, (self,)) + return r_mpd + + def binaryfunc(self, other, funcname): + "binary function returning a cdec" + context.clear_status() + c = cdec() + other_mpd = other_dec = other + if isinstance(other, cdec): + other_mpd = other.mpd + other_dec = other.dec + c.mpd = getattr(self.mpd, funcname)(other_mpd) + c.dec = getattr(self.dec, funcname)(other_dec) + c.verify(funcname, (self, other)) + return c + + def binaryfunc_ctx(self, other, funcname): + "binary function returning a cdec, uses the context methods of decimal.py" + context.clear_status() + c = cdec() + other_mpd = other_dec = other + if isinstance(other, cdec): + other_mpd = other.mpd + other_dec = other.dec + c.mpd = getattr(self.mpd, funcname)(other_mpd) + c.dec = getattr(context.d, funcname)(self.dec, other_dec) + c.verify(funcname, (self, other)) + return c + + def obj_binaryfunc(self, other, funcname): + "binary function returning an object other than a cdec" + context.clear_status() + other_mpd = other_dec = other + if isinstance(other, cdec): + other_mpd = other.mpd + other_dec = other.dec + r_mpd = getattr(self.mpd, funcname)(other_mpd) + r_dec = getattr(self.dec, funcname)(other_dec) + verify((r_mpd, r_dec), funcname, (self, other)) + return r_mpd + + def ternaryfunc(self, other, third, funcname): + "ternary function returning a cdec" + context.clear_status() + c = cdec() + other_mpd = other_dec = other + if isinstance(other, cdec): + other_mpd = other.mpd + other_dec = other.dec + third_mpd = third_dec = third + if isinstance(third, cdec): + third_mpd = third.mpd + third_dec = third.dec + c.mpd = getattr(self.mpd, funcname)(other_mpd, third_mpd) + c.dec = getattr(self.dec, funcname)(other_dec, third_dec) + c.verify(funcname, (self, other, third)) + return c + + def __abs__(self): + return self.unaryfunc('__abs__') + + def __add__(self, other): + return self.binaryfunc(other, '__add__') + + def __bool__(self): + return self.obj_unaryfunc('__bool__') + + def __copy__(self): + return self.unaryfunc('__copy__') + + def __deepcopy__(self, memo=None): + context.clear_status() + c = cdec() + c.mpd = self.mpd.__deepcopy__(memo) + c.dec = self.dec.__deepcopy__(memo) + c.verify('__deepcopy__', (self,)) + return c + + def __div__(self, other): + return self.binaryfunc(other, '__div__') + + def __divmod__(self, other): + context.clear_status() + q = cdec() + r = cdec() + other_mpd = other_dec = other + if isinstance(other, cdec): + other_mpd = other.mpd + other_dec = other.dec + q.mpd, r.mpd = self.mpd.__divmod__(other_mpd) + q.dec, r.dec = self.dec.__divmod__(other_dec, context.d) + q.verify('__divmod__', (self, other)) + r.verify('__divmod__', (self, other)) + return (q, r) + + def __eq__(self, other): + return self.obj_binaryfunc(other, '__eq__') + + def __float__(self): + if (self.mpd.is_nan() and self.dec.is_nan()): + return float("NaN") + try: + return self.obj_unaryfunc('__float__') + except ValueError: + return None + + def __floordiv__(self, other): + return self.binaryfunc(other, '__floordiv__') + + def __ge__(self, other): + return self.obj_binaryfunc(other, '__ge__') + + def __gt__(self, other): + return self.obj_binaryfunc(other, '__gt__') + + def __hash__(self): + if self.mpd.is_snan() or (py_minor <= 1 and self.mpd.is_nan()): + return None # for testing + raise ValueError('Cannot hash a NaN value.') + return self.obj_unaryfunc('__hash__') + + def __int__(self): + # ValueError or OverflowError + if self.mpd.is_special(): + return (None, None) + return self.obj_unaryfunc('__int__') + + def __le__(self, other): + return self.obj_binaryfunc(other, '__le__') + + def __long__(self): + # ValueError or OverflowError + if self.mpd.is_special(): + return (None, None) + return self.obj_unaryfunc('__long__') + + def __lt__(self, other): + return self.obj_binaryfunc(other, '__lt__') + + def __mod__(self, other): + return self.binaryfunc(other, '__mod__') + + def __mul__(self, other): + return self.binaryfunc(other, '__mul__') + + def __ne__(self, other): + return self.obj_binaryfunc(other, '__ne__') + + def __neg__(self): + return self.unaryfunc('__neg__') + + def __nonzero__(self): + return self.obj_unaryfunc('__nonzero__') + + def __pos__(self): + return self.unaryfunc('__pos__') + + def __pow__(self, other, mod=None): + return self.ternaryfunc(other, mod, '__pow__') + + def __radd__(self, other): + return self.binaryfunc(other, '__radd__') + + def __rdiv__(self, other): + return self.binaryfunc(other, '__rdiv__') + + def __rdivmod__(self, other): + context.clear_status() + q = cdec() + r = cdec() + other_mpd = other_dec = other + if isinstance(other, cdec): + other_mpd = other.mpd + other_dec = other.dec + q.mpd, r.mpd = self.mpd.__rdivmod__(other_mpd) + q.dec, r.dec = self.dec.__rdivmod__(other_dec, context.d) + q.verify('__rdivmod__', (self, other)) + r.verify('__rdivmod__', (self, other)) + return (q, r) + + # __reduce__ + + def __repr__(self): + self.obj_unaryfunc('__repr__') + return "cdec('" + str(self.mpd) + "')" + + def __rfloordiv__(self, other): + return self.binaryfunc(other, '__rfloordiv__') + + def __rmod__(self, other): + return self.binaryfunc(other, '__rmod__') + + def __rmul__(self, other): + return self.binaryfunc(other, '__rmul__') + + def __rsub__(self, other): + return self.binaryfunc(other, '__rsub__') + + def __rtruediv__(self, other): + return self.binaryfunc(other, '__rtruediv__') + + def __rpow__(self, other): + return other.__pow__(self) + + def __str__(self): + self.obj_unaryfunc('__str__') + return str(self.mpd) + + def __sub__(self, other): + return self.binaryfunc(other, '__sub__') + + def __truediv__(self, other): + return self.binaryfunc(other, '__truediv__') + + def __trunc__(self): + # ValueError or OverflowError + if self.mpd.is_special(): + return (None, None) + return self.obj_unaryfunc('__trunc__') + + def _apply(self): + return self.unaryfunc('_apply') + + def abs(self): + return self.unaryfunc_ctx('abs') + + def add(self, other): + return self.binaryfunc_ctx(other, 'add') + + def adjusted(self): + return self.obj_unaryfunc('adjusted') + + def canonical(self): + return self.unaryfunc('canonical') + + def compare(self, other): + return self.binaryfunc(other, 'compare') + + def compare_signal(self, other): + return self.binaryfunc(other, 'compare_signal') + + def compare_total(self, other): + return self.binaryfunc(other, 'compare_total') + + def compare_total_mag(self, other): + return self.binaryfunc(other, 'compare_total_mag') + + def copy_abs(self): + return self.unaryfunc('copy_abs') + + def copy_negate(self): + return self.unaryfunc('copy_negate') + + def copy_sign(self, other): + return self.binaryfunc(other, 'copy_sign') + + def divide(self, other): + return self.binaryfunc_ctx(other, 'divide') + + def divide_int(self, other): + return self.binaryfunc_ctx(other, 'divide_int') + + def divmod(self, other): + context.clear_status() + q = cdec() + r = cdec() + other_mpd = other_dec = other + if isinstance(other, cdec): + other_mpd = other.mpd + other_dec = other.dec + q.mpd, r.mpd = self.mpd.divmod(other_mpd) + q.dec, r.dec = context.d.divmod(self.dec, other_dec) + q.verify('divmod', (self, other)) + r.verify('divmod', (self, other)) + return (q, r) + + def exp(self): + return self.unaryfunc('exp') + + def fma(self, other, third): + return self.ternaryfunc(other, third, 'fma') + + # imag + # invroot + + def is_canonical(self): + return self.obj_unaryfunc('is_canonical') + + def is_finite(self): + return self.obj_unaryfunc('is_finite') + + def is_infinite(self): + return self.obj_unaryfunc('is_infinite') + + def is_nan(self): + return self.obj_unaryfunc('is_nan') + + def is_normal(self): + return self.obj_unaryfunc('is_normal') + + def is_qnan(self): + return self.obj_unaryfunc('is_qnan') + + def is_signed(self): + return self.obj_unaryfunc('is_signed') + + def is_snan(self): + return self.obj_unaryfunc('is_snan') + + def is_subnormal(self): + return self.obj_unaryfunc('is_subnormal') + + def is_zero(self): + return self.obj_unaryfunc('is_zero') + + def ln(self): + return self.unaryfunc('ln') + + def log10(self): + return self.unaryfunc('log10') + + def logb(self): + return self.unaryfunc('logb') + + def logical_and(self, other): + return self.binaryfunc(other, 'logical_and') + + def logical_invert(self): + return self.unaryfunc('logical_invert') + + def logical_or(self, other): + return self.binaryfunc(other, 'logical_or') + + def logical_xor(self, other): + return self.binaryfunc(other, 'logical_xor') + + def max(self, other): + return self.binaryfunc(other, 'max') + + def max_mag(self, other): + return self.binaryfunc(other, 'max_mag') + + def min(self, other): + return self.binaryfunc(other, 'min_mag') + + def min_mag(self, other): + return self.binaryfunc(other, 'min_mag') + + def minus(self): + return self.unaryfunc_ctx('minus') + + def multiply(self, other): + return self.binaryfunc_ctx(other, 'multiply') + + def next_minus(self): + return self.unaryfunc('next_minus') + + def next_plus(self): + return self.unaryfunc('next_plus') + + def next_toward(self, other): + return self.binaryfunc(other, 'next_toward') + + def normalize(self): + return self.unaryfunc('normalize') + + def number_class(self): + return self.obj_unaryfunc('number_class') + + def plus(self): + return self.unaryfunc_ctx('plus') + + def power(self, other, third=None): + "ternary function returning a cdec, uses the context methods of decimal.py" + context.clear_status() + c = cdec() + other_mpd = other_dec = other + if isinstance(other, cdec): + other_mpd = other.mpd + other_dec = other.dec + third_mpd = third_dec = third + if isinstance(third, cdec): + third_mpd = third.mpd + third_dec = third.dec + c.mpd = pow(self.mpd, other_mpd, third_mpd) + c.dec = pow(self.dec, other_dec, third_dec) + c.verify('power', (self, other, third)) + return c + + # powmod: same as __pow__ or power with three arguments + + def quantize(self, other): + return self.binaryfunc(other, 'quantize') + + def radix(self): + return self.obj_unaryfunc('radix') + + # real + # reduce: same as normalize + + def remainder(self, other): + return self.binaryfunc_ctx(other, 'remainder') + + def remainder_near(self, other): + return self.binaryfunc(other, 'remainder_near') + + def rotate(self, other): + return self.binaryfunc(other, 'rotate') + + def same_quantum(self, other): + return self.obj_binaryfunc(other, 'same_quantum') + + def scaleb(self, other): + return self.binaryfunc(other, 'scaleb') + + def shift(self, other): + return self.binaryfunc(other, 'shift') + + # sign + + def sqrt(self): + return self.unaryfunc('sqrt') + + def subtract(self, other): + return self.binaryfunc_ctx(other, 'subtract') + + def to_eng_string(self): + return self.obj_unaryfunc('to_eng_string') + + def to_integral(self): + return self.unaryfunc('to_integral') + + def to_integral_exact(self): + return self.unaryfunc('to_integral_exact') + + def to_integral_value(self): + return self.unaryfunc('to_integral_value') + + def to_sci_string(self): + context.clear_status() + r_mpd = self.mpd.to_sci_string() + r_dec = context.d.to_sci_string(self.dec) + verify((r_mpd, r_dec), 'to_sci_string', (self,)) + return r_mpd + + +def log(fmt, args=None): + if args: + sys.stdout.write(''.join((fmt, '\n')) % args) + else: + sys.stdout.write(''.join((str(fmt), '\n'))) + sys.stdout.flush() + +def test_method(method, testspecs, testfunc): + log("testing %s ...", method) + for spec in testspecs: + if 'samples' in spec: + spec['prec'] = sorted(random.sample(range(1, 101), spec['samples'])) + for prec in spec['prec']: + context.prec = prec + for expts in spec['expts']: + emin, emax = expts + if emin == 'rand': + context.Emin = random.randrange(-1000, 0) + context.Emax = random.randrange(prec, 1000) + else: + context.Emin, context.Emax = emin, emax + if prec > context.Emax: continue + log(" prec: %d emin: %d emax: %d", + (context.prec, context.Emin, context.Emax)) + restr_range = 9999 if context.Emax > 9999 else context.Emax+99 + for rounding in sorted(decround): + context.rounding = rounding + context.capitals = random.randrange(2) + if spec['clamp'] == 2: + context.clamp = random.randrange(2) + else: + context.clamp = spec['clamp'] + exprange = context.f.Emax + testfunc(method, prec, exprange, restr_range, spec['iter']) + +def test_unary(method, prec, exprange, restr_range, iter): + if method in ['__int__', '__long__', '__trunc__', 'to_integral', + 'to_integral_value', 'to_integral_value']: + exprange = restr_range + for a in un_close_to_pow10(prec, exprange, iter): + try: + x = cdec(a) + getattr(x, method)() + except CdecException as err: + log(err) + for a in un_close_numbers(prec, exprange, -exprange, iter): + try: + x = cdec(a) + getattr(x, method)() + except CdecException as err: + log(err) + for a in un_incr_digits_tuple(prec, exprange, iter): + try: + x = cdec(a) + getattr(x, method)() + except CdecException as err: + log(err) + for a in un_randfloat(): + try: + x = cdec(a) + getattr(x, method)() + except CdecException as err: + log(err) + for i in range(1000): + try: + s = randdec(prec, exprange) + x = cdec(s) + getattr(x, method)() + except CdecException as err: + log(err) + except OverflowError: + pass + try: + s = randtuple(prec, exprange) + x = cdec(s) + getattr(x, method)() + except CdecException as err: + log(err) + except OverflowError: + pass + +def test_un_logical(method, prec, exprange, restr_range, iter): + for a in logical_un_incr_digits(prec, iter): + try: + x = cdec(a) + getattr(x, method)() + except CdecException as err: + log(err) + for i in range(1000): + try: + s = randdec(prec, restr_range) + x = cdec(s) + getattr(x, method)() + except CdecException as err: + log(err) + except OverflowError: + pass + +def test_binary(method, prec, exprange, restr_range, iter): + if method in ['__pow__', '__rpow__', 'power']: + exprange = restr_range + for a, b in bin_close_to_pow10(prec, exprange, iter): + try: + x = cdec(a) + y = cdec(b) + getattr(x, method)(y) + except CdecException as err: + log(err) + for a, b in bin_close_numbers(prec, exprange, -exprange, iter): + try: + x = cdec(a) + y = cdec(b) + getattr(x, method)(y) + except CdecException as err: + log(err) + for a, b in bin_incr_digits(prec, exprange, iter): + try: + x = cdec(a) + y = cdec(b) + getattr(x, method)(y) + except CdecException as err: + log(err) + for a, b in bin_randfloat(): + try: + x = cdec(a) + y = cdec(b) + getattr(x, method)(y) + except CdecException as err: + log(err) + for i in range(1000): + s1 = randdec(prec, exprange) + s2 = randdec(prec, exprange) + try: + x = cdec(s1) + y = cdec(s2) + getattr(x, method)(y) + except CdecException as err: + log(err) + +def test_bin_logical(method, prec, exprange, restr_range, iter): + for a, b in logical_bin_incr_digits(prec, iter): + try: + x = cdec(a) + y = cdec(b) + getattr(x, method)(y) + except CdecException as err: + log(err) + for i in range(1000): + s1 = randdec(prec, restr_range) + s2 = randdec(prec, restr_range) + try: + x = cdec(s1) + y = cdec(s2) + getattr(x, method)(y) + except CdecException as err: + log(err) + +def test_ternary(method, prec, exprange, restr_range, iter): + if method in ['__pow__', 'power']: + exprange = restr_range + for a, b, c in tern_close_numbers(prec, exprange, -exprange, iter): + try: + x = cdec(a) + y = cdec(b) + z = cdec(c) + getattr(x, method)(y, z) + except CdecException as err: + log(err) + for a, b, c in tern_incr_digits(prec, exprange, iter): + try: + x = cdec(a) + y = cdec(b) + z = cdec(c) + getattr(x, method)(y, z) + except CdecException as err: + log(err) + for a, b, c in tern_randfloat(): + try: + x = cdec(a) + y = cdec(b) + z = cdec(c) + getattr(x, method)(y, z) + except CdecException as err: + log(err) + for i in range(1000): + s1 = randdec(prec, 2*exprange) + s2 = randdec(prec, 2*exprange) + s3 = randdec(prec, 2*exprange) + try: + x = cdec(s1) + y = cdec(s2) + z = cdec(s3) + getattr(x, method)(y, z) + except CdecException as err: + log(err) + +def test_format(method, prec, exprange, restr_range, iter): + for a in un_incr_digits_tuple(prec, restr_range, iter): + context.clear_status() + try: + fmt = rand_format(chr(random.randrange(32, 128))) + x = format(context.f.create_decimal(a), fmt) + y = format(context.d.create_decimal(a), fmt) + except Exception as err: + print(err, fmt) + continue + if x != y: + print(context.f) + print(context.d) + print("\n%s %s" % (a, fmt)) + print("%s %s\n" % (x, y)) + for i in range(1000): + context.clear_status() + try: + a = randdec(99, 9999) + fmt = rand_format(chr(random.randrange(32, 128))) + x = format(context.f.create_decimal(a), fmt) + y = format(context.d.create_decimal(a), fmt) + except Exception as err: + print(err, fmt) + continue + if x != y: + print(context.f) + print(context.d) + print("\n%s %s" % (a, fmt)) + print("%s %s\n" % (x, y)) + +def test_locale(method, prec, exprange, restr_range, iter): + for a in un_incr_digits_tuple(prec, restr_range, iter): + context.clear_status() + try: + fmt = rand_locale() + x = format(context.f.create_decimal(a), fmt) + y = format(context.d.create_decimal(a), fmt) + except Exception as err: + print(err, fmt) + continue + if x != y: + print(context.f) + print(context.d) + print(locale.setlocale(locale.LC_NUMERIC)) + print("%s %s" % (a, fmt)) + print(list(array.array('u', x))) + print(list(array.array('u', y))) + for i in range(1000): + context.clear_status() + try: + a = randdec(99, 9999) + fmt = rand_locale() + x = format(context.f.create_decimal(a), fmt) + y = format(context.d.create_decimal(a), fmt) + except Exception as err: + print(err, fmt) + continue + if x != y: + print(context.f) + print(context.d) + print(locale.setlocale(locale.LC_NUMERIC)) + print("%s %s" % (a, fmt)) + print(list(array.array('u', x))) + print(list(array.array('u', y))) + +def test_round(method, prec, exprange, restr_range, iter): + for a in un_incr_digits_tuple(prec, restr_range, 1): + context.clear_status() + try: + n = random.randrange(10) + x = (context.f.create_decimal(a)).__round__(n) + y = (context.d.create_decimal(a)).__round__(n) + except Exception as err: + print(err) + continue + if str(x) != str(y): + print(context.f) + print(context.d) + print("\n%s %s" % (a, n)) + print("%s %s\n" % (x, y)) + exit(1) + for i in range(1000): + context.clear_status() + try: + a = randdec(99, 9999) + n = random.randrange(10) + x = context.f.create_decimal(a).__round__(n) + y = context.d.create_decimal(a).__round__(n) + except Exception as err: + print(err) + continue + if str(x) != str(y): + print(context.f) + print(context.d) + print("\n%s %s" % (a, n)) + print("%s %s\n" % (x, y)) + +def test_from_float(method, prec, exprange, restr_range, iter): + for rounding in sorted(decround): + context.rounding = rounding + exprange = 384 + for i in range(1000): + intpart = str(random.randrange(100000000000000000000000000000000000000)) + fracpart = str(random.randrange(100000000000000000000000000000000000000)) + exp = str(random.randrange(-384, 384)) + fstring = intpart + '.' + fracpart + 'e' + exp + f = float(fstring) + try: + c = cdec(f) + except CdecException as err: + log(err) + +def assert_eq_status(c, d): + """assert equality of cdecimal and decimal status""" + for signal in c.flags: + if signal == cdecimal.FloatOperation: + continue + if c.flags[signal] == (not d.flags[deccond[signal]]): + return False + return True + +def test_quantize_api(method, prec, exprange, restr_range, iter): + for a in un_incr_digits(prec, restr_range, 1): + emax = random.randrange(exprange) + emin = random.randrange(-exprange, 0) + clamp = random.randrange(2) + exp = randdec(2*prec, exprange) + for rounding in sorted(decround): + try: + c = cdecimal.Context(prec=prec, Emax=emax, Emin=emin, clamp=clamp, traps=[]) + d = decimal.Context(prec=prec, Emax=emax, Emin=emin, traps=[]) + attr = 'clamp' if py_minor >= 2 else "_clamp" + setattr(d, attr, clamp) + + x = cdecimal.Decimal(a) + y = cdecimal.Decimal(exp) + cresult = x.quantize(y, rounding, c) + + u = decimal.Decimal(a) + v = decimal.Decimal(exp) + dresult = u.quantize(v, decround[rounding], d) + except Exception as err: + print(err) + continue + if str(cresult) != str(dresult) or \ + not assert_eq_status(c, d): + print("%s\n%s\n" % (c, d)) + print("x: %s\ny: %s\nu: %s\nv: %s\n" % (x, y, u, v)) + print("a: %s exp: %s\n" % (a, exp)) + print("cresult: %s\ndresult: %s\n" % (cresult, dresult)) + for i in range(1000): + a = randdec(prec, 9999) + prec = random.randrange(1, 50) + emax = random.randrange(exprange) + emin = random.randrange(-exprange, 0) + clamp = random.randrange(2) + exp = randdec(2*prec, exprange) + for rounding in sorted(decround): + try: + c = cdecimal.Context(prec=prec, Emax=emax, Emin=emin, clamp=clamp, traps=[]) + d = decimal.Context(prec=prec, Emax=emax, Emin=emin, traps=[]) + attr = 'clamp' if py_minor >= 2 else "_clamp" + setattr(d, attr, clamp) + + x = cdecimal.Decimal(a) + y = cdecimal.Decimal(exp) + cresult = x.quantize(context=c, exp=y, rounding=rounding) + + u = decimal.Decimal(a) + v = decimal.Decimal(exp) + dresult = u.quantize(context=d, exp=v, rounding=decround[rounding]) + except Exception as err: + print(err) + continue + if str(cresult) != str(dresult) or \ + not assert_eq_status(c, d): + print("%s\n%s\n" % (c, d)) + print("x: %s\ny: %s\nu: %s\nv: %s\n" % (x, y, u, v)) + print("a: %s exp: %s\n" % (a, exp)) + print("cresult: %s\ndresult: %s\n" % (cresult, dresult)) + + +if __name__ == '__main__': + + import time + + randseed = int(time.time()) + random.seed(randseed) + + base_expts = [(cdecimal.MIN_EMIN, cdecimal.MAX_EMAX)] + if cdecimal.MAX_EMAX == 999999999999999999: + base_expts.append((-999999999, 999999999)) + + base = { + 'name': 'base', + 'expts': base_expts, + 'prec': [], + 'clamp': 2, + 'iter': None, + 'samples': None, + } + small = { + 'name': 'small', + 'prec': [1, 2, 3, 4, 5], + 'expts': [(-1,1), (-2,2), (-3,3), (-4,4), (-5,5)], + 'clamp': 2, + 'iter': None + } + ieee = [ + {'name': 'decimal32', 'prec': [7], 'expts': [(-95, 96)], 'clamp': 1, 'iter': None}, + {'name': 'decimal64', 'prec': [16], 'expts': [(-383, 384)], 'clamp': 1, 'iter': None}, + {'name': 'decimal128', 'prec': [34], 'expts': [(-6143, 6144)], 'clamp': 1, 'iter': None} + ] + + if '--medium' in sys.argv: + base['expts'].append(('rand', 'rand')) + base['samples'] = None + testspecs = [small] + ieee + [base] + if '--long' in sys.argv: + base['expts'].append(('rand', 'rand')) + base['samples'] = 5 + testspecs = [small] + ieee + [base] + elif '--all' in sys.argv: + base['expts'].append(('rand', 'rand')) + base['samples'] = 100 + testspecs = [small] + ieee + [base] + else: # --short + rand_ieee = random.choice(ieee) + base['iter'] = small['iter'] = rand_ieee['iter'] = 1 + base['samples'] = 1 + base['expts'] = [random.choice(base_expts)] + prec = random.randrange(1, 6) + small['prec'] = [prec] + small['expts'] = [(-prec, prec)] + testspecs = [small, rand_ieee, base] + + + all_decimal_methods = set(dir(cdecimal.Decimal) + dir(decimal.Decimal)) + all_cdec_methods = [m for m in dir(cdec) if m in all_decimal_methods] + untested_methods = [m for m in all_decimal_methods if not (m in all_cdec_methods)] + + unary_methods = [] + binary_methods = [] + ternary_methods = [] + for m in all_cdec_methods: + try: + l = len(inspect.getargspec(getattr(cdec, m))[0]) + except TypeError: + continue + if l == 1: + unary_methods.append(m) + elif l == 2: + binary_methods.append(m) + elif l == 3: + ternary_methods.append(m) + else: + raise ValueError((m, l)) + + unary_methods.append('__deepcopy__') + binary_methods.remove('__deepcopy__') + binary_methods.remove('__new__') + binary_methods.append('power') + untested_methods.remove('from_float') + if py_minor < 6: + unary_methods.remove('__trunc__') + for elem in ['__ge__', '__gt__', '__le__', '__lt__']: + binary_methods.remove(elem) + + untested_methods.sort() + unary_methods.sort() + binary_methods.sort() + ternary_methods.sort() + + + log("\nRandom seed: %d\n\n", randseed) + log("Skipping tests: \n\n%s\n", untested_methods) + + + for method in unary_methods: + test_method(method, testspecs, test_unary) + + for method in binary_methods: + test_method(method, testspecs, test_binary) + + for method in ternary_methods: + test_method(method, testspecs, test_ternary) + + test_method('logical_invert', testspecs, test_un_logical) + + for method in ['logical_and', 'logical_or', 'logical_xor']: + test_method(method, testspecs, test_bin_logical) + + test_method('quantize_api', testspecs, test_quantize_api) + + + if py_minor >= 2: + # Some tests will fail with 3.1, since alignment has been changed + # in decimal.py 3.2. + from genlocale import * + test_method('format', testspecs, test_format) + test_method('locale', testspecs, test_locale) + test_method('round', testspecs, test_round) + test_method('from_float', testspecs, test_from_float) + + + sys.exit(EXIT_STATUS) diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/python/formathelper.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/python/formathelper.py Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,231 @@ +# +# Copyright (c) 2008-2010 Stefan Krah. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + + +import os, sys, locale, random +import platform, subprocess +from randdec import * +from decimal import * + + +windows_lang_strings = [ + "chinese", "chinese-simplified", "chinese-traditional", "czech", "danish", + "dutch", "belgian", "english", "australian", "canadian", "english-nz", + "english-uk", "english-us", "finnish", "french", "french-belgian", + "french-canadian", "french-swiss", "german", "german-austrian", + "german-swiss", "greek", "hungarian", "icelandic", "italian", "italian-swiss", + "japanese", "korean", "norwegian", "norwegian-bokmal", "norwegian-nynorsk", + "polish", "portuguese", "portuguese-brazil", "russian", "slovak", "spanish", + "spanish-mexican", "spanish-modern", "swedish", "turkish", +] + +preferred_encoding = { + 'cs_CZ': 'ISO8859-2', + 'cs_CZ.iso88592': 'ISO8859-2', + 'czech': 'ISO8859-2', + 'eesti': 'ISO8859-1', + 'estonian': 'ISO8859-1', + 'et_EE': 'ISO8859-15', + 'et_EE.ISO-8859-15': 'ISO8859-15', + 'et_EE.iso885915': 'ISO8859-15', + 'et_EE.iso88591': 'ISO8859-1', + 'fi_FI.iso88591': 'ISO8859-1', + 'fi_FI': 'ISO8859-15', + 'fi_FI@euro': 'ISO8859-15', + 'fi_FI.iso885915@euro': 'ISO8859-15', + 'finnish': 'ISO8859-1', + 'lv_LV': 'ISO8859-13', + 'lv_LV.iso885913': 'ISO8859-13', + 'nb_NO': 'ISO8859-1', + 'nb_NO.iso88591': 'ISO8859-1', + 'bokmal': 'ISO8859-1', + 'nn_NO': 'ISO8859-1', + 'nn_NO.iso88591': 'ISO8859-1', + 'no_NO': 'ISO8859-1', + 'norwegian': 'ISO8859-1', + 'nynorsk': 'ISO8859-1', + 'ru_RU': 'ISO8859-5', + 'ru_RU.iso88595': 'ISO8859-5', + 'russian': 'ISO8859-5', + 'ru_RU.KOI8-R': 'KOI8-R', + 'ru_RU.koi8r': 'KOI8-R', + 'ru_RU.CP1251': 'CP1251', + 'ru_RU.cp1251': 'CP1251', + 'sk_SK': 'ISO8859-2', + 'sk_SK.iso88592': 'ISO8859-2', + 'slovak': 'ISO8859-2', + 'sv_FI': 'ISO8859-1', + 'sv_FI.iso88591': 'ISO8859-1', + 'sv_FI@euro': 'ISO8859-15', + 'sv_FI.iso885915@euro': 'ISO8859-15', + 'uk_UA': 'KOI8-U', + 'uk_UA.koi8u': 'KOI8-U' +} + +integers = [ + "", + "1", + "12", + "123", + "1234", + "12345", + "123456", + "1234567", + "12345678", + "123456789", + "1234567890", + "12345678901", + "123456789012", + "1234567890123", + "12345678901234", + "123456789012345", + "1234567890123456", + "12345678901234567", + "123456789012345678", + "1234567890123456789", + "12345678901234567890", + "123456789012345678901", + "1234567890123456789012", +] + +numbers = [ + "0", "-0", "+0", + "0.0", "-0.0", "+0.0", + "0e0", "-0e0", "+0e0", + ".0", "-.0", + ".1", "-.1", + "1.1", "-1.1", + "1e1", "-1e1" +] + +py_major = sys.version_info[0] + +if platform.system() == 'Windows': + locale_list = windows_lang_strings +else: + try: + # On Ubuntu, `locale -a` gives the wrong case for some locales, + # so we get the correct names directly: + f = open("/var/lib/locales/supported.d/local") + locale_list = [loc.split()[0] for loc in f.readlines()] + except: + locale_list = subprocess.Popen(["locale", "-a"], + stdout=subprocess.PIPE).communicate()[0] + if py_major == 3: + locale_list = locale_list.decode() + locale_list = locale_list.split('\n') + + +if py_major < 3: + # issue7327 (min_width and multibyte separators): wont_fix + save_loc = locale.setlocale(locale.LC_NUMERIC) + for loc in locale_list[:]: + try: + locale.setlocale(locale.LC_NUMERIC, loc) + except locale.Error: + locale_list.remove(loc) + continue + d = locale.localeconv() + if len(d['thousands_sep']) > 1 or len(d['decimal_point']) > 1: + locale_list.remove(loc) + locale.setlocale(locale.LC_NUMERIC, save_loc) + +try: + locale_list.remove('') +except ValueError: + pass + +# Debian +if os.path.isfile("/etc/locale.alias"): + with open("/etc/locale.alias") as f: + while 1: + try: + line = f.readline() + except UnicodeDecodeError: + continue + if line == "": + break + if line.startswith('#'): + continue + x = line.split() + if len(x) == 2: + if x[0] in locale_list: + locale_list.remove(x[0]) + +if platform.system() == 'FreeBSD': + # http://www.freebsd.org/cgi/query-pr.cgi?pr=142173 + # en_GB.US-ASCII has 163 as the currency symbol. + for loc in ['it_CH.ISO8859-1', 'it_CH.ISO8859-15', 'it_CH.UTF-8', 'it_IT.ISO8859-1', + 'it_IT.ISO8859-15', 'it_IT.UTF-8', 'sl_SI.ISO8859-2', 'sl_SI.UTF-8', + 'en_GB.US-ASCII']: + try: + locale_list.remove(loc) + except ValueError: + pass + + +def get_preferred_encoding(): + loc = locale.setlocale(locale.LC_CTYPE) + if loc in preferred_encoding: + return preferred_encoding[loc] + else: + return locale.getpreferredencoding() + +if py_major < 3: + def printit(testno, s, fmt, encoding=None): + if not encoding: + encoding = get_preferred_encoding() + try: + result = format(Decimal(s), fmt) + if isinstance(fmt, unicode): + fmt = repr(fmt.encode(encoding))[1:-1] + if isinstance(result, unicode): + result = repr(result.encode(encoding))[1:-1] + if "'" in result: + sys.stdout.write("xfmt%d format %s '%s' -> \"%s\"\n" + % (testno, s, fmt, result)) + else: + sys.stdout.write("xfmt%d format %s '%s' -> '%s'\n" + % (testno, s, fmt, result)) + except Exception as err: + sys.stderr.write("%s %s %s\n" % (err, s, fmt)) +else: + def printit(testno, s, fmt, encoding=None): + if not encoding: + encoding = get_preferred_encoding() + try: + result = format(Decimal(s), fmt) + fmt = str(fmt.encode(encoding))[2:-1] + result = str(result.encode(encoding))[2:-1] + if "'" in result: + sys.stdout.write("xfmt%d format %s '%s' -> \"%s\"\n" + % (testno, s, fmt, result)) + else: + sys.stdout.write("xfmt%d format %s '%s' -> '%s'\n" + % (testno, s, fmt, result)) + except Exception as err: + sys.stderr.write("%s %s %s\n" % (err, s, fmt)) diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/python/genlocale.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/python/genlocale.py Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,194 @@ +# +# Copyright (c) 2008-2010 Stefan Krah. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + + +# +# Very extensive test that comes close to brute force testing +# all format string combinations containing either a thousands +# separator or the 'n' specifier. +# +# Usage: python3.2 genlocale.py | ../runtest - +# + + +from formathelper import * + + +# Generate random format strings, no 'n' specifier +# [[fill]align][sign][#][0][width][.precision][type] +def _gen_format_sep(): + for align in ('', '<', '>', '=', '^'): + for fill in ('', 'x'): + if align == '': fill = '' + for sign in ('', '+', '-', ' '): + for zeropad in ('', '0'): + if align != '': zeropad = '' + for width in ['']+[str(y) for y in range(1, 15)]+['101']: + for prec in ['']+['.'+str(y) for y in range(15)]: + # for type in ('', 'E', 'e', 'G', 'g', 'F', 'f', '%'): + type = random.choice(('', 'E', 'e', 'G', 'g', 'F', 'f', '%')) + yield ''.join((fill, align, sign, zeropad, width, ',', prec, type)) + + +# Generate random format strings with 'n' specifier +# [[fill]align][sign][#][0][width][.precision][type] +def _gen_format_locale(): + for align in ('', '<', '>', '=', '^'): + for fill in ('', 'x'): + if align == '': fill = '' + for sign in ('', '+', '-', ' '): + for zeropad in ('', '0'): + if align != '': zeropad = '' + for width in ['']+[str(y) for y in range(1, 20)]+['101']: + for prec in ['']+['.'+str(y) for y in range(1, 20)]: + yield ''.join((fill, align, sign, zeropad, width, prec, 'n')) + + +# Generate random format strings with a unicode fill character +# [[fill]align][sign][#][0][width][.precision][type] +def randf(fill): + active = sorted(random.sample(range(5), random.randrange(6))) + s = '' + s += str(fill) + s += random.choice('<>=^') + have_align = 1 + for elem in active: + if elem == 0: # sign + s += random.choice('+- ') + elif elem == 1: # width + s += str(random.randrange(1, 100)) + elif elem == 2: # thousands separator + s += ',' + elif elem == 3: # prec + s += '.' + # decimal.py does not support prec=0 + s += str(random.randrange(1, 100)) + elif elem == 4: + if 2 in active: c = 'EeGgFf%' + else: c = 'EeGgFfn%' + s += random.choice(c) + return s + +# Generate random format strings with random locale setting +# [[fill]align][sign][#][0][width][.precision][type] +def rand_locale(): + try: + loc = random.choice(locale_list) + locale.setlocale(locale.LC_ALL, loc) + except locale.Error as err: + pass + active = sorted(random.sample(range(5), random.randrange(6))) + s = '' + have_align = 0 + for elem in active: + if elem == 0: # fill+align + s += chr(random.randrange(32, 128)) + s += random.choice('<>=^') + have_align = 1 + elif elem == 1: # sign + s += random.choice('+- ') + elif elem == 2 and not have_align: # zeropad + s += '0' + elif elem == 3: # width + s += str(random.randrange(1, 100)) + elif elem == 4: # prec + s += '.' + # decimal.py does not support prec=0 + s += str(random.randrange(1, 100)) + s += 'n' + return s + + +if __name__ == '__main__': + + testno = 0 + print("rounding: half_even") + + if not unicode_chars: + unicode_chars = gen_unicode_chars() + + # unicode fill character test + for x in range(10): + for fill in unicode_chars: + intpart = fracpart = '' + while (not intpart) and (not fracpart): + intpart = random.choice(integers) + fracpart = random.choice(integers) + s = ''.join((random.choice(('', '-')), intpart, '.', fracpart)) + fmt = randf(fill) + testno += 1 + printit(testno, s, fmt, 'utf-8') + + # thousands separator test + for fmt in _gen_format_sep(): + for s in un_incr_digits(15, 384, 30): + testno += 1 + for sign in ('', '-'): + for intpart in integers: + for fracpart in integers: + if (not intpart) and (not fracpart): + continue + s = ''.join((sign, intpart, '.', fracpart)) + testno += 1 + printit(testno, s, fmt) + for s in numbers: + testno += 1 + printit(testno, s, fmt) + for x in range(100): + s = randdec(20, 425) + testno += 1 + printit(testno, s, fmt) + for x in range(100): + s = randint(20) + testno += 1 + printit(testno, s, fmt) + + # locale test + for loc in locale_list: + try: + locale.setlocale(locale.LC_ALL, loc) + except locale.Error as err: + sys.stderr.write("%s: %s\n" % (loc, err)) + continue + print("locale: %s" % loc) + for fmt in _gen_format_locale(): + for sign in ('', '-'): + intpart = fracpart = '' + while (not intpart) and (not fracpart): + intpart = random.choice(integers) + fracpart = random.choice(integers) + s = ''.join((sign, intpart, '.', fracpart)) + testno += 1 + printit(testno, s, fmt) + for s in random.sample(numbers, 3): + testno += 1 + printit(testno, s, fmt) + getcontext().prec = 300 + for x in range(10): + s = randdec(20, 425000000) + testno += 1 + printit(testno, s, fmt) diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/python/genrandformat.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/python/genrandformat.py Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,55 @@ +# +# Copyright (c) 2008-2010 Stefan Krah. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + + +# +# Test formatting using random format strings. This must be run +# in a UFT-8 terminal. +# +# Usage: python3.2 genrandformat.py | ../runtest - +# + + +from formathelper import * +print("rounding: half_even") + + +testno = 0 +for x in range(1000): + for sign in ('', '-'): + intpart = fracpart = '' + while (not intpart) and (not fracpart): + intpart = random.choice(integers) + fracpart = random.choice(integers) + s = ''.join((sign, intpart, '.', fracpart)) + fmt = rand_format(rand_unicode()) + testno += 1 + printit(testno, s, fmt, 'utf-8') + for s in un_incr_digits(15, 384, 30): + fmt = rand_format(rand_unicode()) + testno += 1 + printit(testno, s, fmt, 'utf-8') diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/python/genrandlocale.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/python/genrandlocale.py Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,61 @@ +# +# Copyright (c) 2008-2010 Stefan Krah. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + + +# +# For each possible locale setting, test formatting using random +# format strings. +# +# Usage: python3.2 genrandlocale.py | ../runtest - +# + + +from formathelper import * +print("rounding: half_even") + + +testno = 0 +for loc in locale_list: + try: + locale.setlocale(locale.LC_ALL, loc) + except locale.Error as err: + sys.stderr.write("%s: %s\n" % (loc, err)) + continue + print("locale: %s" % loc) + for sign in ('', '-'): + intpart = fracpart = '' + while (not intpart) and (not fracpart): + intpart = random.choice(integers) + fracpart = random.choice(integers) + s = ''.join((sign, intpart, '.', fracpart)) + fmt = rand_format('x') + testno += 1 + printit(testno, s, fmt) + for s in un_incr_digits(15, 384, 30): + fmt = rand_format('x') + testno += 1 + printit(testno, s, fmt) diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/python/gettests.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/python/gettests.bat Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,3 @@ +@ECHO OFF + +if not exist decimaltestdata mkdir decimaltestdata && copy /y ..\..\decimaltestdata\* decimaltestdata diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/python/gettests.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/python/gettests.sh Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,5 @@ +#!/bin/sh + +if ! [ -d decimaltestdata ]; then + cp -a ../../decimaltestdata . +fi diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/python/randdec.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/python/randdec.py Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,506 @@ +#!/usr/bin/env python + +# +# Copyright (c) 2008-2010 Stefan Krah. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + + +# +# Grammar from http://speleotrove.com/decimal/daconvs.html +# +# 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 +# + + +import random, sys + + +def sign(): + if random.randrange(2): + if random.randrange(2): return '+' + return '' + return '-' + +def indicator(): + return "eE"[random.randrange(2)] + +def digits(maxprec): + if maxprec == 0: return '' + return str(random.randrange(10**maxprec)) + +def dot(): + if random.randrange(2): return '.' + return '' + +def decimal_part(maxprec): + if random.randrange(100) > 60: # integers + return digits(maxprec) + if random.randrange(2): + intlen = random.randrange(1, maxprec+1) + fraclen = maxprec-intlen + intpart = digits(intlen) + fracpart = digits(fraclen) + return ''.join((intpart, '.', fracpart)) + else: + return ''.join((dot(), digits(maxprec))) + +def expdigits(maxexp): + return str(random.randrange(maxexp)) + +def exponent_part(maxexp): + return ''.join((indicator(), sign(), expdigits(maxexp))) + +def infinity(): + if random.randrange(2): return 'Infinity' + return 'Inf' + +def nan(): + d = '' + if random.randrange(2): + d = digits(random.randrange(99)); + if random.randrange(2): + return ''.join(('NaN', d)) + else: + return ''.join(('sNaN', d)) + +def numeric_value(maxprec, maxexp): + if random.randrange(100) > 90: + return infinity() + exp_part = '' + if random.randrange(100) > 60: + exp_part = exponent_part(maxexp) + return ''.join((decimal_part(maxprec), exp_part)) + +def numeric_string(maxprec, maxexp): + if random.randrange(100) > 95: + return ''.join((sign(), nan())) + else: + return ''.join((sign(), numeric_value(maxprec, maxexp))) + +def randdec(maxprec, maxexp): + return numeric_string(maxprec, maxexp) + +def randint(maxprec): + return digits(maxprec) + +def rand_adjexp(maxprec, maxadjexp): + d = digits(maxprec) + maxexp = maxadjexp-len(d)+1 + if maxexp == 0: maxexp = 1 + exp = str(random.randrange(maxexp-2*(abs(maxexp)), maxexp)) + return ''.join((sign(), d, 'E', exp)) + + +def ndigits(n): + if n < 1: return 0 + return random.randrange(10**(n-1), 10**n) + +def randtuple(maxprec, maxexp): + n = random.randrange(100) + sign = (0,1)[random.randrange(1)] + coeff = ndigits(maxprec) + if n >= 95: + coeff = () + exp = 'F' + elif n >= 85: + coeff = tuple(map(int, str(ndigits(maxprec)))) + exp = "nN"[random.randrange(1)] + else: + coeff = tuple(map(int, str(ndigits(maxprec)))) + exp = random.randrange(-maxexp, maxexp) + return (sign, coeff, exp) + + +def from_triple(sign, coeff, exp): + return ''.join((str(sign*coeff), indicator(), str(exp))) + + +# Close to 10**n +def un_close_to_pow10(prec, maxexp, itertns=None): + if itertns is None: + lst = range(prec+30) + else: + lst = random.sample(range(prec+30), itertns) + nines = [10**n - 1 for n in lst] + pow10 = [10**n for n in lst] + for coeff in nines: + yield coeff + yield -coeff + yield from_triple(1, coeff, random.randrange(2*maxexp)) + yield from_triple(-1, coeff, random.randrange(2*maxexp)) + for coeff in pow10: + yield coeff + yield -coeff + +# Close to 10**n +def bin_close_to_pow10(prec, maxexp, itertns=None): + if itertns is None: + lst = range(prec+30) + else: + lst = random.sample(range(prec+30), itertns) + nines = [10**n - 1 for n in lst] + pow10 = [10**n for n in lst] + for coeff in nines: + yield coeff, 1 + yield -coeff, -1 + yield 1, coeff + yield -1, -coeff + yield from_triple(1, coeff, random.randrange(2*maxexp)), 1 + yield from_triple(-1, coeff, random.randrange(2*maxexp)), -1 + yield 1, from_triple(1, coeff, -random.randrange(2*maxexp)) + yield -1, from_triple(-1, coeff, -random.randrange(2*maxexp)) + for coeff in pow10: + yield coeff, -1 + yield -coeff, 1 + yield 1, -coeff + yield -coeff, 1 + +# Close to 1: +def close_to_one_greater(prec, emax, emin): + rprec = 10**prec + return ''.join(("1.", '0'*random.randrange(prec), + str(random.randrange(rprec)))) + +def close_to_one_less(prec, emax, emin): + rprec = 10**prec + return ''.join(("0.9", '9'*random.randrange(prec), + str(random.randrange(rprec)))) + +# Close to 0: +def close_to_zero_greater(prec, emax, emin): + rprec = 10**prec + return ''.join(("0.", '0'*random.randrange(prec), + str(random.randrange(rprec)))) + +def close_to_zero_less(prec, emax, emin): + rprec = 10**prec + return ''.join(("-0.", '0'*random.randrange(prec), + str(random.randrange(rprec)))) + +# Close to emax: +def close_to_emax_less(prec, emax, emin): + rprec = 10**prec + return ''.join(("9.", '9'*random.randrange(prec), + str(random.randrange(rprec)), "E", str(emax))) + +def close_to_emax_greater(prec, emax, emin): + rprec = 10**prec + return ''.join(("1.", '0'*random.randrange(prec), + str(random.randrange(rprec)), "E", str(emax+1))) + +# Close to emin: +def close_to_emin_greater(prec, emax, emin): + rprec = 10**prec + return ''.join(("1.", '0'*random.randrange(prec), + str(random.randrange(rprec)), "E", str(emin))) + +def close_to_emin_less(prec, emax, emin): + rprec = 10**prec + return ''.join(("9.", '9'*random.randrange(prec), + str(random.randrange(rprec)), "E", str(emin-1))) + +# Close to etiny: +def close_to_etiny_greater(prec, emax, emin): + rprec = 10**prec + etiny = emin - (prec - 1) + return ''.join(("1.", '0'*random.randrange(prec), + str(random.randrange(rprec)), "E", str(etiny))) + +def close_to_etiny_less(prec, emax, emin): + rprec = 10**prec + etiny = emin - (prec - 1) + return ''.join(("9.", '9'*random.randrange(prec), + str(random.randrange(rprec)), "E", str(etiny-1))) + + +def close_to_min_etiny_greater(prec, max_prec, min_emin): + rprec = 10**prec + etiny = min_emin - (max_prec - 1) + return ''.join(("1.", '0'*random.randrange(prec), + str(random.randrange(rprec)), "E", str(etiny))) + +def close_to_min_etiny_less(prec, max_prec, min_emin): + rprec = 10**prec + etiny = min_emin - (max_prec - 1) + return ''.join(("9.", '9'*random.randrange(prec), + str(random.randrange(rprec)), "E", str(etiny-1))) + + +close_funcs = [ + close_to_one_greater, close_to_one_less, close_to_zero_greater, + close_to_zero_less, close_to_emax_less, close_to_emax_greater, + close_to_emin_greater, close_to_emin_less, close_to_etiny_greater, + close_to_etiny_less, close_to_min_etiny_greater, close_to_min_etiny_less +] + + +def un_close_numbers(prec, emax, emin, itertns=None): + if itertns is None: + itertns = 1000 + for i in range(itertns): + for func in close_funcs: + yield func(prec, emax, emin) + +def bin_close_numbers(prec, emax, emin, itertns=None): + if itertns is None: + itertns = 1000 + for i in range(itertns): + for func1 in close_funcs: + for func2 in close_funcs: + yield func1(prec, emax, emin), func2(prec, emax, emin) + for func in close_funcs: + yield randdec(prec, emax), func(prec, emax, emin) + yield func(prec, emax, emin), randdec(prec, emax) + +def tern_close_numbers(prec, emax, emin, itertns): + if itertns is None: + itertns = 1000 + for i in range(itertns): + for func1 in close_funcs: + for func2 in close_funcs: + for func3 in close_funcs: + yield (func1(prec, emax, emin), func2(prec, emax, emin), + func3(prec, emax, emin)) + for func in close_funcs: + yield (randdec(prec, emax), func(prec, emax, emin), + func(prec, emax, emin)) + yield (func(prec, emax, emin), randdec(prec, emax), + func(prec, emax, emin)) + yield (func(prec, emax, emin), func(prec, emax, emin), + randdec(prec, emax)) + for func in close_funcs: + yield (randdec(prec, emax), randdec(prec, emax), + func(prec, emax, emin)) + yield (randdec(prec, emax), func(prec, emax, emin), + randdec(prec, emax)) + yield (func(prec, emax, emin), randdec(prec, emax), + randdec(prec, emax)) + + +# If itertns == None, test all digit lengths up to prec + 30 +def un_incr_digits(prec, maxexp, itertns): + if itertns is None: + lst = range(prec+30) + else: + lst = random.sample(range(prec+30), itertns) + for m in lst: + yield from_triple(1, ndigits(m), 0) + yield from_triple(-1, ndigits(m), 0) + yield from_triple(1, ndigits(m), random.randrange(maxexp)) + yield from_triple(-1, ndigits(m), random.randrange(maxexp)) + +# If itertns == None, test all digit lengths up to prec + 30 +# Also output decimals im tuple form. +def un_incr_digits_tuple(prec, maxexp, itertns): + if itertns is None: + lst = range(prec+30) + else: + lst = random.sample(range(prec+30), itertns) + for m in lst: + yield from_triple(1, ndigits(m), 0) + yield from_triple(-1, ndigits(m), 0) + yield from_triple(1, ndigits(m), random.randrange(maxexp)) + yield from_triple(-1, ndigits(m), random.randrange(maxexp)) + # test from tuple + yield (0, tuple(map(int, str(ndigits(m)))), 0) + yield (1, tuple(map(int, str(ndigits(m)))), 0) + yield (0, tuple(map(int, str(ndigits(m)))), random.randrange(maxexp)) + yield (1, tuple(map(int, str(ndigits(m)))), random.randrange(maxexp)) + +# If itertns == None, test all combinations of digit lengths up to prec + 30 +def bin_incr_digits(prec, maxexp, itertns): + if itertns is None: + lst1 = range(prec+30) + lst2 = range(prec+30) + else: + lst1 = random.sample(range(prec+30), itertns) + lst2 = random.sample(range(prec+30), itertns) + for m in lst1: + x = from_triple(1, ndigits(m), 0) + yield x, x + x = from_triple(-1, ndigits(m), 0) + yield x, x + x = from_triple(1, ndigits(m), random.randrange(maxexp)) + yield x, x + x = from_triple(-1, ndigits(m), random.randrange(maxexp)) + yield x, x + for m in lst1: + for n in lst2: + x = from_triple(1, ndigits(m), 0) + y = from_triple(1, ndigits(n), 0) + yield x, y + x = from_triple(-1, ndigits(m), 0) + y = from_triple(1, ndigits(n), 0) + yield x, y + x = from_triple(1, ndigits(m), 0) + y = from_triple(-1, ndigits(n), 0) + yield x, y + x = from_triple(-1, ndigits(m), 0) + y = from_triple(-1, ndigits(n), 0) + yield x, y + x = from_triple(1, ndigits(m), random.randrange(maxexp)) + y = from_triple(1, ndigits(n), random.randrange(maxexp)) + yield x, y + x = from_triple(-1, ndigits(m), random.randrange(maxexp)) + y = from_triple(1, ndigits(n), random.randrange(maxexp)) + yield x, y + x = from_triple(1, ndigits(m), random.randrange(maxexp)) + y = from_triple(-1, ndigits(n), random.randrange(maxexp)) + yield x, y + x = from_triple(-1, ndigits(m), random.randrange(maxexp)) + y = from_triple(-1, ndigits(n), random.randrange(maxexp)) + yield x, y + + +def randsign(): + return (1, -1)[random.randrange(2)] + +# If itertns == None, test all combinations of digit lengths up to prec + 30 +def tern_incr_digits(prec, maxexp, itertns): + if itertns is None: + lst1 = range(prec+30) + lst2 = range(prec+30) + lst3 = range(prec+30) + else: + lst1 = random.sample(range(prec+30), itertns) + lst2 = random.sample(range(prec+30), itertns) + lst3 = random.sample(range(prec+30), itertns) + for m in lst1: + for n in lst2: + for p in lst3: + x = from_triple(randsign(), ndigits(m), 0) + y = from_triple(randsign(), ndigits(n), 0) + z = from_triple(randsign(), ndigits(p), 0) + yield x, y, z + + +# Tests for the 'logical' functions +def bindigits(prec): + z = 0 + for i in range(prec): + z += random.randrange(2) * 10**i + return z + +def logical_un_incr_digits(prec, itertns): + if itertns is None: + lst = range(prec+30) + else: + lst = random.sample(range(prec+30), itertns) + for m in lst: + yield from_triple(1, bindigits(m), 0) + +def logical_bin_incr_digits(prec, itertns): + if itertns is None: + lst1 = range(prec+30) + lst2 = range(prec+30) + else: + lst1 = random.sample(range(prec+30), itertns) + lst2 = random.sample(range(prec+30), itertns) + for m in lst1: + x = from_triple(1, bindigits(m), 0) + yield x, x + for m in lst1: + for n in lst2: + x = from_triple(1, bindigits(m), 0) + y = from_triple(1, bindigits(n), 0) + yield x, y + + +py_major = sys.version_info[0] +if py_major == 2: + def touni(c): return unichr(c) +else: + def touni(c): return chr(c) + +# Generate list of all unicode characters that are accepted +# as fill characters by decimal.py. +def gen_unicode_chars(): + from decimal import Decimal + sys.stderr.write("\ngenerating unicode chars ... ") + r = [] + for c in range(32, 0x110001): + try: + x = touni(c) + try: + x.encode('utf-8').decode() + format(Decimal(0), x + '<19g') + r.append(x) + except: + pass + except ValueError: + pass + r.remove(touni(ord("'"))) + r.remove(touni(ord('"'))) + r.remove(touni(ord('\\'))) + sys.stderr.write("DONE\n\n") + return r + +unicode_chars = [] +def rand_unicode(): + global unicode_chars + if not unicode_chars: + unicode_chars = gen_unicode_chars() + return random.choice(unicode_chars) + + +# Generate random format strings +# [[fill]align][sign][#][0][width][.precision][type] +def rand_format(fill): + active = sorted(random.sample(range(7), random.randrange(8))) + have_align = 0 + s = '' + for elem in active: + if elem == 0: # fill+align + s += fill + s += random.choice('<>=^') + have_align = 1 + elif elem == 1: # sign + s += random.choice('+- ') + elif elem == 2 and not have_align: # zeropad + s += '0' + elif elem == 3: # width + s += str(random.randrange(1, 100)) + elif elem == 4: # thousands separator + s += ',' + elif elem == 5: # prec + s += '.' + # decimal.py does not support prec=0 + s += str(random.randrange(1, 100)) + elif elem == 6: + if 4 in active: c = 'EeGgFf%' + else: c = 'EeGgFfn%' + s += random.choice(c) + return s diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/python/randfloat.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/python/randfloat.py Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,263 @@ +# Copyright (c) 2010 Python Software Foundation. All Rights Reserved. +# Adapted from Python's Lib/test/test_strtod.py (by Mark Dickinson) + +# Tests for the correctly-rounded string -> float conversions +# introduced in Python 2.7 and 3.1. + +import random + +TEST_SIZE = 16 + + +def test_short_halfway_cases(): + # exact halfway cases with a small number of significant digits + for k in 0, 5, 10, 15, 20: + # upper = smallest integer >= 2**54/5**k + upper = -(-2**54//5**k) + # lower = smallest odd number >= 2**53/5**k + lower = -(-2**53//5**k) + if lower % 2 == 0: + lower += 1 + for i in range(10 * TEST_SIZE): + # Select a random odd n in [2**53/5**k, + # 2**54/5**k). Then n * 10**k gives a halfway case + # with small number of significant digits. + n, e = random.randrange(lower, upper, 2), k + + # Remove any additional powers of 5. + while n % 5 == 0: + n, e = n // 5, e + 1 + assert n % 10 in (1, 3, 7, 9) + + # Try numbers of the form n * 2**p2 * 10**e, p2 >= 0, + # until n * 2**p2 has more than 20 significant digits. + digits, exponent = n, e + while digits < 10**20: + s = '{}e{}'.format(digits, exponent) + yield s + # Same again, but with extra trailing zeros. + s = '{}e{}'.format(digits * 10**40, exponent - 40) + yield s + digits *= 2 + + # Try numbers of the form n * 5**p2 * 10**(e - p5), p5 + # >= 0, with n * 5**p5 < 10**20. + digits, exponent = n, e + while digits < 10**20: + s = '{}e{}'.format(digits, exponent) + yield s + # Same again, but with extra trailing zeros. + s = '{}e{}'.format(digits * 10**40, exponent - 40) + yield s + digits *= 5 + exponent -= 1 + +def test_halfway_cases(): + # test halfway cases for the round-half-to-even rule + for i in range(1000): + for j in range(TEST_SIZE): + # bit pattern for a random finite positive (or +0.0) float + bits = random.randrange(2047*2**52) + + # convert bit pattern to a number of the form m * 2**e + e, m = divmod(bits, 2**52) + if e: + m, e = m + 2**52, e - 1 + e -= 1074 + + # add 0.5 ulps + m, e = 2*m + 1, e - 1 + + # convert to a decimal string + if e >= 0: + digits = m << e + exponent = 0 + else: + # m * 2**e = (m * 5**-e) * 10**e + digits = m * 5**-e + exponent = e + s = '{}e{}'.format(digits, exponent) + yield s + +def test_boundaries(): + # boundaries expressed as triples (n, e, u), where + # n*10**e is an approximation to the boundary value and + # u*10**e is 1ulp + boundaries = [ + (10000000000000000000, -19, 1110), # a power of 2 boundary (1.0) + (17976931348623159077, 289, 1995), # overflow boundary (2.**1024) + (22250738585072013831, -327, 4941), # normal/subnormal (2.**-1022) + (0, -327, 4941), # zero + ] + for n, e, u in boundaries: + for j in range(1000): + for i in range(TEST_SIZE): + digits = n + random.randrange(-3*u, 3*u) + exponent = e + s = '{}e{}'.format(digits, exponent) + yield s + n *= 10 + u *= 10 + e -= 1 + +def test_underflow_boundary(): + # test values close to 2**-1075, the underflow boundary; similar + # to boundary_tests, except that the random error doesn't scale + # with n + for exponent in range(-400, -320): + base = 10**-exponent // 2**1075 + for j in range(TEST_SIZE): + digits = base + random.randrange(-1000, 1000) + s = '{}e{}'.format(digits, exponent) + yield s + +def test_bigcomp(): + for ndigs in 5, 10, 14, 15, 16, 17, 18, 19, 20, 40, 41, 50: + dig10 = 10**ndigs + for i in range(100 * TEST_SIZE): + digits = random.randrange(dig10) + exponent = random.randrange(-400, 400) + s = '{}e{}'.format(digits, exponent) + yield s + +def test_parsing(): + # make '0' more likely to be chosen than other digits + digits = '000000123456789' + signs = ('+', '-', '') + + # put together random short valid strings + # \d*[.\d*]?e + for i in range(1000): + for j in range(TEST_SIZE): + s = random.choice(signs) + intpart_len = random.randrange(5) + s += ''.join(random.choice(digits) for _ in range(intpart_len)) + if random.choice([True, False]): + s += '.' + fracpart_len = random.randrange(5) + s += ''.join(random.choice(digits) + for _ in range(fracpart_len)) + else: + fracpart_len = 0 + if random.choice([True, False]): + s += random.choice(['e', 'E']) + s += random.choice(signs) + exponent_len = random.randrange(1, 4) + s += ''.join(random.choice(digits) + for _ in range(exponent_len)) + + if intpart_len + fracpart_len: + yield s + +test_particular = [ + # squares + '1.00000000100000000025', + '1.0000000000000000000000000100000000000000000000000' #... + '00025', + '1.0000000000000000000000000000000000000000000010000' #... + '0000000000000000000000000000000000000000025', + '1.0000000000000000000000000000000000000000000000000' #... + '000001000000000000000000000000000000000000000000000' #... + '000000000025', + '0.99999999900000000025', + '0.9999999999999999999999999999999999999999999999999' #... + '999000000000000000000000000000000000000000000000000' #... + '000025', + '0.9999999999999999999999999999999999999999999999999' #... + '999999999999999999999999999999999999999999999999999' #... + '999999999999999999999999999999999999999990000000000' #... + '000000000000000000000000000000000000000000000000000' #... + '000000000000000000000000000000000000000000000000000' #... + '0000000000000000000000000000025', + + '1.0000000000000000000000000000000000000000000000000' #... + '000000000000000000000000000000000000000000000000000' #... + '100000000000000000000000000000000000000000000000000' #... + '000000000000000000000000000000000000000000000000001', + '1.0000000000000000000000000000000000000000000000000' #... + '000000000000000000000000000000000000000000000000000' #... + '500000000000000000000000000000000000000000000000000' #... + '000000000000000000000000000000000000000000000000005', + '1.0000000000000000000000000000000000000000000000000' #... + '000000000100000000000000000000000000000000000000000' #... + '000000000000000000250000000000000002000000000000000' #... + '000000000000000000000000000000000000000000010000000' #... + '000000000000000000000000000000000000000000000000000' #... + '0000000000000000001', + '1.0000000000000000000000000000000000000000000000000' #... + '000000000100000000000000000000000000000000000000000' #... + '000000000000000000249999999999999999999999999999999' #... + '999999999999979999999999999999999999999999999999999' #... + '999999999999999999999900000000000000000000000000000' #... + '000000000000000000000000000000000000000000000000000' #... + '00000000000000000000000001', + + '0.9999999999999999999999999999999999999999999999999' #... + '999999999900000000000000000000000000000000000000000' #... + '000000000000000000249999999999999998000000000000000' #... + '000000000000000000000000000000000000000000010000000' #... + '000000000000000000000000000000000000000000000000000' #... + '0000000000000000001', + '0.9999999999999999999999999999999999999999999999999' #... + '999999999900000000000000000000000000000000000000000' #... + '000000000000000000250000001999999999999999999999999' #... + '999999999999999999999999999999999990000000000000000' #... + '000000000000000000000000000000000000000000000000000' #... + '1', + + # tough cases for ln etc. + '1.000000000000000000000000000000000000000000000000' #... + '00000000000000000000000000000000000000000000000000' #... + '00100000000000000000000000000000000000000000000000' #... + '00000000000000000000000000000000000000000000000000' #... + '0001', + '0.999999999999999999999999999999999999999999999999' #... + '99999999999999999999999999999999999999999999999999' #... + '99899999999999999999999999999999999999999999999999' #... + '99999999999999999999999999999999999999999999999999' #... + '99999999999999999999999999999999999999999999999999' #... + '9999' + ] + + +TESTCASES = [ + [x for x in test_short_halfway_cases()], + [x for x in test_halfway_cases()], + [x for x in test_boundaries()], + [x for x in test_underflow_boundary()], + [x for x in test_bigcomp()], + [x for x in test_parsing()], + test_particular +] + +def un_randfloat(): + for i in range(1000): + l = random.choice(TESTCASES[:6]) + yield random.choice(l) + for v in test_particular: + yield v + +def bin_randfloat(): + for i in range(1000): + l1 = random.choice(TESTCASES) + l2 = random.choice(TESTCASES) + yield random.choice(l1), random.choice(l2) + +def tern_randfloat(): + for i in range(1000): + l1 = random.choice(TESTCASES) + l2 = random.choice(TESTCASES) + l3 = random.choice(TESTCASES) + yield random.choice(l1), random.choice(l2), random.choice(l3) + + +if __name__ == '__main__': + + for s in un_randfloat(): + print(s) + + for s in bin_randfloat(): + print(s) + + for s in tern_randfloat(): + print(s) diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/tests/Makefile.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/tests/Makefile.in Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,98 @@ + +SRCDIR = .. +INC = -I$(SRCDIR) -I../../../../ + +CC = @CC@ +LD = @CC@ +AR = @AR@ + +MPD_WARN = @MPD_WARN@ +MPD_CONFIG = @MPD_CONFIG@ +MPD_CCOV = @MPD_CCOV@ + +CONFIGURE_CFLAGS = @CONFIGURE_CFLAGS@ +CFLAGS ?= $(CONFIGURE_CFLAGS) + +GMPDEPS = @GMPDEPS@ +GMPPATH = @GMPPATH@ +ifneq ($(strip $(GMPPATH)),) + INC += -I$(GMPPATH)/include -L$(GMPPATH)/lib + ifeq ($(CC), suncc) + INC += -R$(GMPPATH)/lib + endif +endif + + +default: runtest cov fntcov test_transpose ppro_mulmod +extended: default karatsuba_fnt karatsuba_fnt2 $(GMPDEPS) +build_libcoverage: CFLAGS = $(MPD_WARN) $(MPD_CONFIG) $(MPD_CCOV) +build_libcoverage: default + + +# dectest +runtest:\ +runtest.c $(SRCDIR)/io.h $(SRCDIR)/mpdecimal.h $(SRCDIR)/memory.h \ + $(SRCDIR)/mptest.h $(SRCDIR)/mptypes.h $(SRCDIR)/libmpdec.a \ + malloc_fail.c malloc_fail.h + $(CC) $(INC) $(CFLAGS) -o runtest runtest.c malloc_fail.c $(SRCDIR)/libmpdec.a -lm + +cov:\ +cov.c $(SRCDIR)/mpdecimal.h $(SRCDIR)/mptypes.h $(SRCDIR)/libmpdec.a \ + malloc_fail.c malloc_fail.h + $(CC) $(INC) $(CFLAGS) -o cov cov.c malloc_fail.c $(SRCDIR)/libmpdec.a -lm + +fntcov:\ +fntcov.c $(SRCDIR)/mpdecimal.h $(SRCDIR)/mptypes.h $(SRCDIR)/libmpdec.a \ + malloc_fail.c malloc_fail.h + $(CC) $(INC) $(CFLAGS) -o fntcov fntcov.c malloc_fail.c $(SRCDIR)/libmpdec.a -lm + +# extended tests +karatsuba_fnt:\ +karatsuba_fnt.c $(SRCDIR)/mpdecimal.h $(SRCDIR)/mptypes.h $(SRCDIR)/libmpdec.a + $(CC) $(INC) $(CFLAGS) -o karatsuba_fnt karatsuba_fnt.c $(SRCDIR)/libmpdec.a -lm + +karatsuba_fnt2:\ +karatsuba_fnt2.c $(SRCDIR)/mpdecimal.h $(SRCDIR)/mptypes.h $(SRCDIR)/libmpdec.a + $(CC) $(INC) $(CFLAGS) -o karatsuba_fnt2 karatsuba_fnt2.c $(SRCDIR)/libmpdec.a -lm + +ppro_mulmod:\ +ppro_mulmod.c $(SRCDIR)/mpdecimal.h $(SRCDIR)/constants.h \ + $(SRCDIR)/numbertheory.h $(SRCDIR)/mptypes.h \ + $(SRCDIR)/mptest.h $(SRCDIR)/umodarith.h \ + $(SRCDIR)/typearith.h $(SRCDIR)/libmpdec.a + $(CC) $(INC) $(CFLAGS) -o ppro_mulmod ppro_mulmod.c $(SRCDIR)/libmpdec.a -lm + +test_transpose:\ +test_transpose.c $(SRCDIR)/bits.h $(SRCDIR)/mpdecimal.h \ + $(SRCDIR)/constants.h $(SRCDIR)/mptypes.h \ + $(SRCDIR)/mptest.h $(SRCDIR)/typearith.h \ + $(SRCDIR)/transpose.h $(SRCDIR)/libmpdec.a + $(CC) $(INC) $(CFLAGS) -o test_transpose test_transpose.c $(SRCDIR)/libmpdec.a -lm + +# tests against gmp +mpd_mpz_add:\ +mpd_mpz_add.c $(SRCDIR)/mpdecimal.h $(SRCDIR)/mptypes.h $(SRCDIR)/libmpdec.a + $(CC) $(INC) $(CFLAGS) -o mpd_mpz_add mpd_mpz_add.c $(SRCDIR)/libmpdec.a -lm -lgmp + +mpd_mpz_divmod:\ +mpd_mpz_divmod.c $(SRCDIR)/mpdecimal.h $(SRCDIR)/mptypes.h $(SRCDIR)/libmpdec.a + $(CC) $(INC) $(CFLAGS) -o mpd_mpz_divmod mpd_mpz_divmod.c $(SRCDIR)/libmpdec.a -lm -lgmp + +mpd_mpz_mul:\ +mpd_mpz_mul.c $(SRCDIR)/mpdecimal.h $(SRCDIR)/mptypes.h $(SRCDIR)/libmpdec.a + $(CC) $(INC) $(CFLAGS) -o mpd_mpz_mul mpd_mpz_mul.c $(SRCDIR)/libmpdec.a -lm -lgmp + +mpd_mpz_sub:\ +mpd_mpz_sub.c $(SRCDIR)/mpdecimal.h $(SRCDIR)/mptypes.h $(SRCDIR)/libmpdec.a + $(CC) $(INC) $(CFLAGS) -o mpd_mpz_sub mpd_mpz_sub.c $(SRCDIR)/libmpdec.a -lm -lgmp + + +FORCE: + +clean: FORCE + rm -f *.o *.gch *.gcda *.gcno *.gcov *.dyn *.dpi *.lock \ + runtest cov fntcov karatsuba_fnt karatsuba_fnt2 ppro_mulmod \ + test_transpose mpd_mpz_add mpd_mpz_divmod mpd_mpz_mul mpd_mpz_sub + + + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/tests/Makefile.vc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/tests/Makefile.vc Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,89 @@ + + +CC = cl.exe +LD = $(CC) + +SRCDIR = .. +INC = -I$(SRCDIR) + +OBJS = +!if "$(MACHINE)" == "x64" +OBJS = $(SRCDIR)\vcdiv64.obj +!endif + +default: runtest cov fntcov test_transpose +extended: default karatsuba_fnt karatsuba_fnt2 ppro_mulmod +extended_gmp: extended mpd_mpz_add mpd_mpz_divmod mpd_mpz_mul mpd_mpz_sub + + +# dectest +runtest:\ +Makefile runtest.c $(SRCDIR)\io.h $(SRCDIR)\mpdecimal.h $(SRCDIR)\memory.h \ + $(SRCDIR)\mptest.h $(SRCDIR)\mptypes.h $(SRCDIR)\$(USELIB) \ + malloc_fail.c malloc_fail.h + $(CC) -I$(SRCDIR) $(UFLAGS) $(CFLAGS) runtest.c malloc_fail.c $(SRCDIR)\$(USELIB) + +# coverage +cov:\ +cov.c $(SRCDIR)\mpdecimal.h $(SRCDIR)\mptypes.h $(SRCDIR)\$(USELIB) \ + malloc_fail.c malloc_fail.h + $(CC) -I$(SRCDIR) $(UFLAGS) $(CFLAGS) cov.c malloc_fail.c $(SRCDIR)\$(USELIB) + +fntcov:\ +fntcov.c $(SRCDIR)\mpdecimal.h $(SRCDIR)\mptypes.h $(SRCDIR)\$(USELIB) \ + malloc_fail.c malloc_fail.h + $(CC) -I$(SRCDIR) $(UFLAGS) $(CFLAGS) fntcov.c malloc_fail.c $(SRCDIR)\$(USELIB) + +# extended tests +karatsuba_fnt:\ +Makefile karatsuba_fnt.c $(SRCDIR)\mpdecimal.h $(SRCDIR)\mptypes.h \ + $(SRCDIR)\mptest.h $(SRCDIR)\$(USELIB) + $(CC) -I$(SRCDIR) $(UFLAGS) $(CFLAGS) karatsuba_fnt.c $(SRCDIR)\$(USELIB) +karatsuba_fnt2:\ +Makefile karatsuba_fnt2.c $(SRCDIR)\mpdecimal.h $(SRCDIR)\mptypes.h \ + $(SRCDIR)\mptest.h $(SRCDIR)\$(USELIB) + $(CC) -I$(SRCDIR) $(UFLAGS) $(CFLAGS) karatsuba_fnt2.c $(SRCDIR)\$(USELIB) +ppro_mulmod:\ +Makefile ppro_mulmod.c $(SRCDIR)\mpdecimal.h $(SRCDIR)\constants.h \ + $(SRCDIR)\numbertheory.h $(SRCDIR)\mptypes.h \ + $(SRCDIR)\mptest.h $(SRCDIR)\umodarith.h \ + $(SRCDIR)\typearith.h $(SRCDIR)\$(USELIB) + $(CC) -I$(SRCDIR) $(UFLAGS) $(CFLAGS) ppro_mulmod.c $(SRCDIR)\$(USELIB) +test_transpose:\ +Makefile test_transpose.c $(SRCDIR)\bits.h $(SRCDIR)\mpdecimal.h \ + $(SRCDIR)\constants.h $(SRCDIR)\mptypes.h \ + $(SRCDIR)\mptest.h $(SRCDIR)\typearith.h \ + $(SRCDIR)\transpose.h $(SRCDIR)\$(USELIB) + $(CC) -I$(SRCDIR) $(UFLAGS) -wd4273 $(CFLAGS) test_transpose.c $(SRCDIR)\constants.c $(OBJS) $(SRCDIR)\$(USELIB) + +# gmp tests +mpd_mpz_add:\ +Makefile mpd_mpz_add.c $(SRCDIR)\mpdecimal.h $(SRCDIR)\mptypes.h $(SRCDIR)\$(USELIB) + $(CC) -I$(SRCDIR) -I"$(GMPINC)" $(UFLAGS) $(CFLAGS) mpd_mpz_add.c $(SRCDIR)\$(USELIB) "$(GMPLIB)" +mpd_mpz_divmod:\ +Makefile mpd_mpz_divmod.c $(SRCDIR)\mpdecimal.h $(SRCDIR)\mptypes.h $(SRCDIR)\$(USELIB) + $(CC) -I$(SRCDIR) -I"$(GMPINC)" $(UFLAGS) $(CFLAGS) mpd_mpz_divmod.c $(SRCDIR)\$(USELIB) "$(GMPLIB)" +mpd_mpz_mul:\ +Makefile mpd_mpz_mul.c $(SRCDIR)\mpdecimal.h $(SRCDIR)\mptypes.h $(SRCDIR)\$(USELIB) + $(CC) -I$(SRCDIR) -I"$(GMPINC)" $(UFLAGS) $(CFLAGS) mpd_mpz_divmod.c $(SRCDIR)\$(USELIB) "$(GMPLIB)" +mpd_mpz_sub:\ +Makefile mpd_mpz_sub.c $(SRCDIR)\mpdecimal.h $(SRCDIR)\mptypes.h $(SRCDIR)\$(USELIB) + $(CC) -I$(SRCDIR) -I"$(GMPINC)" $(UFLAGS) $(CFLAGS) mpd_mpz_sub.c $(SRCDIR)\$(USELIB) "$(GMPLIB)" + + +FORCE: + +clean: FORCE + -@if exist *.obj del *.obj + -@if exist *.dll del *.dll + -@if exist *.exp del *.exp + -@if exist *.lib del *.lib + -@if exist *.ilk del *.ilk + -@if exist *.pdb del *.pdb + -@if exist *.pgc del *.pgc + -@if exist *.pgd del *.pgd + -@if exist *.manifest del *.manifest + -@if exist *.exe del *.exe + + + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/tests/additional.decTest --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/tests/additional.decTest Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,29 @@ + +-- Additional Tests + +Dectest: ./testdata/baseconv.decTest + +Dectest: ./testdata/binop_eq.decTest + +Dectest: ./testdata/divmod.decTest +Dectest: ./testdata/divmod_eq.decTest + +Dectest: ./testdata/fma_eq.decTest + +Dectest: ./testdata/format.decTest + +Dectest: ./testdata/invroot.decTest + +Dectest: ./testdata/largeint.decTest + +Dectest: ./testdata/powmod.decTest +Dectest: ./testdata/powmod_eq.decTest + +Dectest: ./testdata/shiftlr.decTest + +Dectest: ./testdata/getint.decTest + +Dectest: ./testdata/cov.decTest +Dectest: ./testdata/extra.decTest + + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/tests/cov.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/tests/cov.c Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,1346 @@ +#include +#include +#include +#include +#include "mpdecimal.h" +#include "mptypes.h" +#include "malloc_fail.h" + + +/* This file contains coverage tests for rarely exercised code paths. */ + +#ifndef _MSC_VER + #include + #define ASSERT(p) if (!(p)) {abort();} + mpd_uint_t mpd_qsshiftr(mpd_t *result, const mpd_t *a, mpd_ssize_t n); +#else + #define ASSERT(p) if (!(p)) {mpd_err_fatal("assertion failed");} +#endif + +#define BUFSIZE 500 +#if MPD_MAX_FLAG_LIST > BUFSIZE + #error "insufficient buffer length" +#endif + + +static void mpd_testcontext(mpd_context_t *ctx) +{ + mpd_defaultcontext(ctx); + ctx->prec = 28; +} + +static void +test_traphandler(mpd_context_t *ctx UNUSED) +{ + ; +} + +uint64_t +randbits(void) +{ + return (uint64_t)rand()<<48 | (uint64_t)rand()<<32 | + (uint64_t)rand()<<16 | (uint64_t)rand(); +} + + +/*****************************************************************************/ +/* Inttype conversion functions */ +/*****************************************************************************/ + +#define TEST_GETSET_INTTYPE(TYPE, FMTSPEC) \ +static void \ +getset_##TYPE( \ + mpd_t *a, TYPE x, mpd_context_t *ctx, \ + TYPE (* getfunc)(const mpd_t *, mpd_context_t *ctx), \ + void (* setfunc)(mpd_t *, TYPE, mpd_context_t *ctx)) \ +{ \ + char buf[BUFSIZE]; \ + char *s; \ + TYPE y; \ + \ + setfunc(a, x, ctx); \ + \ + if (getfunc != NULL) { \ + y = getfunc(a, ctx); \ + ASSERT(x == y) \ + } \ + \ + snprintf(buf, BUFSIZE, "%" FMTSPEC, x); \ + s = mpd_to_sci(a, 0); \ + ASSERT(strcmp(s, buf) == 0) \ + mpd_free(s); \ +} + +TEST_GETSET_INTTYPE(mpd_ssize_t, PRI_mpd_ssize_t) +TEST_GETSET_INTTYPE(int32_t, PRIi32) +TEST_GETSET_INTTYPE(int64_t, PRIi64) +TEST_GETSET_INTTYPE(mpd_uint_t, PRI_mpd_size_t) +TEST_GETSET_INTTYPE(uint32_t, PRIu32) +TEST_GETSET_INTTYPE(uint64_t, PRIu64) + +static void +test_int_conversions(void) +{ + uint32_t status; + mpd_context_t ctx; + mpd_t *a; + mpd_uint_t data[MPD_MINALLOC_MAX]; + mpd_t b = {MPD_STATIC|MPD_STATIC_DATA, 0, 0, 0, MPD_MINALLOC_MAX, data}; + int i; + + mpd_testcontext(&ctx); + a = mpd_new(&ctx); + +#ifdef CONFIG_64 + #define mpd_get_i32 NULL + #define mpd_get_u32 NULL +#else + #define mpd_get_i64 NULL + #define mpd_get_u64 NULL +#endif + + /* mpd_ssize_t */ + getset_mpd_ssize_t(a, MPD_SSIZE_MIN, &ctx, mpd_get_ssize, mpd_set_ssize); + getset_mpd_ssize_t(a, MPD_SSIZE_MAX, &ctx, mpd_get_ssize, mpd_set_ssize); + for (i = 0; i < 100000; i++) { + getset_mpd_ssize_t(a, (mpd_ssize_t)randbits(), &ctx, + mpd_get_ssize, mpd_set_ssize); + } + + getset_mpd_ssize_t(&b, MPD_SSIZE_MIN, &ctx, mpd_get_ssize, mpd_sset_ssize); + getset_mpd_ssize_t(&b, MPD_SSIZE_MAX, &ctx, mpd_get_ssize, mpd_sset_ssize); + for (i = 0; i < 100000; i++) { + getset_mpd_ssize_t(&b, (mpd_ssize_t)randbits(), &ctx, + mpd_get_ssize, mpd_sset_ssize); + } + + /* int32_t */ + getset_int32_t(a, INT32_MIN, &ctx, mpd_get_i32, mpd_set_i32); + getset_int32_t(a, INT32_MAX, &ctx, mpd_get_i32, mpd_set_i32); + for (i = 0; i < 100000; i++) { + getset_int32_t(a, (int32_t)randbits(), &ctx, + mpd_get_i32, mpd_set_i32); + } + + getset_int32_t(&b, INT32_MIN, &ctx, mpd_get_i32, mpd_sset_i32); + getset_int32_t(&b, INT32_MAX, &ctx, mpd_get_i32, mpd_sset_i32); + for (i = 0; i < 100000; i++) { + getset_int32_t(&b, (int32_t)randbits(), &ctx, + mpd_get_i32, mpd_sset_i32); + } + + /* int64_t */ + getset_int64_t(a, INT64_MIN, &ctx, mpd_get_i64, mpd_set_i64); + getset_int64_t(a, INT64_MAX, &ctx, mpd_get_i64, mpd_set_i64); + for (i = 0; i < 100000; i++) { + getset_int64_t(a, (int64_t)randbits(), &ctx, + mpd_get_i64, mpd_set_i64); + } + +#ifdef CONFIG_64 + getset_int64_t(&b, INT64_MIN, &ctx, mpd_get_i64, mpd_sset_i64); + getset_int64_t(&b, INT64_MAX, &ctx, mpd_get_i64, mpd_sset_i64); + for (i = 0; i < 100000; i++) { + getset_int64_t(&b, (int64_t)randbits(), &ctx, + mpd_get_i64, mpd_sset_i64); + } +#endif + + /* mpd_uint_t */ + getset_mpd_uint_t(a, 0, &ctx, mpd_get_uint, mpd_set_uint); + getset_mpd_uint_t(a, MPD_UINT_MAX, &ctx, mpd_get_uint, mpd_set_uint); + for (i = 0; i < 100000; i++) { + getset_mpd_uint_t(a, (mpd_uint_t)randbits(), &ctx, + mpd_get_uint, mpd_set_uint); + } + + getset_mpd_uint_t(&b, 0, &ctx, mpd_get_uint, mpd_sset_uint); + getset_mpd_uint_t(&b, MPD_UINT_MAX, &ctx, mpd_get_uint, mpd_sset_uint); + for (i = 0; i < 100000; i++) { + getset_mpd_uint_t(&b, (mpd_uint_t)randbits(), &ctx, + mpd_get_uint, mpd_sset_uint); + } + + /* uint32_t */ + getset_uint32_t(a, 0, &ctx, mpd_get_u32, mpd_set_u32); + getset_uint32_t(a, UINT32_MAX, &ctx, mpd_get_u32, mpd_set_u32); + for (i = 0; i < 100000; i++) { + getset_uint32_t(a, (uint32_t)randbits(), &ctx, + mpd_get_u32, mpd_set_u32); + } + + getset_uint32_t(&b, 0, &ctx, mpd_get_u32, mpd_sset_u32); + getset_uint32_t(&b, UINT32_MAX, &ctx, mpd_get_u32, mpd_sset_u32); + for (i = 0; i < 100000; i++) { + getset_uint32_t(&b, (uint32_t)randbits(), &ctx, + mpd_get_u32, mpd_sset_u32); + } + + /* uint64_t */ + getset_uint64_t(a, 0, &ctx, mpd_get_u64, mpd_set_u64); + getset_uint64_t(a, UINT64_MAX, &ctx, mpd_get_u64, mpd_set_u64); + for (i = 0; i < 100000; i++) { + getset_uint64_t(a, (uint64_t)randbits(), &ctx, + mpd_get_u64, mpd_set_u64); + } + +#ifdef CONFIG_64 + getset_uint64_t(&b, 0, &ctx, mpd_get_u64, mpd_sset_u64); + getset_uint64_t(&b, UINT64_MAX, &ctx, mpd_get_u64, mpd_sset_u64); + for (i = 0; i < 100000; i++) { + getset_uint64_t(&b, (uint64_t)randbits(), &ctx, + mpd_get_u64, mpd_sset_u64); + } +#endif + + /* specials */ + status = 0; + mpd_set_string(a, "nan", &ctx); + ASSERT(mpd_qget_uint(a, &status) == MPD_UINT_MAX) + ASSERT(status&MPD_Invalid_operation) + + /* non-integer */ + status = 0; + mpd_set_string(a, "2345e-1", &ctx); + ASSERT(mpd_qget_uint(a, &status) == MPD_UINT_MAX) + ASSERT(status&MPD_Invalid_operation) + + /* too large */ + status = 0; + mpd_set_uint(a, 8, &ctx); + a->exp = MPD_RDIGITS; + ASSERT(mpd_qget_uint(a, &status) == MPD_UINT_MAX) + ASSERT(status&MPD_Invalid_operation) + + /* too large */ + status = 0; + mpd_set_uint(a, ((uint64_t)MPD_SSIZE_MAX)+1, &ctx); + ASSERT(mpd_qget_ssize(a, &status) == MPD_SSIZE_MAX) + ASSERT(status&MPD_Invalid_operation) + + mpd_del(a); +} + + +/*****************************************************************************/ +/* Mixed arithmetic functions */ +/*****************************************************************************/ + +#define TEST_ARITH_INTTYPE(TYPE, FMTSPEC) \ +static void \ +arith_##TYPE( \ + mpd_t *tmp, const mpd_t *a, TYPE x, mpd_context_t *ctx, \ + void (* func)(mpd_t *, const mpd_t *, TYPE, mpd_context_t *ctx), \ + void (* ctrl)(mpd_t *, const mpd_t *, const mpd_t *, mpd_context_t *ctx)) \ +{ \ + char buf[BUFSIZE]; \ + char *s1, *s2; \ + \ + func(tmp, a, x, ctx); \ + s1 = mpd_to_sci(tmp, 0); \ + \ + snprintf(buf, BUFSIZE, "%" FMTSPEC, x); \ + mpd_set_string(tmp, buf, ctx); \ + ctrl(tmp, a, tmp, ctx); \ + s2 = mpd_to_sci(tmp, 0); \ + \ + ASSERT(strcmp(s1, s2) == 0) \ + mpd_free(s1); \ + mpd_free(s2); \ +} + +TEST_ARITH_INTTYPE(mpd_ssize_t, PRI_mpd_ssize_t) +TEST_ARITH_INTTYPE(int32_t, PRIi32) +TEST_ARITH_INTTYPE(mpd_uint_t, PRI_mpd_size_t) +TEST_ARITH_INTTYPE(uint32_t, PRIu32) +#ifdef CONFIG_64 +TEST_ARITH_INTTYPE(int64_t, PRIi64) +TEST_ARITH_INTTYPE(uint64_t, PRIu64) +#endif + +static void (*ssize_funcs[])(mpd_t*, const mpd_t*, mpd_ssize_t, mpd_context_t*) = + {mpd_add_ssize, mpd_sub_ssize, mpd_mul_ssize, mpd_div_ssize, NULL}; + +static void (*i32_funcs[])(mpd_t*, const mpd_t*, int32_t, mpd_context_t*) = + {mpd_add_i32, mpd_sub_i32, mpd_mul_i32, mpd_div_i32, NULL}; + +static void (*uint_funcs[])(mpd_t*, const mpd_t*, mpd_uint_t, mpd_context_t*) = + {mpd_add_uint, mpd_sub_uint, mpd_mul_uint, mpd_div_uint, NULL}; + +static void (*u32_funcs[])(mpd_t*, const mpd_t*, uint32_t, mpd_context_t*) = + {mpd_add_u32, mpd_sub_u32, mpd_mul_u32, mpd_div_u32, NULL}; + +#ifdef CONFIG_64 +static void (*i64_funcs[])(mpd_t*, const mpd_t*, int64_t, mpd_context_t*) = + {mpd_add_i64, mpd_sub_i64, mpd_mul_i64, mpd_div_i64, NULL}; + +static void (*u64_funcs[])(mpd_t*, const mpd_t*, uint64_t, mpd_context_t*) = + {mpd_add_u64, mpd_sub_u64, mpd_mul_u64, mpd_div_u64, NULL}; +#endif + +static void (*control_funcs[])(mpd_t*, const mpd_t*, const mpd_t*, mpd_context_t*) = + {mpd_add, mpd_sub, mpd_mul, mpd_div, NULL}; + + +/* mixed mpd_t and integer operations */ +static void +test_mixed_arith(void) +{ + mpd_context_t ctx; + mpd_t *tmp, *a; + int i, k; + + mpd_testcontext(&ctx); + tmp = mpd_new(&ctx); + a = mpd_new(&ctx); + + ctx.traps &= ~MPD_Division_by_zero; + + for (i = 0; ssize_funcs[i] != NULL; i++) { + mpd_set_string(a, "123456e2", &ctx); + arith_mpd_ssize_t(tmp, a, MPD_SSIZE_MIN, &ctx, + ssize_funcs[i], control_funcs[i]); + arith_mpd_ssize_t(tmp, a, MPD_SSIZE_MAX, &ctx, + ssize_funcs[i], control_funcs[i]); + for (k = 0; k < 100000; k++) { + arith_mpd_ssize_t(tmp, a, (mpd_ssize_t)randbits(), &ctx, + ssize_funcs[i], control_funcs[i]); + } + } + + for (i = 0; i32_funcs[i] != NULL; i++) { + mpd_set_string(a, "-123456e2", &ctx); + arith_int32_t(tmp, a, INT32_MIN, &ctx, + i32_funcs[i], control_funcs[i]); + arith_int32_t(tmp, a, INT32_MAX, &ctx, + i32_funcs[i], control_funcs[i]); + for (k = 0; k < 100000; k++) { + arith_int32_t(tmp, a, (int32_t)randbits(), &ctx, + i32_funcs[i], control_funcs[i]); + } + } + + for (i = 0; uint_funcs[i] != NULL; i++) { + mpd_set_string(a, "456789e2", &ctx); + arith_mpd_uint_t(tmp, a, 0, &ctx, + uint_funcs[i], control_funcs[i]); + arith_mpd_uint_t(tmp, a, MPD_UINT_MAX, &ctx, + uint_funcs[i], control_funcs[i]); + for (k = 0; k < 100000; k++) { + arith_mpd_uint_t(tmp, a, (mpd_uint_t)randbits(), &ctx, + uint_funcs[i], control_funcs[i]); + } + } + + for (i = 0; u32_funcs[i] != NULL; i++) { + mpd_set_string(a, "987654e2", &ctx); + arith_uint32_t(tmp, a, 0, &ctx, + u32_funcs[i], control_funcs[i]); + arith_uint32_t(tmp, a, UINT32_MAX, &ctx, + u32_funcs[i], control_funcs[i]); + for (k = 0; k < 100000; k++) { + arith_uint32_t(tmp, a, (uint32_t)randbits(), &ctx, + u32_funcs[i], control_funcs[i]); + } + } + +#ifdef CONFIG_64 + for (i = 0; i64_funcs[i] != NULL; i++) { + mpd_set_string(a, "-123456e2", &ctx); + arith_int64_t(tmp, a, INT64_MIN, &ctx, + i64_funcs[i], control_funcs[i]); + arith_int64_t(tmp, a, INT64_MAX, &ctx, + i64_funcs[i], control_funcs[i]); + for (k = 0; k < 100000; k++) { + arith_int64_t(tmp, a, (int64_t)randbits(), &ctx, + i64_funcs[i], control_funcs[i]); + } + } + + for (i = 0; u64_funcs[i] != NULL; i++) { + mpd_set_string(a, "-123456e2", &ctx); + arith_uint64_t(tmp, a, 0, &ctx, + u64_funcs[i], control_funcs[i]); + arith_uint64_t(tmp, a, UINT64_MAX, &ctx, + u64_funcs[i], control_funcs[i]); + for (k = 0; k < 100000; k++) { + arith_uint64_t(tmp, a, (uint64_t)randbits(), &ctx, + u64_funcs[i], control_funcs[i]); + } + } +#endif + + mpd_del(tmp); + mpd_del(a); +} + +static void +test_context(void) +{ + mpd_context_t ctx; + mpd_ssize_t ssize; + + /* context.c */ + mpd_traphandler = test_traphandler; + mpd_init(&ctx, MPD_MAX_PREC+1); + ASSERT(ctx.status&MPD_Invalid_context) + ASSERT(ctx.newtrap == MPD_Invalid_context) + mpd_traphandler = mpd_dflt_traphandler; + + mpd_init(&ctx, 100); + ASSERT(MPD_MINALLOC_MIN <= MPD_MINALLOC && + MPD_MINALLOC <= MPD_MINALLOC_MAX) + + fprintf(stderr, " This warning is part of the coverage test: "); + ssize = MPD_MINALLOC; + mpd_setminalloc(2000); + ASSERT(MPD_MINALLOC == ssize) + + /* DON'T do this */ + MPD_MINALLOC = MPD_MINALLOC_MIN; + + mpd_basiccontext(&ctx); + ASSERT(mpd_getprec(&ctx) == 9) + ASSERT(mpd_getemax(&ctx) == MPD_MAX_EMAX) + ASSERT(mpd_getemin(&ctx) == MPD_MIN_EMIN) + ASSERT(mpd_getround(&ctx) == MPD_ROUND_HALF_UP) + ASSERT(mpd_gettraps(&ctx) == (MPD_Traps|MPD_Clamped)) + ASSERT(mpd_getstatus(&ctx) == 0) + ASSERT(mpd_getclamp(&ctx) == 0) + ASSERT(mpd_getcr(&ctx) == 1) + + ASSERT(mpd_ieee_context(&ctx, MPD_IEEE_CONTEXT_MAX_BITS*2) < 0) + + mpd_ieee_context(&ctx, 128); + ASSERT(mpd_getprec(&ctx) == 34) + ASSERT(mpd_getemax(&ctx) == 6144) + ASSERT(mpd_getemin(&ctx) == -6143) + ASSERT(mpd_getround(&ctx) == MPD_ROUND_HALF_EVEN) + ASSERT(mpd_gettraps(&ctx) == 0) + ASSERT(mpd_getstatus(&ctx) == 0) + ASSERT(mpd_getclamp(&ctx) == 1) + ASSERT(mpd_getcr(&ctx) == 1) + + ASSERT(!mpd_qsetprec(&ctx, -1)) + ASSERT(!mpd_qsetprec(&ctx, 0)) + ASSERT(!mpd_qsetprec(&ctx, MPD_MAX_PREC+1)) + + ASSERT(!mpd_qsetemax(&ctx, -1)) + ASSERT(!mpd_qsetemax(&ctx, MPD_MAX_EMAX+1)) + + ASSERT(!mpd_qsetemin(&ctx, 1)) + ASSERT(!mpd_qsetemin(&ctx, MPD_MIN_EMIN-1)) + + ASSERT(!mpd_qsetround(&ctx, -1)) + ASSERT(!mpd_qsetround(&ctx, MPD_ROUND_GUARD)) + + ASSERT(!mpd_qsettraps(&ctx, MPD_Max_status+1)) + ASSERT(!mpd_qsetstatus(&ctx, MPD_Max_status+1)) + + ASSERT(!mpd_qsetclamp(&ctx, -1)) + ASSERT(!mpd_qsetclamp(&ctx, 2)) + + ASSERT(!mpd_qsetcr(&ctx, -1)) + ASSERT(!mpd_qsetcr(&ctx, 2)) + + mpd_qsetprec(&ctx, 2*MPD_RDIGITS); + ASSERT(ctx.prec == 2*MPD_RDIGITS) + + mpd_qsetemax(&ctx, MPD_MAX_EMAX); + ASSERT(ctx.emax == MPD_MAX_EMAX) + + mpd_qsetemin(&ctx, MPD_MIN_EMIN); + ASSERT(ctx.emin == MPD_MIN_EMIN) + + mpd_qsetround(&ctx, MPD_ROUND_HALF_UP); + ASSERT(ctx.round == MPD_ROUND_HALF_UP) + + mpd_qsettraps(&ctx, MPD_Traps); + ASSERT(ctx.traps == MPD_Traps) + + mpd_qsetstatus(&ctx, 0); + ASSERT(ctx.status == 0) + + mpd_qsetclamp(&ctx, 0); + ASSERT(ctx.clamp == 0) + + mpd_qsetcr(&ctx, 1); + ASSERT(ctx.allcr == 1) +} + +/* + * NOTE: Using setters like in this function is dangerous or meaningless + * at best. This is only for testing. + */ +static void +test_attributes(void) +{ + mpd_context_t ctx; + mpd_uint_t adata[MPD_MINALLOC_MAX]; + mpd_uint_t bdata[MPD_MINALLOC_MAX]; + mpd_t a = {MPD_STATIC|MPD_STATIC_DATA, 0, 0, 0, MPD_MINALLOC_MAX, adata}; + mpd_t b = {MPD_STATIC|MPD_STATIC_DATA, 0, 0, 0, MPD_MINALLOC_MAX, bdata}; + char *s; + + mpd_testcontext(&ctx); + + /* specials */ + mpd_set_infinity(&a); + ASSERT(mpd_isinfinite(&a)) + mpd_set_snan(&a); + ASSERT(mpd_issnan(&a)) + + /* data flags */ + mpd_set_dynamic(&a); + ASSERT(mpd_isdynamic(&a)) + mpd_set_static(&a); + ASSERT(mpd_isstatic(&a)) + mpd_set_const_data(&a); + ASSERT(mpd_isconst_data(&a)) + + mpd_set_static_data(&a); + mpd_clear_flags(&a); + + /* switch to dynamic data */ + mpd_set_string(&a, "-2.3854727e+1875", &ctx); + ASSERT(mpd_isstatic(&a)) + ASSERT(mpd_isstatic_data(&a)) + ASSERT(mpd_resize(&a, 2*MPD_MINALLOC_MAX, &ctx)) + ASSERT(a.alloc == 2*MPD_MINALLOC_MAX) + ASSERT(mpd_isstatic(&a)) + ASSERT(mpd_isdynamic_data(&a)) + s = mpd_to_sci(&a, 0); + ASSERT(strcmp(s, "-2.3854727e+1875") == 0) + mpd_free(s); + + /* switch to dynamic data, zero new memory */ + mpd_set_string(&b, "123456789", &ctx); + ASSERT(mpd_isstatic(&b)) + ASSERT(mpd_isstatic_data(&b)) + ASSERT(mpd_resize_zero(&b, 3*MPD_MINALLOC_MAX, &ctx)) + ASSERT(b.alloc == 3*MPD_MINALLOC_MAX) + ASSERT(mpd_isstatic(&b)) + ASSERT(mpd_isdynamic_data(&b)) + ASSERT(b.data[0] == 0) + + + /* rarely used attributes */ + mpd_set_string(&a, "2.3854727e+1875", &ctx); + ASSERT(mpd_iscanonical(&a)) + ASSERT(mpd_isfinite(&a)) + ASSERT(!mpd_issigned(&a)) + mpd_set_negative(&a); + ASSERT(mpd_issigned(&a)) + + mpd_set_string(&a, "123000e-3", &ctx); + ASSERT(mpd_isinteger(&a)) + ASSERT(mpd_isodd(&a)) + ASSERT(!mpd_iseven(&a)) + + mpd_set_string(&a, "123000e-2", &ctx); + ASSERT(mpd_isinteger(&a)) + ASSERT(mpd_iseven(&a)) + ASSERT(!mpd_isodd(&a)) + + mpd_del(&a); + mpd_del(&b); +} + +static void +test_shift(void) +{ + mpd_context_t ctx; + mpd_uint_t adata[MPD_MINALLOC_MAX]; + mpd_uint_t bdata[MPD_MINALLOC_MAX]; + mpd_t a = {MPD_STATIC|MPD_STATIC_DATA, 0, 0, 0, MPD_MINALLOC_MAX, adata}; + mpd_t b = {MPD_STATIC|MPD_STATIC_DATA, 0, 0, 0, MPD_MINALLOC_MAX, bdata}; + char *s; + + /* mpd_qsshiftr */ + mpd_testcontext(&ctx); + ctx.prec = 100; + ctx.emax = MPD_MAX_EMAX; + ctx.emin = MPD_MIN_EMIN; + + mpd_set_string(&a, "123456789123456789", &ctx); + mpd_qsshiftr(&a, &a, 0); + s = mpd_to_sci(&a, 0); + ASSERT(strcmp(s, "123456789123456789") == 0) + mpd_free(s); + + mpd_set_string(&a, "0", &ctx); + mpd_qsshiftr(&a, &a, 0); + s = mpd_to_sci(&a, 0); + ASSERT(strcmp(s, "0") == 0) + mpd_free(s); + + mpd_set_string(&a, "123", &ctx); + mpd_qsshiftr(&a, &a, 7); + s = mpd_to_sci(&a, 0); + ASSERT(strcmp(s, "0") == 0) + mpd_free(s); + + mpd_set_string(&a, "123456789123456789", &ctx); + mpd_qsshiftr(&b, &a, 0); + s = mpd_to_sci(&b, 0); + ASSERT(strcmp(s, "123456789123456789") == 0) + mpd_free(s); + + mpd_set_string(&a, "0", &ctx); + mpd_qsshiftr(&b, &a, 0); + s = mpd_to_sci(&b, 0); + ASSERT(strcmp(s, "0") == 0) + mpd_free(s); + + mpd_set_string(&a, "123", &ctx); + mpd_qsshiftr(&b, &a, 7); + s = mpd_to_sci(&b, 0); + ASSERT(strcmp(s, "0") == 0) + mpd_free(s); + + /* mpd_qrotate */ + ctx.traps = 0; + ctx.status = 0; + mpd_set_string(&a, "1234556789", &ctx); + mpd_set_string(&b, "1e100", &ctx); + mpd_rotate(&a, &a, &b, &ctx); + ASSERT(mpd_isnan(&a)) + ASSERT(ctx.status&MPD_Invalid_operation) + + mpd_del(&a); + mpd_del(&b); +} + +static void +test_check_nans(void) +{ + mpd_context_t ctx; + mpd_uint_t adata[MPD_MINALLOC_MAX]; + mpd_uint_t bdata[MPD_MINALLOC_MAX]; + mpd_t a = {MPD_STATIC|MPD_STATIC_DATA, 0, 0, 0, MPD_MINALLOC_MAX, adata}; + mpd_t b = {MPD_STATIC|MPD_STATIC_DATA, 0, 0, 0, MPD_MINALLOC_MAX, bdata}; + + mpd_testcontext(&ctx); + + /* check nans */ + ctx.status = 0; + mpd_set_string(&a, "NaN", &ctx); + ASSERT(mpd_check_nan(&b, &a, &ctx)) + ASSERT(ctx.status == 0) + ASSERT(mpd_isqnan(&b)) + + ctx.status = 0; + mpd_set_string(&a, "1", &ctx); + ASSERT(!mpd_check_nan(&b, &a, &ctx)) + ASSERT(ctx.status == 0) + + mpd_traphandler = test_traphandler; + ctx.status = 0; + mpd_set_string(&a, "sNaN", &ctx); + mpd_set_string(&b, "1", &ctx); + ASSERT(mpd_check_nans(&b, &a, &b, &ctx)) + ASSERT(ctx.status == MPD_Invalid_operation) + ASSERT(mpd_isqnan(&b)) + mpd_traphandler = mpd_dflt_traphandler; + + ctx.status = 0; + mpd_set_string(&a, "2", &ctx); + mpd_set_string(&b, "1", &ctx); + ASSERT(!mpd_check_nans(&b, &a, &b, &ctx)) + ASSERT(ctx.status == 0) + + mpd_del(&a); + mpd_del(&b); +} + +static void +test_finalize_round(void) +{ + mpd_context_t ctx; + mpd_uint_t adata[MPD_MINALLOC_MAX]; + mpd_uint_t bdata[MPD_MINALLOC_MAX]; + mpd_t a = {MPD_STATIC|MPD_STATIC_DATA, 0, 0, 0, MPD_MINALLOC_MAX, adata}; + mpd_t b = {MPD_STATIC|MPD_STATIC_DATA, 0, 0, 0, MPD_MINALLOC_MAX, bdata}; + char *s; + + mpd_testcontext(&ctx); + + /* finalize */ + ctx.prec = 5; + ctx.status = 0; + mpd_set_string(&a, "8.89871263726722323e201", &ctx); + mpd_finalize(&a, &ctx); + s = mpd_to_sci(&a, 1); + ASSERT(strcmp(s, "8.8987E+201") == 0) + ASSERT(ctx.status == (MPD_Rounded|MPD_Inexact)) + mpd_free(s); + + /* apply_round_excess, apply_round_fit */ + ctx.prec = MPD_RDIGITS + 1; + ctx.emax = 99; + ctx.emin = -99; + ctx.traps &= ~MPD_Underflow; + +#ifdef CONFIG_64 + ctx.status = 0; + mpd_set_string(&a, "99999999999999999999e-119", &ctx); + s = mpd_to_sci(&a, 0); + ASSERT(strcmp(s, "1.0000000000000000000e-99") == 0) + ASSERT(ctx.status == (MPD_Underflow|MPD_Subnormal|MPD_Rounded|MPD_Inexact)) + mpd_free(s); + + ctx.status = 0; + mpd_set_string(&a, "99999999999999999999e79", &ctx); + mpd_set_string(&b, "1e80", &ctx); + mpd_quantize(&a, &a, &b, &ctx); + s = mpd_to_sci(&a, 0); + ASSERT(strcmp(s, "1.0000000000000000000e+99") == 0) + ASSERT(ctx.status == (MPD_Rounded|MPD_Inexact)) + mpd_free(s); +#else + ctx.status = 0; + mpd_set_string(&a, "9999999999e-109", &ctx); + s = mpd_to_sci(&a, 0); + ASSERT(strcmp(s, "1.000000000e-99") == 0) + ASSERT(ctx.status == (MPD_Underflow|MPD_Subnormal|MPD_Rounded|MPD_Inexact)) + mpd_free(s); + + ctx.status = 0; + mpd_set_string(&a, "9999999999e89", &ctx); + mpd_set_string(&b, "1e90", &ctx); + mpd_quantize(&a, &a, &b, &ctx); + s = mpd_to_sci(&a, 0); + ASSERT(strcmp(s, "1.000000000e+99") == 0) + ASSERT(ctx.status == (MPD_Rounded|MPD_Inexact)) + mpd_free(s); +#endif + + mpd_del(&a); + mpd_del(&b); +} + +static void +test_baseconv(void) +{ + mpd_context_t ctx; + mpd_uint_t adata[MPD_MINALLOC_MAX]; + mpd_t a = {MPD_STATIC|MPD_STATIC_DATA, 0, 0, 0, MPD_MINALLOC_MAX, adata}; + uint32_t u32data; + uint16_t u16data; + + mpd_testcontext(&ctx); + mpd_traphandler = test_traphandler; + + /* special or non-integer values */ + mpd_set_string(&a, "inf", &ctx); + + ctx.status = 0; + ASSERT(mpd_export_u16(&u16data, 1, 1<<15, &a, &ctx) == SIZE_MAX) + ASSERT(ctx.status & MPD_Invalid_operation) + + ctx.status = 0; + ASSERT(mpd_export_u32(&u32data, 1, 1<<15, &a, &ctx) == SIZE_MAX) + ASSERT(ctx.status & MPD_Invalid_operation) + + mpd_set_string(&a, "9.12987391", &ctx); + + ctx.status = 0; + ASSERT(mpd_export_u16(&u16data, 1, 1<<15, &a, &ctx) == SIZE_MAX) + ASSERT(ctx.status & MPD_Invalid_operation) + + ctx.status = 0; + ASSERT(mpd_export_u32(&u32data, 1, 1<<15, &a, &ctx) == SIZE_MAX) + ASSERT(ctx.status & MPD_Invalid_operation) + + /* exceeding limits */ +#if MPD_SIZE_MAX < SIZE_MAX + mpd_set_string(&a, "123456789", &ctx); + ctx.status = 0; + ASSERT(mpd_export_u32(&u32data, (size_t)MPD_SSIZE_MAX+1, 1<<15, &a, &ctx) == SIZE_MAX) + ASSERT(ctx.status & MPD_Invalid_operation) +#endif + + mpd_set_string(&a, "123456789", &ctx); + + ctx.status = 0; + mpd_import_u16(&a, &u16data, SIZE_MAX-1, MPD_POS, 1<<15, &ctx); + ASSERT(ctx.status & MPD_Invalid_operation) + + ctx.status = 0; + mpd_import_u16(&a, &u16data, MPD_SIZE_MAX/(sizeof (mpd_uint_t))+1, MPD_POS, 2, &ctx); + ASSERT(ctx.status & MPD_Invalid_operation) + + ctx.status = 0; + mpd_import_u32(&a, &u32data, SIZE_MAX-1, MPD_POS, 1<<15, &ctx); + ASSERT(ctx.status & MPD_Invalid_operation) + + ctx.status = 0; + mpd_import_u32(&a, &u32data, MPD_SIZE_MAX/(sizeof (mpd_uint_t))+1, MPD_POS, 2, &ctx); + ASSERT(ctx.status & MPD_Invalid_operation) + + mpd_traphandler = mpd_dflt_traphandler; + mpd_del(&a); +} + +static void +test_set_string(void) +{ + mpd_context_t ctx; + mpd_uint_t adata[MPD_MINALLOC_MAX]; + mpd_uint_t bdata[MPD_MINALLOC_MAX]; + mpd_t a = {MPD_STATIC|MPD_STATIC_DATA, 0, 0, 0, MPD_MINALLOC_MAX, adata}; + mpd_t b = {MPD_STATIC|MPD_STATIC_DATA, 0, 0, 0, MPD_MINALLOC_MAX, bdata}; + char buf[BUFSIZE]; + char *s, *t; + mpd_ssize_t mem; + int n; + + mpd_testcontext(&ctx); + ctx.traps = MPD_Malloc_error; + + /* Exponent limits */ + ctx.status = 0; + ctx.prec = 28; + snprintf(buf, BUFSIZE, "0.0000000000000000000000001e%" PRI_mpd_ssize_t, + (mpd_ssize_t)MPD_MAX_EMAX+20); + mpd_set_string(&a, buf, &ctx); + t = mpd_to_sci(&a, 1); + snprintf(buf, BUFSIZE, "1E+%" PRI_mpd_ssize_t, (mpd_ssize_t)MPD_MAX_EMAX-5); + ASSERT(strcmp(t, buf) == 0) + ASSERT(ctx.status == 0) + mpd_free(t); + + ctx.status = 0; + ctx.prec = MPD_MAX_PREC; + snprintf(buf, BUFSIZE, "0.0000000000000000000000001e%" PRI_mpd_ssize_t, + (mpd_ssize_t)MPD_MAX_EMAX+30); + mpd_set_string(&a, buf, &ctx); + t = mpd_to_sci(&a, 1); + ASSERT(strcmp(t, "Infinity") == 0) + ASSERT(ctx.status == (MPD_Inexact|MPD_Overflow|MPD_Rounded)) + mpd_free(t); + + ctx.status = 0; + ctx.prec = MPD_MAX_PREC; + snprintf(buf, BUFSIZE, "1000000000000000000000000000e%" PRI_mpd_ssize_t, mpd_etiny(&ctx)-27); + mpd_set_string(&a, buf, &ctx); + t = mpd_to_sci(&a, 1); + snprintf(buf, BUFSIZE, "1E%" PRI_mpd_ssize_t, mpd_etiny(&ctx)); + ASSERT(strcmp(t, buf) == 0) + ASSERT(ctx.status == (MPD_Subnormal|MPD_Rounded)) + mpd_free(t); + + ctx.status = 0; + ctx.prec = 28; + snprintf(buf, BUFSIZE, "-0.0000000000000000000000001e%" PRI_mpd_ssize_t, MPD_SSIZE_MAX); + mpd_set_string(&a, buf, &ctx); + t = mpd_to_sci(&a, 1); + ASSERT(strcmp(t, "-Infinity") == 0) + ASSERT(ctx.status == (MPD_Overflow|MPD_Rounded|MPD_Inexact)) + mpd_free(t); + + ctx.status = 0; + ctx.prec = 28; + snprintf(buf, BUFSIZE, "-0.0000000000000000000000001e%" PRI_mpd_ssize_t, MPD_SSIZE_MIN); + mpd_set_string(&a, buf, &ctx); + snprintf(buf, BUFSIZE, "-0E%" PRI_mpd_ssize_t, mpd_etiny(&ctx)); + t = mpd_to_sci(&a, 1); + ASSERT(strcmp(t, buf) == 0) + ASSERT(ctx.status == (MPD_Subnormal|MPD_Inexact| + MPD_Clamped|MPD_Underflow| + MPD_Rounded)) + mpd_free(t); + + ctx.status = 0; + n = snprintf(buf, BUFSIZE, "1e%s", "184467440737095516161"); + mpd_set_string(&a, buf, &ctx); + t = mpd_to_sci(&a, 1); + ASSERT(strcmp(t, "Infinity") == 0) + ASSERT(ctx.status == (MPD_Inexact|MPD_Overflow|MPD_Rounded)) + mpd_free(t); + + ctx.status = 0; + n = snprintf(buf, BUFSIZE, "-1e%s", "-184467440737095516161"); + mpd_set_string(&a, buf, &ctx); + t = mpd_to_sci(&a, 1); + snprintf(buf, BUFSIZE, "-0E%" PRI_mpd_ssize_t, mpd_etiny(&ctx)); + ASSERT(strcmp(t, buf) == 0) + ASSERT(ctx.status == (MPD_Subnormal|MPD_Inexact| + MPD_Clamped|MPD_Underflow| + MPD_Rounded)) + mpd_free(t); + + + /* Exponent and precision limits: requires large amounts of memory. */ + mem = MPD_MAX_PREC+10+23+1; + if ((s = malloc(mem)) == NULL) { + mpd_del(&a); + mpd_del(&b); + return; + } + + ctx.prec = MPD_MAX_PREC; + + /* .000...0001e2147483647 -> Infinity */ + s[0] = '.'; + memset(s+1, '0', MPD_MAX_PREC-1); + s[MPD_MAX_PREC] = '1'; + s[MPD_MAX_PREC+1] = 'e'; + s[MPD_MAX_PREC+2] = '\0'; + + ctx.status = 0; + n = snprintf(s+MPD_MAX_PREC+2, 23, "%" PRI_mpd_ssize_t, MPD_SSIZE_MAX); + mpd_set_string(&a, s, &ctx); + if (n > 0 && !(ctx.status&MPD_Malloc_error)) { + t = mpd_to_sci(&a, 1); + ASSERT(strcmp(t, "Infinity") == 0) + ASSERT(ctx.status == (MPD_Inexact|MPD_Overflow|MPD_Rounded)) + mpd_free(t); + + } + + /* .000...0001e184467440737095516161 -> Infinity */ + ctx.status = 0; + s[MPD_MAX_PREC+2] = '\0'; + n = snprintf(s+MPD_MAX_PREC+2, 23, "%s", "184467440737095516161"); + mpd_set_string(&a, s, &ctx); + if (n > 0 && !(ctx.status&MPD_Malloc_error)) { + t = mpd_to_sci(&a, 1); + ASSERT(strcmp(t, "Infinity") == 0) + ASSERT(ctx.status == (MPD_Inexact|MPD_Overflow|MPD_Rounded)) + mpd_free(t); + } + + /* .000...0001e425000000 -> 1 */ + ctx.status = 0; + s[MPD_MAX_PREC+2] = '\0'; + n = snprintf(s+MPD_MAX_PREC+2, 23, "%" PRI_mpd_ssize_t, (mpd_ssize_t)MPD_MAX_EMAX); + mpd_set_string(&a, s, &ctx); + if (n > 0 && !(ctx.status&MPD_Malloc_error)) { + t = mpd_to_sci(&a, 1); + ASSERT(strcmp(t, "1") == 0) + ASSERT(ctx.status == 0) + mpd_free(t); + } + + /* .000...0001e850000000 -> 1 */ + ctx.status = 0; + s[MPD_MAX_PREC+2] = '\0'; + n = snprintf(s+MPD_MAX_PREC+2, 23, "%" PRI_mpd_ssize_t, 2*(mpd_ssize_t)MPD_MAX_EMAX); + mpd_set_string(&a, s, &ctx); + if (n > 0 && !(ctx.status&MPD_Malloc_error)) { + t = mpd_to_sci(&a, 1); + snprintf(buf, BUFSIZE, "1E+%" PRI_mpd_ssize_t, (mpd_ssize_t)MPD_MAX_EMAX); + ASSERT(strcmp(t, buf) == 0) + ASSERT(ctx.status == 0) + mpd_free(t); + } + + /* .000...0005e424999999 -> 0.5 */ + ctx.status = 0; + s[MPD_MAX_PREC] = '5'; + s[MPD_MAX_PREC+1] = 'e'; + s[MPD_MAX_PREC+2] = '\0'; + n = snprintf(s+MPD_MAX_PREC+2, 23, "%" PRI_mpd_ssize_t, (mpd_ssize_t)MPD_MAX_EMAX-1); + mpd_set_string(&a, s, &ctx); + if (n > 0 && !(ctx.status&MPD_Malloc_error)) { + t = mpd_to_sci(&a, 1); + ASSERT(strcmp(t, "0.5") == 0) + ASSERT(ctx.status == 0) + mpd_free(t); + } + + /* .000...0001e-2147483648 -> 0E-849999999 */ + ctx.status = 0; + s[MPD_MAX_PREC] = '1'; + s[MPD_MAX_PREC+1] = 'e'; + s[MPD_MAX_PREC+2] = '\0'; + n = snprintf(s+MPD_MAX_PREC+2, 23, "%" PRI_mpd_ssize_t, MPD_SSIZE_MIN); + mpd_set_string(&a, s, &ctx); + if (n > 0 && !(ctx.status&MPD_Malloc_error)) { + t = mpd_to_sci(&a, 1); + snprintf(buf, BUFSIZE, "0E%" PRI_mpd_ssize_t, mpd_etiny(&ctx)); + ASSERT(strcmp(t, buf) == 0) + ASSERT(ctx.status == (MPD_Subnormal|MPD_Inexact| + MPD_Clamped|MPD_Underflow| + MPD_Rounded)) + mpd_free(t); + } + + /* .000...0001e-184467440737095516161 -> 0E-849999999 */ + ctx.status = 0; + s[MPD_MAX_PREC] = '1'; + s[MPD_MAX_PREC+1] = 'e'; + s[MPD_MAX_PREC+2] = '\0'; + n = snprintf(s+MPD_MAX_PREC+2, 23, "%s", "-184467440737095516161"); + mpd_set_string(&a, s, &ctx); + if (n > 0 && !(ctx.status&MPD_Malloc_error)) { + t = mpd_to_sci(&a, 1); + snprintf(buf, BUFSIZE, "0E%" PRI_mpd_ssize_t, mpd_etiny(&ctx)); + ASSERT(strcmp(t, buf) == 0) + ASSERT(ctx.status == (MPD_Subnormal|MPD_Inexact| + MPD_Clamped|MPD_Underflow| + MPD_Rounded)) + mpd_free(t); + + } + + /* 10000...0000e-425000000 -> 0.1 */ + ctx.status = 0; + s[0] = '1'; + memset(s+1, '0', MPD_MAX_PREC-1); + s[MPD_MAX_PREC] = 'e'; + s[MPD_MAX_PREC+1] = '\0'; + n = snprintf(s+MPD_MAX_PREC+1, 23, "%" PRI_mpd_ssize_t, (mpd_ssize_t)MPD_MIN_EMIN); + mpd_set_string(&a, s, &ctx); + if (n > 0 && !(ctx.status&MPD_Malloc_error)) { + mpd_set_string(&b, "0.1", &ctx); + ASSERT(mpd_cmp(&a, &b, &ctx) == 0) + ASSERT(ctx.status == 0) + } + + /* 10000...0000e-1275000000 -> 1 */ + ctx.status = 0; + s[0] = '1'; + memset(s+1, '0', MPD_MAX_PREC-1); + s[MPD_MAX_PREC] = 'e'; + s[MPD_MAX_PREC+1] = '\0'; + n = snprintf(s+MPD_MAX_PREC+1, 23, "%" PRI_mpd_ssize_t, 3*(mpd_ssize_t)MPD_MIN_EMIN+2); + mpd_set_string(&a, s, &ctx); + if (n > 0 && !(ctx.status&MPD_Malloc_error)) { + t = mpd_to_sci(&a, 1); + snprintf(buf, BUFSIZE, "1E%" PRI_mpd_ssize_t, mpd_etiny(&ctx)); + ASSERT(strcmp(t, buf) == 0) + ASSERT(ctx.status == (MPD_Subnormal|MPD_Rounded)) + mpd_free(t); + } + + /* Too many fraction digits: .000...0001e184467440737095516161 -> NaN */ + s[0] = '.'; + memset(s+1, '0', MPD_MAX_PREC); + s[MPD_MAX_PREC+1] = '1'; + s[MPD_MAX_PREC+2] = 'e'; + + ctx.status = 0; + s[MPD_MAX_PREC+3] = '\0'; + n = snprintf(s+MPD_MAX_PREC+3, 23, "%s", "184467440737095516161"); + mpd_set_string(&a, s, &ctx); + if (n > 0 && !(ctx.status&MPD_Malloc_error)) { + t = mpd_to_sci(&a, 1); + ASSERT(strcmp(t, "NaN") == 0) + ASSERT(ctx.status == MPD_Conversion_syntax) + mpd_free(t); + } + + /* Exactly MPD_MAX_PREC digits */ + ctx.status = 0; + ctx.prec = MPD_MAX_PREC; + memset(s, '9', MPD_MAX_PREC); + s[MPD_MAX_PREC] = '\0'; + mpd_set_string(&a, s, &ctx); + if (!(ctx.status&MPD_Malloc_error)) { + ASSERT(ctx.status == 0) + t = mpd_to_sci(&a, 0); + if (t != NULL) { + ASSERT(strcmp(t, s) == 0) + mpd_free(t); + } + } + + /* Too many digits: 99999...9999 -> NaN */ + ctx.status = 0; + memset(s, '9', MPD_MAX_PREC+1); + s[MPD_MAX_PREC+1] = '\0'; + mpd_set_string(&a, s, &ctx); + if (!(ctx.status&MPD_Malloc_error)) { + ASSERT(ctx.status == MPD_Conversion_syntax) + } + + mpd_del(&a); + mpd_del(&b); + free(s); +} + +static void +test_memory(void) +{ + mpd_context_t ctx; + mpd_uint_t bdata[MPD_MINALLOC_MAX]; + mpd_t b = {MPD_STATIC|MPD_STATIC_DATA, 0, 0, 0, MPD_MINALLOC_MAX, bdata}; + mpd_t *a; + + mpd_testcontext(&ctx); + ctx.traps = 0; + + /* Allocation failures */ + ctx.status = 0; + a = mpd_new(&ctx); + mpd_set_alloc_fail(&ctx); + mpd_resize(a, 20, &ctx); + mpd_set_alloc(&ctx); + ASSERT(ctx.status & MPD_Malloc_error) + ASSERT(mpd_isnan(a)) + mpd_del(a); + + ctx.status = 0; + mpd_set_alloc_fail(&ctx); + mpd_resize_zero(&b, MPD_MINALLOC_MAX+1, &ctx); + mpd_set_alloc(&ctx); + ASSERT(ctx.status & MPD_Malloc_error) + ASSERT(mpd_isnan(&b)) + + for (alloc_fail = 1; alloc_fail <= 10; alloc_fail++) { + ctx.status = 0; + + mpd_set_alloc_fail(&ctx); + a = mpd_new(&ctx); + mpd_set_alloc(&ctx); + + if (!(ctx.status & MPD_Malloc_error)) { + mpd_del(a); + break; + } + ASSERT(a == NULL) + } + ASSERT(alloc_fail == 3) + +#if MPD_SIZE_MAX < SIZE_MAX +{ + char *s; + s = mpd_callocfunc_em((size_t)MPD_SIZE_MAX+1, 16); + ASSERT(s == NULL) + s = mpd_callocfunc_em(16, (size_t)MPD_SIZE_MAX+1); + ASSERT(s == NULL) +} +#endif + + mpd_del(&b); +} + +static void +test_output(void) +{ + uint32_t status; + mpd_context_t ctx; + mpd_uint_t adata[MPD_MINALLOC_MAX]; + mpd_t a = {MPD_STATIC|MPD_STATIC_DATA, 0, 0, 0, MPD_MINALLOC_MAX, adata}; + FILE *fp; + char buf[BUFSIZE]; + char *s; + int n; + + mpd_testcontext(&ctx); + ctx.traps = 0; + + /* printing of flags and signals */ + status = MPD_Max_status; + + s = "Clamped Conversion_syntax Division_by_zero Division_impossible " + "Division_undefined Fpu_error Inexact Invalid_context Invalid_operation " + "Malloc_error Not_implemented Overflow Rounded Subnormal Underflow"; + + n = mpd_snprint_flags(buf, BUFSIZE, status); + ASSERT(n > 0 && (size_t)n == strlen(s)) + ASSERT(strcmp(buf, s) == 0) + + s = "[Clamped, Conversion_syntax, Division_by_zero, Division_impossible, " + "Division_undefined, Fpu_error, Inexact, Invalid_context, Invalid_operation, " + "Malloc_error, Not_implemented, Overflow, Rounded, Subnormal, Underflow]"; + + n = mpd_lsnprint_flags(buf, BUFSIZE, status, NULL); + ASSERT(n > 0 && (size_t)n == strlen(s)) + ASSERT(strcmp(buf, s) == 0) + + s = "[Clamped, IEEE_Invalid_operation, Division_by_zero, Inexact, " + "Not_implemented, Overflow, Rounded, Subnormal, Underflow]"; + + n = mpd_lsnprint_signals(buf, BUFSIZE, status, NULL); + ASSERT(n > 0 && (size_t)n == strlen(s)) + ASSERT(strcmp(buf, s) == 0) + + /* simple printing to file */ + if ((fp = tmpfile()) != NULL) { + mpd_set_string(&a, "1.23456789e441", &ctx); + mpd_fprint(fp, &a); + rewind(fp); + if (fgets(buf, BUFSIZE, fp) != NULL) { + ASSERT(strcmp(buf, "1.23456789e441\n")) + } + fclose(fp); + } + + /* simple printing to stdout */ + mpd_set_string(&a, "1.23456789e441", &ctx); + printf(" This line is part of the coverage test: "); + mpd_print(&a); + + /* mpd_qformat_spec */ + + /* min_width > MPD_MAX_PREC */ + ctx.status = 0; + ctx.prec = MPD_MAX_PREC; + mpd_set_string(&a, "1.23456789e441", &ctx); + snprintf(buf, BUFSIZE, "%" PRI_mpd_ssize_t ".10", (mpd_ssize_t)MPD_MAX_PREC+1); + s = mpd_format(&a, buf, &ctx); + ASSERT(s == NULL && (ctx.status&MPD_Invalid_operation)) + + mpd_del(&a); +} + +static sig_atomic_t sigfpe_raised = 0; +void +sigfpe_handler(int signum) +{ + (void)signum; + sigfpe_raised = 1; +} + +static void +test_misc(void) +{ + mpd_context_t ctx; + mpd_uint_t adata[MPD_MINALLOC_MAX]; + mpd_uint_t bdata[MPD_MINALLOC_MAX]; + mpd_t a = {MPD_STATIC|MPD_STATIC_DATA, 0, 0, 0, MPD_MINALLOC_MAX, adata}; + mpd_t b = {MPD_STATIC|MPD_STATIC_DATA, 0, 0, 0, MPD_MINALLOC_MAX, bdata}; + char buf[BUFSIZE]; + char *s, *t; + + mpd_testcontext(&ctx); + ctx.traps = 0; + + /* signcpy */ + mpd_set_string(&b, "3", &ctx); + mpd_signcpy(&b, &a); + s = mpd_to_sci(&b, 0); + ASSERT(strcmp(s, "-3")) + mpd_free(s); + + /* maxcoeff */ + ctx.prec = 28; + ctx.status = 0; + mpd_set_string(&a, "1e2025", &ctx); + mpd_maxcoeff(&a, &ctx); + s = mpd_to_sci(&a, 0); + ASSERT(strcmp(s, "9999999999999999999999999999e2025")) + ASSERT(ctx.status == 0) + mpd_free(s); + + /* canonical */ + ctx.status = 0; + mpd_set_string(&a, "1.182736812e999999", &ctx); + mpd_canonical(&b, &a, &ctx); + s = mpd_to_sci(&a, 0); + t = mpd_to_sci(&b, 0); + ASSERT(strcmp(s, t) == 0) + ASSERT(ctx.status == 0) + mpd_free(s); + mpd_free(t); + + /* mpd_msword */ + mpd_set_string(&a, "2.3854727e+1875", &ctx); + ASSERT(mpd_msd(mpd_msword(&a)) == 2) + + /* mpd_radix */ + ASSERT(mpd_radix() == 10) + + /* rescale, greater than emax */ + ctx.status = 0; + mpd_set_string(&a, "3.3", &ctx); + mpd_rescale(&a, &a, MPD_MAX_EMAX+1, &ctx); + s = mpd_to_sci(&a, 1); + ASSERT(strcmp(s, "NaN") == 0) + ASSERT(ctx.status == MPD_Invalid_operation) + mpd_free(s); + + /* CONFIG_64: Over/Underflow in power */ + ctx.status = 0; + mpd_set_string(&a, "1.000000001", &ctx); + mpd_set_string(&b, "12345676891234567891123456789", &ctx); + mpd_pow(&a, &a, &b, &ctx); + s = mpd_to_sci(&a, 0); + ASSERT(strcmp(s, "Infinity") == 0) + ASSERT(ctx.status == (MPD_Rounded|MPD_Overflow|MPD_Inexact)) + mpd_free(s); + + ctx.status = 0; + mpd_set_string(&a, "1.000000001", &ctx); + mpd_set_string(&b, "-12345676891234567891123456789", &ctx); + mpd_pow(&a, &a, &b, &ctx); + s = mpd_to_sci(&a, 1); + snprintf(buf, BUFSIZE, "0E%" PRI_mpd_ssize_t, mpd_etiny(&ctx)); + ASSERT(strcmp(s, buf) == 0) + ASSERT(ctx.status == (MPD_Underflow|MPD_Rounded|MPD_Clamped|MPD_Inexact|MPD_Subnormal)) + mpd_free(s); + + ctx.status = 0; + mpd_set_string(&a, "2.2122163", &ctx); + mpd_set_string(&b, "2899999999999999999.891239129", &ctx); + mpd_pow(&a, &a, &b, &ctx); + s = mpd_to_sci(&a, 0); + ASSERT(strcmp(s, "Infinity") == 0) + ASSERT(ctx.status == (MPD_Rounded|MPD_Overflow|MPD_Inexact)) + mpd_free(s); + +#ifdef CONFIG_32 + /* Allocation failure in mpd_set_u64 */ + mpd_resize(&a, MPD_MINALLOC_MAX+1, &ctx); + mpd_minalloc(&a); + + ctx.status = 0; + mpd_set_alloc_fail(&ctx); + mpd_set_u64(&a, UINT64_MAX, &ctx); + mpd_set_alloc(&ctx); + + ASSERT(ctx.status & MPD_Malloc_error) + ASSERT(mpd_isnan(&a)) +#endif + + /* Default trap handler: SIGFPE */ + signal(SIGFPE, sigfpe_handler); + ctx.traps = MPD_Rounded; + mpd_set_string(&a, "1", &ctx); + ASSERT(sigfpe_raised == 0) + mpd_div_uint(&a, &a, 7, &ctx); + ASSERT(sigfpe_raised == 1) + + mpd_del(&a); + mpd_del(&b); +} + + +int +main(void) +{ + srand((unsigned int)time(NULL)); + fprintf(stderr, "Running cov ... \n\n"); + + /* context.c */ + test_context(); /* Run this first! */ + + /* mpdecimal.c */ + test_check_nans(); + test_finalize_round(); + test_attributes(); + + test_int_conversions(); + test_mixed_arith(); + test_shift(); + test_baseconv(); + test_misc(); + + /* memory.c */ + test_memory(); + + /* io.c */ + test_set_string(); + test_output(); + + /* Valgrind */ + mpd_del(&mpd_ln10); + + fprintf(stderr, "\ncov: PASS\n"); + return 0; +} + + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/tests/covreport.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/tests/covreport.py Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,120 @@ +#!/usr/bin/python + +import os +from glob import glob +from collections import defaultdict + + +# +# gcov *.c is buggy, so getting a nice coverage report for .h files +# requires more steps: +# +# (1) for file in *.c; do gcov -l $file; done +# +# (2) generate a cumulative coverage for each .h file +# +# Tested with gcc/gcov 4.4.3. +# + +NOCOV_EXPECTED = ['constants.c', 'bench.c'] + + +def update_count(line, results): + first, rest = line.split(':', 1) + first = first.lstrip() + try: + results['count'] += int(first) + except ValueError: + results[first] += 1 + return first, rest + + +d = defaultdict(list) +for filename in glob("*##*.h.gcov"): + k = filename.split('##')[1] + d[k].append(filename) + +for outfile, lst in d.items(): + files = [open(x) for x in lst] + out = open(outfile, "w") + for line in files[0]: + results = {'-': 0, '#####': 0, 'count': 0} + first, rest = update_count(line, results) + for f in files[1:]: + fst, rst = update_count(f.readline(), results) + if rst != rest and not 'gcda' in rest and not 'gcno' in rest \ + and not ':Runs:' in rest and not ':Programs:' in rest: + print(line.rstrip(), rst.rstrip(), rest.rstrip()) + if results['count'] > 0: + first = results['count'] + elif results['#####'] > 0: + first = '#####' + else: + first = '-' + first = format(str(first), ">10.10") + out.write(':'.join((first, rest))) + out.close() + for f in files: + f.close() + + +def update_total(line, results): + first, rest = line.split(':', 1) + first = first.lstrip() + try: + int(first) + results['count'] += 1 + except ValueError: + if 'GCOV_NOT_REACHED' in rest: + results['not_reached'] += 1 + elif 'GCOV_UNLIKELY' in rest: + results['unlikely'] += 1 + else: + #if '####' in first: + # print(first, rest) + results[first] += 1 + return first, rest + +print("\n%19s%19s%19s%19s\n" % + ("file name:", "lines:", "not executed:", "unaccounted for:")) + +for filename in glob("*.h.gcov"): + if '##' in filename: continue + with open(filename) as f: + results = {'-': 0, '#####': 0, 'not_reached': 0, 'unlikely': 0, + 'count': 0} + for line in f: + update_total(line, results) + print("%19s%19d%19d%19d" % (filename.split('.gcov')[0], results['count'], + results['not_reached']+results['unlikely']+ + results['#####'], results['#####'])) + +print("") + +for filename in glob("*.c.gcov"): + if '##' in filename: continue + with open(filename) as f: + results = {'-': 0, '#####': 0, 'not_reached': 0, 'unlikely': 0, 'count': 0} + for line in f: + update_total(line, results) + print("%19s%19d%19d%19d" % (filename.split('.gcov')[0], results['count'], + results['not_reached']+results['unlikely']+ + results['#####'], results['#####'])) + +print("\n\n%19s\n" % "no coverage:") + +for filename in glob("*.h"): + s = filename + '.gcov' + if not os.path.isfile(s): + with open(filename) as f: + for line in f: + if 'static inline' in line: + print("%19s" % filename) + break + +for filename in glob("*.c"): + s = filename + '.gcov' + if not os.path.isfile(s) and not filename in NOCOV_EXPECTED: + print("%19s" % filename) + +print("") diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/tests/fntcov.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/tests/fntcov.c Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,375 @@ +/* + * Copyright (c) 2008-2010 Stefan Krah. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + + +#include +#include +#include +#include "mpdecimal.h" +#include "mptypes.h" +#include "mptest.h" +#include "malloc_fail.h" + + +/* + * Code coverage for _mpd_fntmul, _mpd_kmul, and _mpd_kmul_fnt. Since + * _mpd_kmul_fnt is only triggered for a result length that exceeds + * 3*MPD_MAXTRANSFORM_2N, the final tests require substantial amounts + * of RAM. + * + * For CONFIG_32, 4-8GB are required, This means that the tests will + * run comfortably on a 64-bit 8GB machine if the compile option + * MACHINE=full_coverage is chosen. + * + * For CONFIG_64, about 1TB of memory would be needed. + */ + + +#ifndef _MSC_VER + #define ASSERT(p) if (!(p)) {abort();} +#else + #define ASSERT(p) if (!(p)) {mpd_err_fatal("assertion failed");} +#endif + +#define MAXWORDS 10000 + + +int +main(void) +{ + uint32_t status = 0; + mpd_context_t ctx; + mpd_uint_t *a, *b; + mpd_uint_t *fntresult, *kresult, *kfntresult; + mpd_size_t rsize; + mpd_t *x, *y, *z; + mpd_ssize_t xl[5] = {MPD_MAXTRANSFORM_2N, 2*MPD_MAXTRANSFORM_2N, + 4*MPD_MAXTRANSFORM_2N, 4*MPD_MAXTRANSFORM_2N-1, + 4*MPD_MAXTRANSFORM_2N-1}; + mpd_ssize_t yl[5] = {MPD_MAXTRANSFORM_2N/2, MPD_MAXTRANSFORM_2N, + 2*MPD_MAXTRANSFORM_2N, 2*MPD_MAXTRANSFORM_2N, + 32}; + mpd_ssize_t k, alen, blen; + mpd_ssize_t xlen, ylen; + time_t seed; + int i; + + + mpd_maxcontext(&ctx); + + a = malloc(MAXWORDS * (sizeof *a)); + b = malloc(MAXWORDS * (sizeof *b)); + + for (k = 0; k < MAXWORDS; k++) { + a[k] = MPD_RADIX-1; + } + for (k = 0; k < MAXWORDS; k++) { + b[k] = MPD_RADIX-1; + } + + fprintf(stderr, "Running fntcov ... \n\n"); + fprintf(stderr, " Testing Karatsuba multiplication and number " + "theoretic transform ... "); + + /* bignum: all digits 9 */ + for (alen = 1200; alen < MAXWORDS; alen += 1000) { + + fntresult = _mpd_fntmul(a, a, alen, alen, &rsize); + kresult = _mpd_kmul(a, a, alen, alen, &rsize); + kfntresult = _mpd_kmul_fnt(a, a, alen, alen, &rsize); + + for (k = 0; k < 2*alen; k++) { + if (kresult[k] != fntresult[k] || kfntresult[k] != fntresult[k]) { + fprintf(stderr, " FAIL\n"); + exit(1); + } + } + + mpd_free(fntresult); + mpd_free(kresult); + mpd_free(kfntresult); + + for (blen = 1200; blen <= alen; blen += 1000) { + + fntresult = _mpd_fntmul(a, b, alen, blen, &rsize); + kresult = _mpd_kmul(a, b, alen, blen, &rsize); + kfntresult = _mpd_kmul_fnt(a, b, alen, blen, &rsize); + + for (k = 0; k < alen+blen; k++) { + if (kresult[k] != fntresult[k] || kfntresult[k] != fntresult[k]) { + fprintf(stderr, " FAIL\n"); + exit(1); + } + } + + mpd_free(fntresult); + mpd_free(kresult); + mpd_free(kfntresult); + } + } + + /* Bignum: random test */ + seed = time(NULL); + srandom((unsigned int)seed); + + for (alen = 1200; alen < MAXWORDS; alen += 1000) { + + for (k = 0; k < alen; k++) { + a[k] = random()%MPD_RADIX; + } + + fntresult = _mpd_fntmul(a, a, alen, alen, &rsize); + kresult = _mpd_kmul(a, a, alen, alen, &rsize); + kfntresult = _mpd_kmul_fnt(a, a, alen, alen, &rsize); + + for (k = 0; k < 2*alen; k++) { + if (kresult[k] != fntresult[k] || kfntresult[k] != fntresult[k]) { + fprintf(stderr, " FAIL: seed = %"PRI_time_t"\n", seed); + exit(1); + } + } + + mpd_free(fntresult); + mpd_free(kresult); + mpd_free(kfntresult); + + for (blen = 1200; blen <= alen; blen += 1000) { + + for (k = 0; k < blen; k++) { + b[k] = random()%MPD_RADIX; + } + + fntresult = _mpd_fntmul(a, b, alen, blen, &rsize); + kresult = _mpd_kmul(a, b, alen, blen, &rsize); + kfntresult = _mpd_kmul_fnt(a, b, alen, blen, &rsize); + + for (k = 0; k < alen+blen; k++) { + if (kresult[k] != fntresult[k] || kfntresult[k] != fntresult[k]) { + fprintf(stderr, " FAIL: seed = %"PRI_time_t"\n", seed); + exit(1); + } + } + + mpd_free(fntresult); + mpd_free(kresult); + mpd_free(kfntresult); + } + } + + /* Excessive lengths */ + fntresult = _mpd_fntmul(a, a, 2*MPD_MAXTRANSFORM_2N, 2*MPD_MAXTRANSFORM_2N, + &rsize); + ASSERT(fntresult == NULL) + + /* Allocation failures */ + for (alen=500, blen = 500; alen <= 4000; alen+=3500, blen+=1500) { + + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + + mpd_set_alloc_fail(&ctx); + fntresult = _mpd_fntmul(a, a, alen, alen, &rsize); + mpd_set_alloc(&ctx); + + if (fntresult != NULL) { + mpd_free(fntresult); + if (alloc_idx < alloc_fail) { + break; + } + } + } + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + + mpd_set_alloc_fail(&ctx); + fntresult = _mpd_fntmul(a, b, alen, blen, &rsize); + mpd_set_alloc(&ctx); + + if (fntresult != NULL) { + mpd_free(fntresult); + if (alloc_idx < alloc_fail) { + break; + } + } + } + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + + mpd_set_alloc_fail(&ctx); + kresult = _mpd_kmul(a, a, alen, alen, &rsize); + mpd_set_alloc(&ctx); + + if (kresult != NULL) { + mpd_free(kresult); + if (alloc_idx < alloc_fail) { + break; + } + } + } + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + + mpd_set_alloc_fail(&ctx); + kresult = _mpd_kmul(a, b, alen, blen, &rsize); + mpd_set_alloc(&ctx); + + if (kresult != NULL) { + mpd_free(kresult); + if (alloc_idx < alloc_fail) { + break; + } + } + } + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + + mpd_set_alloc_fail(&ctx); + kfntresult = _mpd_kmul_fnt(a, a, alen, alen, &rsize); + mpd_set_alloc(&ctx); + + if (kfntresult != NULL) { + mpd_free(kfntresult); + if (alloc_idx < alloc_fail) { + break; + } + } + } + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + + mpd_set_alloc_fail(&ctx); + kfntresult = _mpd_kmul_fnt(a, b, alen, blen, &rsize); + mpd_set_alloc(&ctx); + + if (kfntresult != NULL) { + mpd_free(kfntresult); + if (alloc_idx < alloc_fail) { + break; + } + } + } + } + + mpd_free(a); + mpd_free(b); + + + /* Huge numbers */ + fprintf(stderr, "\n\n Long test, requires more than 4GB of memory ... \n\n"); + + x = mpd_new(&ctx); + y = mpd_new(&ctx); + z = mpd_new(&ctx); + + ctx.traps = 0; + /* NOT safe, but works for this test. */ + ctx.emax = MPD_SSIZE_MAX; + ctx.prec = MPD_SSIZE_MAX; + for (i = 0; i < 5; i++) { + + xlen = xl[i]; + ylen = yl[i]; + fprintf(stderr, " op1: %11"PRI_mpd_ssize_t" words op2: " + "%11"PRI_mpd_ssize_t" words\n", xlen, ylen); + + if (!mpd_qresize(x, xlen, &status)) { + goto malloc_error; + } + for (k = 0; k < xlen; k++) { + x->data[k] = MPD_RADIX-1; + } + x->len = xlen; + x->exp = 0; + mpd_setdigits(x); + + if (!mpd_qresize(y, ylen, &status)) { + goto malloc_error; + } + for (k = 0; k < ylen; k++) { + y->data[k] = MPD_RADIX-1; + } + y->len = ylen; + y->exp = 0; + mpd_setdigits(y); + + ctx.status = 0; + mpd_mul(z, x, y, &ctx); + if (mpd_isnan(z)) { + ASSERT(ctx.status&MPD_Malloc_error); + goto malloc_error; + } + + ASSERT(z->data[0] == 1) + for (k = 1; k < ylen; k++) { + ASSERT(z->data[k] == 0) + } + for (; k < xlen; k++) { + ASSERT(z->data[k] == MPD_RADIX-1); + } + ASSERT(z->data[k] == MPD_RADIX-2) + k++; + for (; k < xlen+ylen; k++) { + ASSERT(z->data[k] == MPD_RADIX-1); + } + +#if 0 + /* Allocation failures: Only reasonable to test with an + * artificially small MPD_MAXTRANSFORM_2N. For example, + * with MPD_MAXTRANSFORM_2N=4096 coverage of _mpd_kmul_fnt + * is 100%, i.e. also lines tagged with GCOV_UNLIKELY are + * reached. + */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + ctx.status = 0; + + mpd_set_alloc_fail(&ctx); + mpd_mul(z, x, y, &ctx); + mpd_set_alloc(&ctx); + + if (!(ctx.status&MPD_Malloc_error)) { + if (alloc_idx < alloc_fail) { + printf("alloc_idx: %d\n", alloc_idx); + break; + } + } + else { + ASSERT(mpd_isnan(z)); + } + } +#endif + } + + fprintf(stderr, "\nfntcov: PASS\n\n"); + +out: + mpd_del(x); + mpd_del(y); + mpd_del(z); + return 0; + + +malloc_error: + fprintf(stderr, "\nfntcov: out of memory: this test requires large " + "amounts of memory\n\n"); + goto out; +} + + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/tests/fullcov_header.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/tests/fullcov_header.patch Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,25 @@ +--- a/mpdecimal.h 2010-11-15 12:28:32.000000000 +0100 ++++ b/mpdecimal.h 2010-11-15 12:30:04.000000000 +0100 +@@ -110,8 +110,9 @@ + typedef uint64_t mpd_uuint_t; /* double width unsigned mod type */ + #endif + +-#define MPD_SIZE_MAX SIZE_MAX +-typedef size_t mpd_size_t; /* unsigned size type */ ++/* enable CONFIG_32+ANSI on 64-bit platforms without resorting to -m32 */ ++#define MPD_SIZE_MAX UINT32_MAX ++typedef uint32_t mpd_size_t; /* unsigned size type */ + + /* type for dec->len, dec->exp, ctx->prec */ + #define MPD_SSIZE_MAX INT32_MAX +@@ -139,8 +140,8 @@ + /* END CONFIG_32 */ + + +-#if MPD_SIZE_MAX != MPD_UINT_MAX +- #error "unsupported platform: need mpd_size_t == mpd_uint_t" ++#if SIZE_MAX < MPD_SIZE_MAX ++ #error "unsupported platform: need size_t >= mpd_size_t" + #endif + + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/tests/gettests.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/tests/gettests.bat Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,4 @@ +@ECHO OFF +if not exist testdata mkdir testdata +if not exist testdata\add.decTest copy /y ..\..\decimaltestdata\* testdata && move testdata\randomBound32.decTest testdata\randombound32.decTest && move testdata\remainderNear.decTest testdata\remaindernear.decTest +if not exist testdata\baseconv.decTest copy /y testdata_dist\* testdata diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/tests/gettests.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/tests/gettests.sh Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,16 @@ +#!/bin/sh + +if ! [ -d testdata ]; then + mkdir testdata +fi + +if ! [ -f testdata/add.decTest ]; then + cp ../../decimaltestdata/* testdata + mv testdata/randomBound32.decTest testdata/randombound32.decTest + mv testdata/remainderNear.decTest testdata/remaindernear.decTest +fi + +if ! [ -f testdata/baseconv.decTest ]; then + cp testdata_dist/* testdata +fi + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/tests/karatsuba_fnt.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/tests/karatsuba_fnt.c Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2008-2010 Stefan Krah. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + + +#include +#include +#include +#include "mpdecimal.h" +#include "mptypes.h" +#include "mptest.h" + + +/* + * Test Karatsuba multiplication against FNT multiplication. + */ + + +#define WORDS 1200 + + +int +main(int argc, char **argv) +{ + mpd_uint_t *a, *b; + mpd_uint_t *fntresult, *kresult; + mpd_size_t alen, blen, k; + double total = (WORDS-1)*(WORDS)-12; + double counter = 0; + mpd_size_t rsize; + time_t seed; + int verbose; + + verbose = !(argc > 1 && strcmp(argv[1], "-q") == 0); + + a = malloc(WORDS * (sizeof *a)); + b = malloc(WORDS * (sizeof *b)); + + for (k = 0; k < WORDS; k++) { + a[k] = MPD_RADIX-1; + } + for (k = 0; k < WORDS; k++) { + b[k] = MPD_RADIX-1; + } + + if (!verbose) { + fprintf(stderr, "%s ... ", argv[0]); + } + + /* test with all digits 9 */ + for (alen = 4; alen < WORDS; alen++) { + + if (verbose) { + fprintf(stderr, "\r%s: progress: %2.4f%%", + argv[0], (counter/total*100)); + } + + for (blen = 1; blen <= alen; blen++) { + + counter++; + + fntresult = _mpd_fntmul(a, b, alen, blen, &rsize); + kresult = _mpd_kmul(a, b, alen, blen, &rsize); + + for (k = 0; k < alen+blen; k++) { + if (kresult[k] != fntresult[k]) { + fprintf(stderr, " FAIL\n"); + exit(1); + } + } + + mpd_free(fntresult); + mpd_free(kresult); + } + } + + /* random test */ + seed = time(NULL); + srandom((unsigned int)seed); + + for (alen = 4; alen < WORDS; alen++) { + + if (verbose) { + fprintf(stderr, "\r%s: progress: %2.4f%%", argv[0], + (counter/total*100)); + } + + for (k = 0; k < alen; k++) { + a[k] = random()%MPD_RADIX; + } + + for (blen = 1; blen <= alen; blen++) { + + counter++; + + for (k = 0; k < blen; k++) { + b[k] = random()%MPD_RADIX; + } + + fntresult = _mpd_fntmul(a, b, alen, blen, &rsize); + kresult = _mpd_kmul(a, b, alen, blen, &rsize); + + for (k = 0; k < alen+blen; k++) { + if (kresult[k] != fntresult[k]) { + fprintf(stderr, " FAIL: seed = %"PRI_time_t"\n", seed); + exit(1); + } + } + + mpd_free(fntresult); + mpd_free(kresult); + } + } + + if (verbose) { + fprintf(stderr, "\r%s: progress: %2.4f%%", argv[0], 100.0); + } + fprintf(stderr, " PASS\n"); + + mpd_free(a); + mpd_free(b); + + return 0; +} + + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/tests/karatsuba_fnt2.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/tests/karatsuba_fnt2.c Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2008-2010 Stefan Krah. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + + +#include +#include +#include +#include "mpdecimal.h" +#include "mptypes.h" +#include "mptest.h" + + +/* + * Test Karatsuba multiplication with FNT basecase against + * FNT multiplication. + */ + + +#define WORDS 1200 + + +int +main(int argc, char **argv) +{ + mpd_uint_t *a, *b; + mpd_uint_t *fntresult, *kresult; + mpd_size_t alen, blen, k; + double total = (WORDS-1)*(WORDS)-12; + double counter = 0; + mpd_size_t rsize; + time_t seed; + int verbose; + + verbose = !(argc > 1 && strcmp(argv[1], "-q") == 0); + + a = malloc(WORDS * (sizeof *a)); + b = malloc(WORDS * (sizeof *b)); + + for (k = 0; k < WORDS; k++) { + a[k] = MPD_RADIX-1; + } + for (k = 0; k < WORDS; k++) { + b[k] = MPD_RADIX-1; + } + + if (!verbose) { + fprintf(stderr, "%s ... ", argv[0]); + } + + /* test with all digits 9 */ + for (alen = 4; alen < WORDS; alen++) { + + if (verbose) { + fprintf(stderr, "\r%s: progress: %2.4f%%", argv[0], + (counter/total*100)); + } + + for (blen = 1; blen <= alen; blen++) { + + counter++; + + fntresult = _mpd_fntmul(a, b, alen, blen, &rsize); + kresult = _mpd_kmul_fnt(a, b, alen, blen, &rsize); + + for (k = 0; k < alen+blen; k++) { + if (kresult[k] != fntresult[k]) { + fprintf(stderr, " FAIL\n"); + exit(1); + } + } + + mpd_free(fntresult); + mpd_free(kresult); + } + } + + /* random test */ + seed = time(NULL); + srandom((unsigned int)seed); + + for (alen = 4; alen < WORDS; alen++) { + + if (verbose) { + fprintf(stderr, "\r%s: progress: %2.4f%%", argv[0], + (counter/total*100)); + } + + for (k = 0; k < alen; k++) { + a[k] = random()%MPD_RADIX; + } + + for (blen = 1; blen <= alen; blen++) { + + counter++; + + for (k = 0; k < blen; k++) { + b[k] = random()%MPD_RADIX; + } + + fntresult = _mpd_fntmul(a, b, alen, blen, &rsize); + kresult = _mpd_kmul_fnt(a, b, alen, blen, &rsize); + + for (k = 0; k < alen+blen; k++) { + if (kresult[k] != fntresult[k]) { + fprintf(stderr, " FAIL: seed = %"PRI_time_t"\n", seed); + exit(1); + } + } + + mpd_free(fntresult); + mpd_free(kresult); + } + } + + if (verbose) { + fprintf(stderr, "\r%s: progress: %2.4f%%", argv[0], 100.0); + } + fprintf(stderr, " PASS\n"); + + mpd_free(a); + mpd_free(b); + + return 0; +} + + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/tests/malloc_fail.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/tests/malloc_fail.c Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,99 @@ +#include +#include "mpdecimal.h" +#include "malloc_fail.h" + + +/* Test allocation failures */ +int alloc_count; +int alloc_fail; +int alloc_idx; + +void * +mpd_malloc_count(size_t size) +{ + ++alloc_count; + return malloc(size); +} + +void * +mpd_calloc_count(size_t nmemb, size_t size) +{ + ++alloc_count; + return calloc(nmemb, size); +} + +void * +mpd_realloc_count(void *ptr, size_t size) +{ + ++alloc_count; + return realloc(ptr, size); +} + + +void * +mpd_malloc_fail(size_t size) +{ + + if (++alloc_idx >= alloc_fail) { + return NULL; + } + return malloc(size); +} + +void * +mpd_calloc_fail(size_t nmemb, size_t size) +{ + if (++alloc_idx >= alloc_fail) { + return NULL; + } + if (rand()%2) { + return calloc(nmemb, size); + } + else { + return mpd_callocfunc_em(nmemb, size); + } +} + +void * +mpd_realloc_fail(void *ptr, size_t size) +{ + if (++alloc_idx >= alloc_fail) { + return NULL; + } + return realloc(ptr, size); +} + +void +mpd_set_alloc_count(mpd_context_t *ctx) +{ + mpd_mallocfunc = mpd_malloc_count; + mpd_callocfunc = mpd_calloc_count; + mpd_reallocfunc = mpd_realloc_count; + + ctx->traps = MPD_Malloc_error; + alloc_count = 0; +} + +void +mpd_set_alloc_fail(mpd_context_t *ctx) +{ + mpd_mallocfunc = mpd_malloc_fail; + mpd_callocfunc = mpd_calloc_fail; + mpd_reallocfunc = mpd_realloc_fail; + + ctx->traps = 0; + alloc_idx = 0; +} + +void +mpd_set_alloc(mpd_context_t *ctx) +{ + mpd_mallocfunc = malloc; + mpd_callocfunc = (rand()%2) ? calloc : mpd_callocfunc_em; + mpd_reallocfunc = realloc; + + ctx->traps = MPD_Malloc_error; +} + + + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/tests/malloc_fail.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/tests/malloc_fail.h Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,24 @@ +#ifndef MALLOC_FAIL_H +#define MALLOC_FAIL_H + + +#include + +extern int alloc_count; +extern int alloc_fail; +extern int alloc_idx; +void *mpd_malloc_count(size_t size); +void *mpd_calloc_count(size_t nmemb, size_t size); +void *mpd_realloc_count(void *ptr, size_t size); +void *mpd_malloc_fail(size_t size); +void *mpd_calloc_fail(size_t nmemb, size_t size); +void *mpd_realloc_fail(void *ptr, size_t size); + +void mpd_set_alloc_count(mpd_context_t *ctx); +void mpd_set_alloc_fail(mpd_context_t *ctx); +void mpd_set_alloc(mpd_context_t *ctx); + + +#endif + + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/tests/mpd_mpz_add.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/tests/mpd_mpz_add.c Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2008-2010 Stefan Krah. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + + +#include +#include +#include +#include +#include +#include "mpdecimal.h" +#include "mptypes.h" + + +/* + * Test mpd_add against mpz_add, for all possible lengths + * (in decimal digits) from 1x1 upto (WORDS*MPD_RDIGITS)x(WORDS*MPD_RDIGITS). + */ + + +#define WORDS 80 + + +int +main(int argc, char **argv) +{ + mpd_context_t ctx; + mpd_t *a, *b, *c; + mpz_t x, y, z; + mpd_ssize_t ma; + char *mpdresult, *mpzresult; + char *s; + size_t alen, blen, k; + double total = (WORDS*MPD_RDIGITS)*(WORDS*MPD_RDIGITS)*63; + double counter = 0; + time_t seed; + int verbose; + + verbose = !(argc > 1 && strcmp(argv[1], "-q") == 0); + + mpd_maxcontext(&ctx); + s = malloc(WORDS*MPD_RDIGITS+1); + seed = time(NULL); + srandom((unsigned int)seed); + + if (!verbose) { + fprintf(stderr, "%s ... ", argv[0]); + } + + for (ma = MPD_MINALLOC_MIN; ma <= MPD_MINALLOC_MAX; ma++) { + + /* DON'T do this in a real program. You have to be sure + * that no previously allocated decimals will ever be used. */ + MPD_MINALLOC = ma; + + a = mpd_new(&ctx); + b = mpd_new(&ctx); + c = mpd_new(&ctx); + mpz_init(x); + mpz_init(y); + mpz_init(z); + + for (alen = 1; alen <= WORDS*MPD_RDIGITS; alen++) { + + if (verbose) { + fprintf(stderr, "\r%s: progress: %2.4f%%", argv[0], + (counter/total*100)); + } + + for (k = 0; k < alen; k++) { + s[k] = '0' + random()%10; + } + s[k] = '\0'; + mpd_set_string(a, s, &ctx); + mpz_set_str(x, s, 10); + + for (blen = 1; blen <= WORDS*MPD_RDIGITS; blen++) { + + counter++; + + for (k = 0; k < blen; k++) { + s[k] = '0' + random()%10; + } + s[k] = '\0'; + + mpd_set_string(b, s, &ctx); + mpz_set_str(y, s, 10); + + mpd_add(c, a, b, &ctx); + mpdresult = mpd_to_sci(c, 1); + + mpz_add(z, x, y); + mpzresult = mpz_get_str(NULL, 10, z); + + if (strcmp(mpzresult, mpdresult) != 0) { + fprintf(stderr, " FAIL: seed = %"PRI_time_t"\n", seed); + exit(1); + } + + mpd_free(mpdresult); + mpd_free(mpzresult); + } + } + + mpd_del(a); + mpd_del(b); + mpd_del(c); + mpz_clear(x); + mpz_clear(y); + mpz_clear(z); + } + + free(s); + if (verbose) { + fprintf(stderr, "\r%s: progress: %2.4f%%", argv[0], 100.0); + } + fprintf(stderr, " PASS\n"); + + return 0; +} + + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/tests/mpd_mpz_divmod.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/tests/mpd_mpz_divmod.c Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2008-2010 Stefan Krah. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + + +#include +#include +#include +#include +#include +#include "mpdecimal.h" +#include "mptypes.h" + + +/* + * Test mpd_divmod against mpz_fdiv_qr, for all possible lengths + * (in decimal digits) from 1x1 upto (WORDS*MPD_RDIGITS)x(WORDS*MPD_RDIGITS). + */ + + +#define WORDS 80 + + +int +main(int argc, char **argv) +{ + mpd_context_t ctx; + mpd_t *a, *b, *qd, *rd; + mpz_t x, y, qz, rz; + mpd_ssize_t ma; + char *q_mpd, *r_mpd; + char *q_mpz, *r_mpz; + char *s; + size_t alen, blen, k; + double total = (WORDS*MPD_RDIGITS-1)*((WORDS*MPD_RDIGITS)/2)*63; + double counter = 0; + int have_nonzero; + time_t seed; + int verbose; + + verbose = !(argc > 1 && strcmp(argv[1], "-q") == 0); + + mpd_maxcontext(&ctx); + s = malloc(WORDS*MPD_RDIGITS+1); + seed = time(NULL); + srandom((unsigned int)seed); + + if (!verbose) { + fprintf(stderr, "%s ... ", argv[0]); + } + + for (ma = MPD_MINALLOC_MIN; ma <= MPD_MINALLOC_MAX; ma++) { + + /* DON'T do this in a real program. You have to be sure + * that no previously allocated decimals will ever be used. */ + MPD_MINALLOC = ma; + + a = mpd_new(&ctx); + b = mpd_new(&ctx); + qd = mpd_new(&ctx); + rd = mpd_new(&ctx); + mpz_init(x); + mpz_init(y); + mpz_init(qz); + mpz_init(rz); + + for (alen = 1; alen <= WORDS*MPD_RDIGITS; alen++) { + + if (verbose) { + fprintf(stderr, "\r%s: progress: %2.2f%%", argv[0], + (counter/total*100)); + } + + for (k = 0; k < alen; k++) { + s[k] = '0' + random()%10; + } + s[k] = '\0'; + mpd_set_string(a, s, &ctx); + mpz_set_str(x, s, 10); + + for (blen = 1; blen <= alen; blen++) { + + counter++; + + have_nonzero = 0; + while (!have_nonzero) { + for (k = 0; k < blen; k++) { + s[k] = '0' + random()%10; + if (s[k] != '0') { + have_nonzero = 1; + } + } + s[k] = '\0'; + } + + mpd_set_string(b, s, &ctx); + mpz_set_str(y, s, 10); + + mpd_divmod(qd, rd, a, b, &ctx); + q_mpd = mpd_to_sci(qd, 1); + r_mpd = mpd_to_sci(rd, 1); + + mpz_fdiv_qr(qz, rz, x, y); + q_mpz = mpz_get_str(NULL, 10, qz); + r_mpz = mpz_get_str(NULL, 10, rz); + + if (strcmp(q_mpz, q_mpd) != 0) { + fprintf(stderr, " FAIL: seed = %"PRI_time_t"\n", seed); + exit(1); + } + if (strcmp(r_mpz, r_mpd) != 0) { + fprintf(stderr, " FAIL: seed = %"PRI_time_t"\n", seed); + exit(1); + } + + mpd_free(q_mpd); + mpd_free(r_mpd); + mpd_free(q_mpz); + mpd_free(r_mpz); + } + } + + mpd_del(a); + mpd_del(b); + mpd_del(qd); + mpd_del(rd); + mpz_clear(x); + mpz_clear(y); + mpz_clear(qz); + mpz_clear(rz); + } + + free(s); + if (verbose) { + fprintf(stderr, "\r%s: progress: %2.4f%%", argv[0], 100.0); + } + fprintf(stderr, " PASS\n"); + + return 0; +} + + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/tests/mpd_mpz_mul.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/tests/mpd_mpz_mul.c Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2008-2010 Stefan Krah. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + + +#include +#include +#include +#include +#include +#include "mpdecimal.h" +#include "mptypes.h" + + +/* + * Test mpd_mul against mpz_mul, for all possible factor lengths + * (in decimal digits) from 1x1 upto (WORDS*MPD_RDIGITS)*(WORDS*MPD_RDIGITS). + */ + + +#define WORDS 80 + + +int +main(int argc, char **argv) +{ + mpd_context_t ctx; + mpd_t *a, *b, *c; + mpz_t x, y, z; + mpd_ssize_t ma; + char *mpdresult, *mpzresult; + char *s; + size_t alen, blen, k; + double total = (WORDS*MPD_RDIGITS)*(WORDS*MPD_RDIGITS)*63; + double counter = 0; + time_t seed; + int verbose; + + verbose = !(argc > 1 && strcmp(argv[1], "-q") == 0); + + mpd_maxcontext(&ctx); + s = malloc(WORDS*MPD_RDIGITS+1); + seed = time(NULL); + srandom((unsigned int)seed); + + if (!verbose) { + fprintf(stderr, "%s ... ", argv[0]); + } + + for (ma = MPD_MINALLOC_MIN; ma <= MPD_MINALLOC_MAX; ma++) { + + /* DON'T do this in a real program. You have to be sure + * that no previously allocated decimals will ever be used. */ + MPD_MINALLOC = ma; + + a = mpd_new(&ctx); + b = mpd_new(&ctx); + c = mpd_new(&ctx); + mpz_init(x); + mpz_init(y); + mpz_init(z); + + for (alen = 1; alen <= WORDS*MPD_RDIGITS; alen++) { + + if (verbose) { + fprintf(stderr, "\r%s: progress: %2.4f%%", argv[0], + (counter/total*100)); + } + + for (k = 0; k < alen; k++) { + s[k] = '0' + random()%10; + } + s[k] = '\0'; + mpd_set_string(a, s, &ctx); + mpz_set_str(x, s, 10); + + for (blen = 1; blen <= WORDS*MPD_RDIGITS; blen++) { + + counter++; + + for (k = 0; k < blen; k++) { + s[k] = '0' + random()%10; + } + s[k] = '\0'; + + mpd_set_string(b, s, &ctx); + mpz_set_str(y, s, 10); + + mpd_mul(c, a, b, &ctx); + mpdresult = mpd_to_sci(c, 1); + + mpz_mul(z, x, y); + mpzresult = mpz_get_str(NULL, 10, z); + + if (strcmp(mpzresult, mpdresult) != 0) { + fprintf(stderr, " FAIL: seed = %"PRI_time_t"\n", seed); + exit(1); + } + + mpd_free(mpdresult); + mpd_free(mpzresult); + } + } + + mpd_del(a); + mpd_del(b); + mpd_del(c); + mpz_clear(x); + mpz_clear(y); + mpz_clear(z); + } + + free(s); + if (verbose) { + fprintf(stderr, "\r%s: progress: %2.4f%%", argv[0], 100.0); + } + fprintf(stderr, " PASS\n"); + + return 0; +} + + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/tests/mpd_mpz_sub.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/tests/mpd_mpz_sub.c Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2008-2010 Stefan Krah. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + + +#include +#include +#include +#include +#include +#include "mpdecimal.h" +#include "mptypes.h" + + +/* + * Test mpd_sub against mpz_sub, for all possible lengths + * (in decimal digits) from 1x1 upto (WORDS*MPD_RDIGITS)x(WORDS*MPD_RDIGITS). + */ + + +#define WORDS 80 + + +int +main(int argc, char **argv) +{ + mpd_context_t ctx; + mpd_t *a, *b, *c; + mpz_t x, y, z; + mpd_ssize_t ma; + char *mpdresult, *mpzresult; + char *s; + size_t alen, blen, k; + double total = (WORDS*MPD_RDIGITS)*(WORDS*MPD_RDIGITS)*63; + double counter = 0; + time_t seed; + int verbose; + + verbose = !(argc > 1 && strcmp(argv[1], "-q") == 0); + + mpd_maxcontext(&ctx); + s = malloc(WORDS*MPD_RDIGITS+1); + seed = time(NULL); + srandom((unsigned int)seed); + + if (!verbose) { + fprintf(stderr, "%s ... ", argv[0]); + } + + for (ma = MPD_MINALLOC_MIN; ma <= MPD_MINALLOC_MAX; ma++) { + + /* DON'T do this in a real program. You have to be sure + * that no previously allocated decimals will ever be used. */ + MPD_MINALLOC = ma; + + a = mpd_new(&ctx); + b = mpd_new(&ctx); + c = mpd_new(&ctx); + mpz_init(x); + mpz_init(y); + mpz_init(z); + + for (alen = 1; alen <= WORDS*MPD_RDIGITS; alen++) { + + if (verbose) { + fprintf(stderr, "\r%s: progress: %2.4f%%", argv[0], + (counter/total*100)); + } + + for (k = 0; k < alen; k++) { + s[k] = '0' + random()%10; + } + s[k] = '\0'; + mpd_set_string(a, s, &ctx); + mpz_set_str(x, s, 10); + + for (blen = 1; blen <= WORDS*MPD_RDIGITS; blen++) { + + counter++; + + for (k = 0; k < blen; k++) { + s[k] = '0' + random()%10; + } + s[k] = '\0'; + + mpd_set_string(b, s, &ctx); + mpz_set_str(y, s, 10); + + mpd_sub(c, a, b, &ctx); + mpdresult = mpd_to_sci(c, 1); + + mpz_sub(z, x, y); + mpzresult = mpz_get_str(NULL, 10, z); + + if (strcmp(mpzresult, mpdresult) != 0) { + fprintf(stderr, " FAIL: seed = %"PRI_time_t"\n", seed); + exit(1); + } + + mpd_free(mpdresult); + mpd_free(mpzresult); + } + } + + mpd_del(a); + mpd_del(b); + mpd_del(c); + mpz_clear(x); + mpz_clear(y); + mpz_clear(z); + } + + free(s); + if (verbose) { + fprintf(stderr, "\r%s: progress: %2.4f%%", argv[0], 100.0); + } + fprintf(stderr, " PASS\n"); + + return 0; +} + + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/tests/official.decTest --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/tests/official.decTest Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,163 @@ + +-- All tests from the dectest directory. Tests that are skipped are +-- commented out. + +Dectest: ./testdata/abs.decTest +Dectest: ./testdata/add.decTest +Dectest: ./testdata/and.decTest +Dectest: ./testdata/base.decTest +Dectest: ./testdata/clamp.decTest +Dectest: ./testdata/class.decTest +Dectest: ./testdata/compare.decTest +Dectest: ./testdata/comparetotal.decTest +Dectest: ./testdata/comparetotmag.decTest +Dectest: ./testdata/copyabs.decTest +Dectest: ./testdata/copy.decTest +Dectest: ./testdata/copynegate.decTest +Dectest: ./testdata/copysign.decTest +Dectest: ./testdata/ddAbs.decTest +Dectest: ./testdata/ddAdd.decTest +Dectest: ./testdata/ddAnd.decTest +Dectest: ./testdata/ddBase.decTest +-- Dectest: ./testdata/ddCanonical.decTest +Dectest: ./testdata/ddClass.decTest +Dectest: ./testdata/ddCompare.decTest +Dectest: ./testdata/ddCompareSig.decTest +Dectest: ./testdata/ddCompareTotal.decTest +Dectest: ./testdata/ddCompareTotalMag.decTest +Dectest: ./testdata/ddCopyAbs.decTest +Dectest: ./testdata/ddCopy.decTest +Dectest: ./testdata/ddCopyNegate.decTest +Dectest: ./testdata/ddCopySign.decTest +Dectest: ./testdata/ddDivide.decTest +Dectest: ./testdata/ddDivideInt.decTest +-- Dectest: ./testdata/ddEncode.decTest +Dectest: ./testdata/ddFMA.decTest +Dectest: ./testdata/ddInvert.decTest +Dectest: ./testdata/ddLogB.decTest +Dectest: ./testdata/ddMax.decTest +Dectest: ./testdata/ddMaxMag.decTest +Dectest: ./testdata/ddMin.decTest +Dectest: ./testdata/ddMinMag.decTest +Dectest: ./testdata/ddMinus.decTest +Dectest: ./testdata/ddMultiply.decTest +Dectest: ./testdata/ddNextMinus.decTest +Dectest: ./testdata/ddNextPlus.decTest +Dectest: ./testdata/ddNextToward.decTest +Dectest: ./testdata/ddOr.decTest +Dectest: ./testdata/ddPlus.decTest +Dectest: ./testdata/ddQuantize.decTest +Dectest: ./testdata/ddReduce.decTest +Dectest: ./testdata/ddRemainder.decTest +Dectest: ./testdata/ddRemainderNear.decTest +Dectest: ./testdata/ddRotate.decTest +Dectest: ./testdata/ddSameQuantum.decTest +Dectest: ./testdata/ddScaleB.decTest +Dectest: ./testdata/ddShift.decTest +Dectest: ./testdata/ddSubtract.decTest +Dectest: ./testdata/ddToIntegral.decTest +Dectest: ./testdata/ddXor.decTest +-- Dectest: ./testdata/decDouble.decTest +-- Dectest: ./testdata/decQuad.decTest +-- Dectest: ./testdata/decSingle.decTest +Dectest: ./testdata/divide.decTest +Dectest: ./testdata/divideint.decTest +Dectest: ./testdata/dqAbs.decTest +Dectest: ./testdata/dqAdd.decTest +Dectest: ./testdata/dqAnd.decTest +Dectest: ./testdata/dqBase.decTest +-- Dectest: ./testdata/dqCanonical.decTest +Dectest: ./testdata/dqClass.decTest +Dectest: ./testdata/dqCompare.decTest +Dectest: ./testdata/dqCompareSig.decTest +Dectest: ./testdata/dqCompareTotal.decTest +Dectest: ./testdata/dqCompareTotalMag.decTest +Dectest: ./testdata/dqCopyAbs.decTest +Dectest: ./testdata/dqCopy.decTest +Dectest: ./testdata/dqCopyNegate.decTest +Dectest: ./testdata/dqCopySign.decTest +Dectest: ./testdata/dqDivide.decTest +Dectest: ./testdata/dqDivideInt.decTest +-- Dectest: ./testdata/dqEncode.decTest +Dectest: ./testdata/dqFMA.decTest +Dectest: ./testdata/dqInvert.decTest +Dectest: ./testdata/dqLogB.decTest +Dectest: ./testdata/dqMax.decTest +Dectest: ./testdata/dqMaxMag.decTest +Dectest: ./testdata/dqMin.decTest +Dectest: ./testdata/dqMinMag.decTest +Dectest: ./testdata/dqMinus.decTest +Dectest: ./testdata/dqMultiply.decTest +Dectest: ./testdata/dqNextMinus.decTest +Dectest: ./testdata/dqNextPlus.decTest +Dectest: ./testdata/dqNextToward.decTest +Dectest: ./testdata/dqOr.decTest +Dectest: ./testdata/dqPlus.decTest +Dectest: ./testdata/dqQuantize.decTest +Dectest: ./testdata/dqReduce.decTest +Dectest: ./testdata/dqRemainder.decTest +Dectest: ./testdata/dqRemainderNear.decTest +Dectest: ./testdata/dqRotate.decTest +Dectest: ./testdata/dqSameQuantum.decTest +Dectest: ./testdata/dqScaleB.decTest +Dectest: ./testdata/dqShift.decTest +Dectest: ./testdata/dqSubtract.decTest +Dectest: ./testdata/dqToIntegral.decTest +Dectest: ./testdata/dqXor.decTest +Dectest: ./testdata/dsBase.decTest +-- Dectest: ./testdata/dsEncode.decTest +Dectest: ./testdata/exp.decTest +Dectest: ./testdata/fma.decTest +Dectest: ./testdata/inexact.decTest +Dectest: ./testdata/invert.decTest +Dectest: ./testdata/ln.decTest +Dectest: ./testdata/log10.decTest +Dectest: ./testdata/logb.decTest +Dectest: ./testdata/max.decTest +Dectest: ./testdata/maxmag.decTest +Dectest: ./testdata/min.decTest +Dectest: ./testdata/minmag.decTest +Dectest: ./testdata/minus.decTest +Dectest: ./testdata/multiply.decTest +Dectest: ./testdata/nextminus.decTest +Dectest: ./testdata/nextplus.decTest +Dectest: ./testdata/nexttoward.decTest +Dectest: ./testdata/or.decTest +Dectest: ./testdata/plus.decTest +Dectest: ./testdata/power.decTest +Dectest: ./testdata/powersqrt.decTest +Dectest: ./testdata/quantize.decTest +Dectest: ./testdata/randombound32.decTest +Dectest: ./testdata/randoms.decTest +Dectest: ./testdata/reduce.decTest +Dectest: ./testdata/remainder.decTest +Dectest: ./testdata/remaindernear.decTest +Dectest: ./testdata/rescale.decTest +Dectest: ./testdata/rotate.decTest +Dectest: ./testdata/rounding.decTest +Dectest: ./testdata/samequantum.decTest +Dectest: ./testdata/scaleb.decTest +Dectest: ./testdata/shift.decTest +Dectest: ./testdata/squareroot.decTest +Dectest: ./testdata/subtract.decTest +-- Dectest: ./testdata/testall.decTest +Dectest: ./testdata/tointegral.decTest +Dectest: ./testdata/tointegralx.decTest +-- Dectest: ./testdata/trim.decTest +Dectest: ./testdata/xor.decTest + + +-- Summary of functions that are not implemented or do not need testing: + +-- Dectest: ./testdata/ddCanonical.decTest ==> same as copy() +-- Dectest: ./testdata/ddEncode.decTest +-- Dectest: ./testdata/decDouble.decTest +-- Dectest: ./testdata/decQuad.decTest +-- Dectest: ./testdata/decSingle.decTest +-- Dectest: ./testdata/dqCanonical.decTest ==> same as copy() +-- Dectest: ./testdata/dqEncode.decTest +-- Dectest: ./testdata/dsEncode.decTest +-- Dectest: ./testdata/testall.decTest +-- Dectest: ./testdata/trim.decTest + + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/tests/ppro_mulmod.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/tests/ppro_mulmod.c Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,227 @@ +/* + * Copyright (c) 2008-2010 Stefan Krah. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + + +#include +#include "mpdecimal.h" + + +#ifdef PPRO + +#define ANSI + +#include +#include +#include "constants.h" +#include "numbertheory.h" +#include "mptypes.h" +#include "mptest.h" +#include "umodarith.h" + +/* + * These are random tests for the pentium pro modular multiplication functions. + */ + +int +main(int argc UNUSED, char **argv) +{ + double dmod; + uint32_t dinvmod[3]; + mpd_uint_t umod; + mpd_uint_t a, b, c, d; + mpd_uint_t a1, a2, b1, b2; + long i; + + (void)mpd_set_fenv(); + + fprintf(stderr, "%s:\n", argv[0]); + fprintf(stderr, "testing MULMOD ... "); + + srandom((unsigned int)time(NULL)); + + SETMODULUS(P1); + for (i = 0; i < 100000000; i++) { + a = random()%umod; + b = random()%umod; + c = std_mulmod(a, b, umod); + d = MULMOD(a, b); + if (c != d) { + fprintf(stderr, "FAIL: a: %u b: %u ansi: %u " + "ppro: %u\n", a, b, c, d); + exit(1); + } + } + + SETMODULUS(P2); + for (i = 0; i < 100000000; i++) { + a = random()%umod; + b = random()%umod; + c = std_mulmod(a, b, umod); + d = MULMOD(a, b); + if (c != d) { + fprintf(stderr, "FAIL: a: %u b: %u ansi: %u " + "ppro: %u\n", a, b, c, d); + exit(1); + } + } + + SETMODULUS(P3); + for (i = 0; i < 100000000; i++) { + a = random()%umod; + b = random()%umod; + c = std_mulmod(a, b, umod); + d = MULMOD(a, b); + if (c != d) { + fprintf(stderr, "FAIL: a: %u b: %u ansi: %u " + "ppro: %u\n", a, b, c, d); + exit(1); + } + } + + fprintf(stderr, "PASS\n"); + fprintf(stderr, "testing MULMOD2C ... "); + + SETMODULUS(P1); + for (i = 0; i < 100000000; i++) { + a1 = a2 = a = random()%umod; + b1 = b2 = b = random()%umod; + c = random()%umod; + std_mulmod2c(&a1, &b1, c, umod); + MULMOD2C(&a2, &b2, c); + if (a1 != a2 || b1 != b2) { + fprintf(stderr, "FAIL: a: %u b: %u c: %u " + "ansi1: %u ppro1: %u " + "ansi2: %u ppro2: %u ", + a, b, c, a1, a2, b1, b2); + exit(1); + } + } + + SETMODULUS(P2); + for (i = 0; i < 100000000; i++) { + a1 = a2 = a = random()%umod; + b1 = b2 = b = random()%umod; + c = random()%umod; + std_mulmod2c(&a1, &b1, c, umod); + MULMOD2C(&a2, &b2, c); + if (a1 != a2 || b1 != b2) { + fprintf(stderr, "FAIL: a: %u b: %u c: %u " + "ansi1: %u ppro1: %u " + "ansi2: %u ppro2: %u ", + a, b, c, a1, a2, b1, b2); + exit(1); + } + } + + SETMODULUS(P3); + for (i = 0; i < 100000000; i++) { + a1 = a2 = a = random()%umod; + b1 = b2 = b = random()%umod; + c = random()%umod; + std_mulmod2c(&a1, &b1, c, umod); + MULMOD2C(&a2, &b2, c); + if (a1 != a2 || b1 != b2) { + fprintf(stderr, "FAIL: a: %u b: %u c: %u " + "ansi1: %u ppro1: %u " + "ansi2: %u ppro2: %u ", + a, b, c, a1, a2, b1, b2); + exit(1); + } + } + + fprintf(stderr, "PASS\n"); + fprintf(stderr, "testing MULMOD2 ... "); + + SETMODULUS(P1); + for (i = 0; i < 100000000; i++) { + a1 = a2 = a = random()%umod; + b1 = b2 = b = random()%umod; + c = random()%umod; + d = random()%umod; + std_mulmod2(&a1, c, &b1, d, umod); + MULMOD2(&a2, c, &b2, d); + if (a1 != a2 || b1 != b2) { + fprintf(stderr, "FAIL: a: %u b: %u c: %u d: %u " + "ansi1: %u ppro1: %u " + "ansi2: %u ppro2: %u ", + a, b, c, d, a1, a2, b1, b2); + exit(1); + } + } + + SETMODULUS(P2); + for (i = 0; i < 100000000; i++) { + a1 = a2 = a = random()%umod; + b1 = b2 = b = random()%umod; + c = random()%umod; + d = random()%umod; + std_mulmod2(&a1, c, &b1, d, umod); + MULMOD2(&a2, c, &b2, d); + if (a1 != a2 || b1 != b2) { + fprintf(stderr, "FAIL: a: %u b: %u c: %u d: %u " + "ansi1: %u ppro1: %u " + "ansi2: %u ppro2: %u ", + a, b, c, d, a1, a2, b1, b2); + exit(1); + } + } + + SETMODULUS(P3); + for (i = 0; i < 100000000; i++) { + a1 = a2 = a = random()%umod; + b1 = b2 = b = random()%umod; + c = random()%umod; + d = random()%umod; + std_mulmod2(&a1, c, &b1, d, umod); + MULMOD2(&a2, c, &b2, d); + if (a1 != a2 || b1 != b2) { + fprintf(stderr, "FAIL: a: %u b: %u c: %u d: %u " + "ansi1: %u ppro1: %u " + "ansi2: %u ppro2: %u ", + a, b, c, d, a1, a2, b1, b2); + exit(1); + } + } + + fprintf(stderr, "PASS\n"); + + return 0; +} +/* END PPRO_GCC */ +#else + +int +main(int argc UNUSED, char **argv) +{ + fprintf(stderr, "%s: PASS\n", argv[0]); + return 0; +} + +#endif + + + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/tests/runallconfigs.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/tests/runallconfigs.bat Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,85 @@ +@ECHO OFF + +cd ..\ +copy /y Makefile.vc Makefile +cd tests +copy /y Makefile.vc Makefile + + +call vcvarsall x64 + +echo. +echo # ======================================================================== +echo # x64 +echo # ======================================================================== +echo. +cd ..\ +nmake clean +nmake MACHINE=x64 extended_gmp +cd tests +call runalltests.bat + + +echo. +echo # ======================================================================== +echo # ansi64 +echo # ======================================================================== +echo. +cd ..\ +nmake clean +nmake MACHINE=ansi64 extended_gmp +cd tests +call runalltests.bat + + +echo. +echo # ======================================================================== +echo # full_coverage +echo # ======================================================================== +echo. +cd ..\ +nmake clean +patch < tests\fullcov_header.patch +nmake MACHINE=full_coverage extended_gmp +patch -R < tests\fullcov_header.patch +cd tests +call runalltests.bat + + +call vcvarsall x86 + +echo. +echo # ======================================================================== +echo # ppro +echo # ======================================================================== +echo. +cd ..\ +nmake clean +nmake MACHINE=ppro extended_gmp +cd tests +call runalltests.bat + +echo. +echo # ======================================================================== +echo # ansi32 +echo # ======================================================================== +echo. +cd ..\ +nmake clean +nmake MACHINE=ansi32 extended_gmp +cd tests +call runalltests.bat + +echo. +echo # ======================================================================== +echo # ansi-legacy +echo # ======================================================================== +echo. +cd ..\ +nmake clean +nmake MACHINE=ansi-legacy extended_gmp +cd tests +call runalltests.bat + + + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/tests/runallconfigs.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/tests/runallconfigs.sh Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,51 @@ +#!/bin/sh + + +VALGRIND= +if [ X"$1" = X"--valgrind" ]; then + shift + VALGRIND="valgrind --tool=memcheck --leak-check=full --leak-resolution=high --db-attach=yes --show-reachable=yes" +fi +export VALGRIND + +if [ -n "$1" ]; then + CONFIGS="$@" +else + CONFIGS="x64 uint128 ansi64 full_coverage ppro ansi32 ansi-legacy universal" +fi + +GMAKE=`which gmake` +if [ X"$GMAKE" = X"" ]; then + GMAKE=make +fi + + +for config in $CONFIGS; do + printf "\n# ========================================================================\n" + printf "# %s\n" $config + printf "# ========================================================================\n\n" + cd .. + $GMAKE clean + ./configure MACHINE=$config + if [ X"$config" = X"full_coverage" ]; then + patch < tests/fullcov_header.patch + $GMAKE extended + patch -R < tests/fullcov_header.patch + else + $GMAKE extended + fi + cd tests + printf "\n" + if [ X"$config" = X"ppro" ]; then + # Valgrind has no support for 80 bit long double arithmetic. + savevg=$VALGRIND + VALGRIND= + ./runalltests.sh + VALGRIND=$savevg + else + ./runalltests.sh + fi +done + + + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/tests/runalltests.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/tests/runalltests.bat Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,58 @@ +@ECHO OFF + +if exist ..\..\..\..\PCbuild\python.exe set PYTHON="..\..\..\..\PCbuild\python.exe" +if exist ..\..\..\..\PCbuild\python_d.exe set PYTHON="..\..\..\..\PCbuild\python_d.exe" +if exist ..\..\..\..\PCbuild\amd64\python.exe set PYTHON="..\..\..\..\PCbuild\amd64\python.exe" +if exist ..\..\..\..\PCbuild\amd64\python_d.exe set PYTHON="..\..\..\..\PCbuild\amd64\python_d.exe" + +if not exist runtest.exe goto error + +call gettests.bat + +echo. +echo Running official tests ... +echo. +runtest.exe --all official.decTest + +echo. +echo Running additional tests ... +echo. +runtest.exe --all additional.decTest + +echo. +echo Running coverage tests ... +echo. +cov.exe +test_transpose.exe +fntcov.exe + +echo. +echo Running long tests ... +echo. +ppro_mulmod.exe +if exist mpd_mpz_add.exe mpd_mpz_add.exe -q +if exist mpd_mpz_sub.exe mpd_mpz_sub.exe -q +if exist mpd_mpz_mul.exe mpd_mpz_mul.exe -q +if exist mpd_mpz_divmod.exe mpd_mpz_divmod.exe -q +karatsuba_fnt.exe -q +karatsuba_fnt2.exe -q + + +echo. +echo Running locale and format tests ... +echo. +%PYTHON% ..\python\genrandlocale.py | runtest.exe - +%PYTHON% ..\python\genrandformat.py | runtest.exe - +%PYTHON% ..\python\genlocale.py | runtest.exe - + +goto finish + + +:error +echo. +echo error: the tests must be built first +echo. + +:finish + + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/tests/runalltests.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/tests/runalltests.sh Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,50 @@ +#!/bin/sh + + +if ! [ -f runtest ]; then + echo "error: you must build the tests first" + exit 1 +fi + + +./gettests.sh || exit 1 + +printf "\nRunning official tests ... \n\n" +$VALGRIND ./runtest --all official.decTest + +printf "\nRunning additional tests ... \n\n" +$VALGRIND ./runtest --all additional.decTest + +printf "\nRunning coverage tests ... \n\n" +$VALGRIND ./cov +$VALGRIND ./test_transpose +$VALGRIND ./fntcov + +printf "\nRunning long tests ... \n\n" +./ppro_mulmod +if [ -f mpd_mpz_add ]; then + $VALGRIND ./mpd_mpz_add -q +fi +if [ -f mpd_mpz_sub ]; then + $VALGRIND ./mpd_mpz_sub -q +fi +if [ -f mpd_mpz_mul ]; then + $VALGRIND ./mpd_mpz_mul -q +fi +if [ -f mpd_mpz_divmod ]; then + $VALGRIND ./mpd_mpz_divmod -q +fi +$VALGRIND ./karatsuba_fnt -q +$VALGRIND ./karatsuba_fnt2 -q + + +PYTHON=../../../../python + +printf "\nRunning locale and format tests ... \n\n" + +$PYTHON ../python/genrandlocale.py | $VALGRIND ./runtest - +$PYTHON ../python/genrandformat.py | $VALGRIND ./runtest - +$PYTHON ../python/genlocale.py | $VALGRIND ./runtest - + + + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/tests/runshort.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/tests/runshort.bat Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,12 @@ +@ECHO OFF +call gettests.bat +echo. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "io.h" +#include "memory.h" +#include "mpdecimal.h" +#include "mptest.h" +#include "mptypes.h" +#include "malloc_fail.h" + + +#define MAXLINE 400000 +#define MAXTOKEN 32 + + +#ifndef _MSC_VER + #include + #define ASSERT(p) if (!(p)) {abort();} +#else + #define ASSERT(p) if (!(p)) {mpd_err_fatal("assertion failed");} +#endif + + +int have_fail = 0; +int have_printed = 0; + + +static void +mpd_init_rand(mpd_t *x) +{ + long r = random() % 100; + uint8_t sign = random()%2; + + if (r >= 80) { + mpd_minalloc(x); + } + else if (r >= 60) { + mpd_minalloc(x); + mpd_set_flags(x, sign); + } + else if (r >= 40) { + mpd_setspecial(x, sign, MPD_NAN); + } + else if (r >= 20) { + mpd_setspecial(x, sign, MPD_SNAN); + } + else { + mpd_setspecial(x, sign, MPD_INF); + } +} + +static void +mpd_readcontext(mpd_context_t *ctx) +{ +#if defined(CONFIG_64) + ctx->prec=1070000000000000000; + ctx->emax=1070000000000000000; + ctx->emin=-1070000000000000000; +#elif defined(CONFIG_32) + /* These ranges are needed for the official testsuite + * and are generally not problematic at all. */ + ctx->prec=1070000000; + ctx->emax=1070000000; + ctx->emin=-1070000000; +#else + #error "config not defined" +#endif + ctx->round=MPD_ROUND_HALF_UP; + ctx->traps=MPD_Traps; + ctx->status=0; + ctx->newtrap=0; + ctx->clamp=0; + ctx->allcr=0; +} + +static void +mpd_testcontext(mpd_context_t *ctx) +{ +#if defined(CONFIG_64) + ctx->prec=999999999; + ctx->emax=MPD_MAX_EMAX; + ctx->emin=MPD_MIN_EMIN; +#elif defined(CONFIG_32) + /* These ranges are needed for the official testsuite + * and are generally not problematic at all. */ + ctx->prec=999999999; + ctx->emax=999999999; + ctx->emin=-999999999; +#else + #error "config not defined" +#endif + ctx->round=MPD_ROUND_HALF_UP; + ctx->traps=MPD_Traps; + ctx->status=0; + ctx->newtrap=0; + ctx->clamp=0; + ctx->allcr=0; +} + +/* Known differences that are within the spec */ +struct result_diff { + const char *id; + const char *calc; + const char *expected; +}; + +struct status_diff { + const char *id; + uint32_t calc; + uint32_t expected; +}; + +struct result_diff ulp_cases[] = { + /* Cases where the result is allowed to differ by less than one ULP. + * Only needed if ctx->allcr is 0. */ + { "expx013", "1.001000", "1.001001" }, + { "expx020", "1.000000", "1.000001" }, + { "expx109", "0.999999910000004049999878", "0.999999910000004049999879" }, + { "expx1036", "1.005088", "1.005087" }, + { "expx350", "1.0000000", "1.0000001" }, + { "expx351", "1.0000000", "1.0000001" }, + { "expx352", "1.0000000", "1.0000001" }, + {NULL, NULL, NULL} +}; + +struct status_diff status_cases[] = { + /* With a reduced working precision in mpd_qpow() the status matches. */ + { "pwsx803", MPD_Inexact|MPD_Rounded|MPD_Subnormal|MPD_Underflow, MPD_Inexact|MPD_Rounded }, + {NULL, 0, 0} +}; + +char *skipit[] = { + /* NULL reference, decimal16, decimal32, or decimal128 */ + "absx900", + "addx9990", + "addx9991", + "clam090", + "clam091", + "clam092", + "clam093", + "clam094", + "clam095", + "clam096", + "clam097", + "clam098", + "clam099", + "clam189", + "clam190", + "clam191", + "clam192", + "clam193", + "clam194", + "clam195", + "clam196", + "clam197", + "clam198", + "clam199", + "comx990", + "comx991", + "cotx9990", + "cotx9991", + "ctmx9990", + "ctmx9991", + "ddabs900", + "ddadd9990", + "ddadd9991", + "ddcom9990", + "ddcom9991", + "ddcot9990", + "ddcot9991", + "ddctm9990", + "ddctm9991", + "dddiv9998", + "dddiv9999", + "dddvi900", + "dddvi901", + "ddfma2990", + "ddfma2991", + "ddfma39990", + "ddfma39991", + "ddlogb900", + "ddmax900", + "ddmax901", + "ddmxg900", + "ddmxg901", + "ddmin900", + "ddmin901", + "ddmng900", + "ddmng901", + "ddmul9990", + "ddmul9991", + "ddnextm900", + "ddnextm900", + "ddnextp900", + "ddnextp900", + "ddnextt900", + "ddnextt901", + "ddqua998", + "ddqua999", + "ddred900", + "ddrem1000", + "ddrem1001", + "ddrmn1000", + "ddrmn1001", + "ddsub9990", + "ddsub9991", + "ddintx074", + "ddintx094", + "divx9998", + "divx9999", + "dvix900", + "dvix901", + "dqabs900", + "dqadd9990", + "dqadd9991", + "dqcom990", + "dqcom991", + "dqcot9990", + "dqcot9991", + "dqctm9990", + "dqctm9991", + "dqdiv9998", + "dqdiv9999", + "dqdvi900", + "dqdvi901", + "dqfma2990", + "dqfma2991", + "dqadd39990", + "dqadd39991", + "dqlogb900", + "dqmax900", + "dqmax901", + "dqmxg900", + "dqmxg901", + "dqmin900", + "dqmin901", + "dqmng900", + "dqmng901", + "dqmul9990", + "dqmul9991", + "dqnextm900", + "dqnextp900", + "dqnextt900", + "dqnextt901", + "dqqua998", + "dqqua999", + "dqred900", + "dqrem1000", + "dqrem1001", + "dqrmn1000", + "dqrmn1001", + "dqsub9990", + "dqsub9991", + "dqintx074", + "dqintx094", + "expx900", + "fmax2990", + "fmax2991", + "fmax39990", + "fmax39991", + "lnx900", + "logx900", + "logbx900", + "maxx900", + "maxx901", + "mxgx900", + "mxgx901", + "mnm900", + "mnm901", + "mng900", + "mng901", + "minx900", + "mulx990", + "mulx991", + "nextm900", + "nextp900", + "nextt900", + "nextt901", + "plu900", + "powx900", + "powx901", + "pwsx900", + "quax1022", + "quax1023", + "quax1024", + "quax1025", + "quax1026", + "quax1027", + "quax1028", + "quax1029", + "quax0a2", + "quax0a3", + "quax998", + "quax999", + "redx900", + "remx1000", + "remx1001", + "rmnx900", + "rmnx901", + "sqtx9900", + "subx9990", + "subx9991", + /* operand range violations, invalid context */ + "expx901", + "expx902", + "expx903", + "expx905", + "lnx901", + "lnx902", + "lnx903", + "lnx905", + "logx901", + "logx902", + "logx903", + "logx905", + "powx1183", + "powx1184", + "powx4001", + "powx4002", + "powx4003", + "powx4005", + "powx4008", + "powx4010", + "powx4012", + "powx4014", + "scbx164", + "scbx165", + "scbx166", + /* skipped for decNumber, too */ + "powx4302", + "powx4303", + "powx4303", + "powx4342", + "powx4343", + "pwsx805", + /* disagreement for three arg power */ + "pwmx325", + "pwmx326", + NULL +}; + +static inline int +startswith(const char *token, const char *s) +{ + return strncasecmp(token, s, strlen(s)) == 0; +} + +static inline int +eqtoken(const char *token, const char *s) +{ + return strcasecmp(token, s) == 0; +} + +static int +check_skip(char *id) +{ + int i; + + for (i = 0; skipit[i] != NULL; i++) { + if (eqtoken(id, skipit[i])) { +#if RT_VERBOSITY == 2 + if (!have_printed) { + fputs("\n\n", stderr); + have_printed = 1; + } + fprintf(stderr, "SKIP: %s\n", id); +#endif + return 1; + } + } + + return 0; +} + +static char * +nexttoken(char *cp) +{ + static char *start; + static char *end; + + if (cp == NULL) + cp = end; + + for (; *cp != '\0'; cp++) { + if (isspace((unsigned char)*cp)) { + ; + } + else if (*cp == '"') { + start = end = cp+1; + for (; *end != '\0'; end++) { + if (*end == '"' && *(end+1) == '"') + end += 1; + else if (*end == '"') + break; + } + if (*end == '\0') + return NULL; + *end++ = '\0'; + return start; + } + else if (*cp == '\'') { + start = end = cp+1; + for (; *end != '\0'; end++) { + if (*end == '\'' && *(end+1) == '\'') + end += 1; + else if (*end == '\'') + break; + } + if (*end == '\0') + return NULL; + *end++ = '\0'; + return start; + } + else { + start = end = cp; + for (; *end != '\0'; end++) + if (isspace((unsigned char)*end)) + break; + if (*end == '\0') + return NULL; + *end++ = '\0'; + return start; + } + } + + return NULL; +} + +/* split a line into tokens */ +static int +split(char *token[], char line[]) +{ + char *cp; + size_t len; + int n = 0; + + cp = nexttoken(line); + while (n < MAXTOKEN && cp != NULL) { + len = strlen(cp); + if ((token[n] = malloc(len+1)) == NULL) { + mpd_err_fatal("out of memory"); + } + strcpy(token[n], cp); + cp = nexttoken(NULL); + n++; + } + token[n] = NULL; + + return n; +} + +static void +freetoken(char **token) +{ + while (*token != NULL) { + free(*token++); + } +} + +/* returns all expected conditions in a status flag */ +static uint32_t +scan_conditions(char **token) +{ + char *condition = *token; + uint32_t status = 0; + + while (condition != NULL) { + + if (startswith(condition, "--")) + break; + else if (eqtoken(condition, "Clamped")) + status |= MPD_Clamped; + else if (eqtoken(condition, "Conversion_syntax")) + status |= MPD_Conversion_syntax; + else if (eqtoken(condition, "Division_by_zero")) + status |= MPD_Division_by_zero; + else if (eqtoken(condition, "Division_impossible")) + status |= MPD_Division_impossible; + else if (eqtoken(condition, "Division_undefined")) + status |= MPD_Division_undefined; + else if (eqtoken(condition, "Fpu_error")) + status |= MPD_Fpu_error; + else if (eqtoken(condition, "Inexact")) + status |= MPD_Inexact; + else if (eqtoken(condition, "Invalid_context")) + status |= MPD_Invalid_context; + else if (eqtoken(condition, "Invalid_operation")) + status |= MPD_Invalid_operation; + else if (eqtoken(condition, "Malloc_error")) + status |= MPD_Malloc_error; + else if (eqtoken(condition, "Not_implemented")) + status |= MPD_Not_implemented; + else if (eqtoken(condition, "Overflow")) + status |= MPD_Overflow; + else if (eqtoken(condition, "Rounded")) + status |= MPD_Rounded; + else if (eqtoken(condition, "Subnormal")) + status |= MPD_Subnormal; + else if (eqtoken(condition, "Underflow")) + status |= MPD_Underflow; + else + mpd_err_fatal("unknown status: %s", condition); + + condition = *(++token); + } + + return status; +} + +static void +compare_expected(const char *calc, const char *expected, uint32_t expected_status, + char *id, mpd_context_t *ctx) +{ + char ctxstatus[MPD_MAX_FLAG_STRING]; + char expstatus[MPD_MAX_FLAG_STRING]; + + +#ifndef RT_VERBOSITY + /* Do not print known pseudo-failures. */ + int i; + + /* known ULP diffs */ + if (ctx->allcr == 0) { + for (i = 0; ulp_cases[i].id != NULL; i++) { + if (eqtoken(id, ulp_cases[i].id) && + strcmp(expected, ulp_cases[i].expected) == 0 && + strcmp(calc, ulp_cases[i].calc) == 0) { + return; + } + } + } + + /* known status diffs */ + for (i = 0; status_cases[i].id != NULL; i++) { + if (eqtoken(id, status_cases[i].id) && + expected_status == status_cases[i].expected && + ctx->status == status_cases[i].calc) { + return; + } + } +#endif + + if (strcmp(calc, expected) != 0) { + if (!have_printed) { + fputs("\n\n", stderr); + have_printed = 1; + } + fprintf(stderr, "FAIL: %s calc: %s expected: %s\n", + id, calc, expected); + have_fail = 1; + } + if (ctx->status != expected_status) { + if (!have_printed) { + fputs("\n\n", stderr); + have_printed = 1; + } + mpd_snprint_flags(ctxstatus, MPD_MAX_FLAG_STRING, ctx->status), + mpd_snprint_flags(expstatus, MPD_MAX_FLAG_STRING, expected_status); + fprintf(stderr, "FAIL: %s: status: calc: %s expected: %s\n", + id, ctxstatus, expstatus); + have_fail = 1; + } +} + +static int +equalmem(const mpd_t *a, const mpd_t *b) +{ + mpd_ssize_t i; + + if (a->flags != b->flags) return 0; + if (a->exp != b->exp) return 0; + if (a->len != b->len) return 0; + if (a->digits != b->digits) return 0; + for (i = 0; i < a->len; i++) + if (a->data[i] != b->data[i]) + return 0; + return 1; +} + +static void +check_equalmem(const mpd_t *a, const mpd_t *b, char *id) +{ + if (!equalmem(a, b)) { + fprintf(stderr, "FAIL: const arg changed: %s\n", id); + } +} + +static unsigned long +get_testno(char *token) +{ + char *number; + + number = strpbrk(token, "0123456789"); + return strtoul(number, NULL, 10); +} + +/* scan a single operand and the expected result */ +static int +scan_1op_result(mpd_t *op1, char **result, char *token[], mpd_context_t *ctx) +{ + /* operand 1 */ + if (token[2] == NULL) { + mpd_err_fatal("parse error at id %s", token[0]); + } + mpd_set_string(op1, token[2], ctx); + + /* discard "->" */ + if (token[3] == NULL) { + mpd_err_fatal("parse error at id %s", token[0]); + } + + /* expected result */ + if (token[4] == NULL) { + mpd_err_fatal("parse error at id %s", token[0]); + } + *result = token[4]; + + return 5; +} + +/* scan a single operand and two results */ +static int +scan_1op_2results(mpd_t *op1, char **result1, char **result2, char *token[], mpd_context_t *ctx) +{ + /* operand 1 */ + if (token[2] == NULL) { + mpd_err_fatal("parse error at id %s", token[0]); + } + mpd_set_string(op1, token[2], ctx); + + /* discard "->" */ + if (token[3] == NULL) { + mpd_err_fatal("parse error at id %s", token[0]); + } + + /* expected result1 */ + if (token[4] == NULL) { + mpd_err_fatal("parse error at id %s", token[0]); + } + *result1 = token[4]; + + /* expected result2 */ + if (token[5] == NULL) { + mpd_err_fatal("parse error at id %s", token[0]); + } + *result2 = token[5]; + + return 6; +} + +/* scan decimal operand, string operand and the expected result */ +static int +scan_1op_str_result(mpd_t *op1, char **op2, char **result, char *token[], mpd_context_t *ctx) +{ + /* operand 1 */ + if (token[2] == NULL) { + mpd_err_fatal("%s", token[0]); + } + mpd_set_string(op1, token[2], ctx); + + /* operand 2 */ + if (token[3] == NULL) { + mpd_err_fatal("%s", token[0]); + } + *op2 = token[3]; + + /* discard "->" */ + if (token[4] == NULL) { + mpd_err_fatal("%s", token[0]); + } + + /* expected result */ + if (token[5] == NULL) { + mpd_err_fatal("%s", token[0]); + } + *result = token[5]; + + return 6; +} + +/* scan two operands and the expected result */ +static int +scan_2ops_result(mpd_t *op1, mpd_t *op2, char **result, char *token[], mpd_context_t *ctx) +{ + /* operand 1 */ + if (token[2] == NULL) { + mpd_err_fatal("%s", token[0]); + } + mpd_set_string(op1, token[2], ctx); + + /* operand 2 */ + if (token[3] == NULL) { + mpd_err_fatal("%s", token[0]); + } + mpd_set_string(op2, token[3], ctx); + + /* discard "->" */ + if (token[4] == NULL) { + mpd_err_fatal("%s", token[0]); + } + + /* expected result */ + if (token[5] == NULL) { + mpd_err_fatal("%s", token[0]); + } + *result = token[5]; + + return 6; +} + +/* scan two operands and two results */ +static int +scan_2ops_2results(mpd_t *op1, mpd_t *op2, char **result1, char **result2, char *token[], mpd_context_t *ctx) +{ + /* operand 1 */ + if (token[2] == NULL) { + mpd_err_fatal("%s", token[0]); + } + mpd_set_string(op1, token[2], ctx); + + /* operand 2 */ + if (token[3] == NULL) { + mpd_err_fatal("%s", token[0]); + } + mpd_set_string(op2, token[3], ctx); + + /* discard "->" */ + if (token[4] == NULL) { + mpd_err_fatal("%s", token[0]); + } + + /* expected result1 */ + if (token[5] == NULL) { + mpd_err_fatal("%s", token[0]); + } + *result1 = token[5]; + + /* expected result2 */ + if (token[6] == NULL) { + mpd_err_fatal("%s", token[0]); + } + *result2 = token[6]; + + return 7; +} + +/* scan three operands and the expected result */ +static int +scan_3ops_result(mpd_t *op1, mpd_t *op2, mpd_t *op3, char **result, char *token[], mpd_context_t *ctx) +{ + /* operand 1 */ + if (token[2] == NULL) { + mpd_err_fatal("%s", token[0]); + } + mpd_set_string(op1, token[2], ctx); + + /* operand 2 */ + if (token[3] == NULL) { + mpd_err_fatal("%s", token[0]); + } + mpd_set_string(op2, token[3], ctx); + + /* operand 2 */ + if (token[4] == NULL) { + mpd_err_fatal("%s", token[0]); + } + mpd_set_string(op3, token[4], ctx); + + /* discard "->" */ + if (token[5] == NULL) { + mpd_err_fatal("%s", token[0]); + } + + /* expected result */ + if (token[6] == NULL) { + mpd_err_fatal("%s", token[0]); + } + *result = token[6]; + + return 7; +} + +mpd_t *op, *op1, *op2, *op3; +mpd_t *tmp, *tmp1, *tmp2, *tmp3; +mpd_t *result, *result1, *result2; + + +/* + * Test a function returning pointer to char, accepting: + * op1, context + * + * This function is used for "toSci", "toEng" and "apply" + * and does not use a maxctx for the conversion of the operand. + */ +static void +_cp_MpdCtx(char **token, char *(*func)(const mpd_t *, int), mpd_context_t *ctx) +{ + char *calc; + char *expected, *expected_fail; + uint32_t expstatus; + int n; + + ctx->status = 0; + /* status should be set in conversion */ + n = scan_1op_result(op, &expected, token, ctx); + + /* scan expected conditions */ + expstatus = scan_conditions(token+n); + + /* Allocation failures for mpd_set_string */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + (void)scan_1op_result(tmp, &expected_fail, token, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(tmp)) + } + ASSERT(strcmp(expected, expected_fail) == 0) + ASSERT(mpd_cmp_total(tmp, op) == 0) + + + /* make a copy of the operand */ + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + + calc = func(tmp, 1); + + /* compare the calculated result to the expected result */ + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp, op, token[0]); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + + mpd_set_alloc_fail(ctx); + calc = func(tmp, 1); + mpd_set_alloc(ctx); + + if (calc != NULL) { + break; + } + } + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp, op, token[0]); +} + +/* Quick and dirty: parse hex escape sequences as printed in bytestring + * output of Python3x. */ +static char * +parse_escapes(const char *s) +{ + char hex[5]; + char *result, *cp; + unsigned int u; + int n; + + cp = result = malloc(strlen(s)+1); + if (result == NULL) { + return NULL; + } + + hex[0] = '0'; + hex[1] = '\0'; + while (*s) { + if (*s == '\\' && *(s+1) == 'x') { + for (n = 1; n < 4; n++) { + if (!s[n]) { + free(result); + return NULL; + } + hex[n] = s[n]; + } + hex[n] = '\0'; + sscanf(hex, "%x%n", &u, &n); + *cp++ = u; + s += n; + } + else { + *cp++ = *s++; + } + } + + *cp = '\0'; + return result; +} + +/* + * Test a function returning pointer to char, accepting: + * op1, fmt, context + * + * This function is used for "mpd_format". + */ +static void +_cp_MpdFmtCtx(char **token, char *(*func)(const mpd_t *, const char *, mpd_context_t *), mpd_context_t *ctx) +{ + mpd_context_t maxctx; + char *fmt; + char *calc; + char *expected; + uint32_t expstatus; + int n; + + mpd_readcontext(&maxctx); + maxctx.traps = MPD_Malloc_error; + + /* conversion should be done as if there were no limits */ + n = scan_1op_str_result(op1, &fmt, &expected, token, &maxctx); + + fmt = parse_escapes(fmt); + expected = parse_escapes(expected); + + expstatus = scan_conditions(token+n); + + mpd_init_rand(tmp); + mpd_copy(tmp, op1, ctx); + ctx->status = 0; + + calc = func(tmp, fmt, ctx); + + if (calc == NULL) { + calc = strdup("NULL"); + } + /* compare the calculated result to the expected result */ + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp, op1, token[0]); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp); + mpd_copy(tmp, op1, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + calc = func(tmp, fmt, ctx); + mpd_set_alloc(ctx); + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(calc == NULL) + } + if (calc == NULL) { + calc = strdup("NULL"); + } + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp, op1, token[0]); + + free(fmt); + free(expected); +} + +/* + * Test a function returning pointer to const char, accepting: + * op1, context + */ +static void +_ccp_MpdCtx(char **token, const char *(*func)(const mpd_t *, const mpd_context_t *), mpd_context_t *ctx) +{ + mpd_context_t maxctx; + const char *calc; + char *expected; + uint32_t expstatus; + int n; + + mpd_readcontext(&maxctx); + maxctx.traps = MPD_Malloc_error; + + /* conversion should be done as if there were no limits */ + n = scan_1op_result(op, &expected, token, &maxctx); + + /* scan expected conditions */ + expstatus = scan_conditions(token+n); + + + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + ctx->status = 0; + + calc = func(tmp, ctx); + + compare_expected(calc, expected, expstatus, token[0], ctx); + check_equalmem(tmp, op, token[0]); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + calc = func(tmp, ctx); + mpd_set_alloc(ctx); + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(calc == NULL) + } + compare_expected(calc, expected, expstatus, token[0], ctx); + check_equalmem(tmp, op, token[0]); +} + +/* Test a unary function */ +static void +_Res_Op_Ctx(char *token[], void (*func)(mpd_t *, const mpd_t *, mpd_context_t *), mpd_context_t *ctx) +{ + mpd_context_t maxctx; + char *calc; + char *expected; + uint32_t expstatus; + int n, incr; + + mpd_readcontext(&maxctx); + maxctx.traps = MPD_Malloc_error; + + n = scan_1op_result(op, &expected, token, &maxctx); + + /* scan expected conditions */ + expstatus = scan_conditions(token+n); + + + /* result and tmp are distinct decimals */ + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + mpd_init_rand(result); + ctx->status = 0; + + mpd_set_alloc_count(ctx); + func(result, tmp, ctx); + mpd_set_alloc(ctx); + + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp, op, token[0]); + + /* Allocation failures */ + incr = 1; + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail += incr) { + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + mpd_minalloc(result); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(result, tmp, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(result)) + + if (alloc_fail > 50) { + incr = (int)(alloc_count*0.02) + 1; + } + } + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp, op, token[0]); + + + /* result equals operand */ + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + ctx->status = 0; + + mpd_set_alloc_count(ctx); + func(tmp, tmp, ctx); + mpd_set_alloc(ctx); + + calc = mpd_to_sci(tmp, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + + /* Allocation failures */ + incr = 1; + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail += incr) { + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(tmp, tmp, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(tmp)) + + if (alloc_fail > 50) { + incr = (int)(alloc_count*0.02) + 1; + } + } + calc = mpd_to_sci(tmp, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); +} + +/* Test a binary function */ +static void +_Res_Binop_Ctx(char *token[], void (*func)(mpd_t *, const mpd_t *, const mpd_t *, mpd_context_t *), mpd_context_t *ctx) +{ + mpd_context_t maxctx; + char *calc; + char *expected; + uint32_t expstatus; + int n, incr; + + mpd_readcontext(&maxctx); + maxctx.traps = MPD_Malloc_error; + + n = scan_2ops_result(op1, op2, &expected, token, &maxctx); + + /* scan expected conditions */ + expstatus = scan_conditions(token+n); + + + /* three distinct decimals */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_init_rand(result); + ctx->status = 0; + + mpd_set_alloc_count(ctx); + func(result, tmp1, tmp2, ctx); + mpd_set_alloc(ctx); + + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp1, op1, token[0]); + check_equalmem(tmp2, op2, token[0]); + + /* Allocation failures */ + incr = 1; + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail += incr) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_minalloc(result); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(result, tmp1, tmp2, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(result)) + + if (alloc_fail > 50) { + incr = (int)(alloc_count*0.02) + 1; + } + } + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp1, op1, token[0]); + check_equalmem(tmp2, op2, token[0]); + + + /* result == tmp1 */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + mpd_set_alloc_count(ctx); + func(tmp1, tmp1, tmp2, ctx); + mpd_set_alloc(ctx); + + calc = mpd_to_sci(tmp1, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp2, op2, token[0]); + + /* Allocation failures */ + incr = 1; + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail += incr) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(tmp1, tmp1, tmp2, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(tmp1)) + + if (alloc_fail > 50) { + incr = (int)(alloc_count*0.02) + 1; + } + } + calc = mpd_to_sci(tmp1, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp2, op2, token[0]); + + + /* result == tmp2 */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + mpd_set_alloc_count(ctx); + func(tmp2, tmp1, tmp2, ctx); + mpd_set_alloc(ctx); + + calc = mpd_to_sci(tmp2, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp1, op1, token[0]); + + /* Allocation failures */ + incr = 1; + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail += incr) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(tmp2, tmp1, tmp2, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(tmp2)) + + if (alloc_fail > 50) { + incr = (int)(alloc_count*0.02) + 1; + } + } + calc = mpd_to_sci(tmp2, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp1, op1, token[0]); +} + +/* Test a binary function where op1 == op2. */ +static void +_Res_EqualBinop_Ctx(char *token[], void (*func)(mpd_t *, const mpd_t *, const mpd_t *, mpd_context_t *), mpd_context_t *ctx) +{ + mpd_context_t maxctx; + char *calc; + char *expected; + uint32_t expstatus; + int n; + + mpd_readcontext(&maxctx); + maxctx.traps = MPD_Malloc_error; + + n = scan_1op_result(op, &expected, token, &maxctx); + + /* scan expected conditions */ + expstatus = scan_conditions(token+n); + + + /* equal operands, distinct result */ + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + mpd_init_rand(result); + ctx->status = 0; + + func(result, tmp, tmp, ctx); + + /* hack #1 to resolve disagreement with results generated by decimal.py */ + if (expstatus&MPD_Invalid_operation && ctx->status&MPD_Division_impossible) { + expstatus = MPD_Division_impossible; + } + /* hack #2 to resolve disagreement with results generated by decimal.py */ + if (expstatus&MPD_Invalid_operation && ctx->status&MPD_Division_undefined) { + expstatus = MPD_Division_undefined; + } + /* hack #3 to resolve disagreement with results generated by decimal.py (power) */ + if ((startswith(expected, "-0E") || startswith(expected, "0E")) && mpd_isnan(result)) { + expected = "NaN"; + expstatus = MPD_Invalid_operation; + } + + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp, op, token[0]); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + mpd_minalloc(result); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(result, tmp, tmp, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(result)) + } + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp, op, token[0]); + + + /* all parameters equal */ + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + ctx->status = 0; + + func(tmp, tmp, tmp, ctx); + + calc = mpd_to_sci(tmp, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(tmp, tmp, tmp, ctx); + mpd_set_alloc(ctx); + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(tmp)) + } + calc = mpd_to_sci(tmp, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); +} + +/* Test a binary function with a binary result */ +static void +_Binres_Binop_Ctx(char *token[], void (*func)(mpd_t *, mpd_t*, const mpd_t *, const mpd_t *, mpd_context_t *), mpd_context_t *ctx) +{ + mpd_context_t maxctx; + char *calc; + char *expected1, *expected2; + uint32_t expstatus; + int n, incr; + + mpd_readcontext(&maxctx); + maxctx.traps = MPD_Malloc_error; + + n = scan_2ops_2results(op1, op2, &expected1, &expected2, token, &maxctx); + + /* scan expected conditions */ + expstatus = scan_conditions(token+n); + + + /* four distinct decimals */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_init_rand(result1); + mpd_init_rand(result2); + ctx->status = 0; + + mpd_set_alloc_count(ctx); + func(result1, result2, tmp1, tmp2, ctx); + mpd_set_alloc(ctx); + + /* hack #1 to resolve disagreement with results generated by decimal.py */ + if (expstatus&MPD_Invalid_operation && ctx->status&MPD_Division_impossible) { + expstatus = MPD_Division_impossible; + } + /* hack #2 to resolve disagreement with results generated by decimal.py */ + if (expstatus&MPD_Invalid_operation && ctx->status&MPD_Division_undefined) { + expstatus = MPD_Division_undefined; + } + /* hack #3 to resolve disagreement with results generated by decimal.py */ + if ((startswith(expected1, "-Inf") || startswith(expected1, "Inf")) && mpd_isnan(result1)) { + expected1 = "NaN"; + } + + calc = mpd_to_sci(result1, 1); + compare_expected(calc, expected1, expstatus, token[0], ctx); + free(calc); + + calc = mpd_to_sci(result2, 1); + compare_expected(calc, expected2, expstatus, token[0], ctx); + free(calc); + + check_equalmem(tmp1, op1, token[0]); + check_equalmem(tmp2, op2, token[0]); + + /* Allocation failures */ + incr = 1; + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail += incr) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_minalloc(result1); + mpd_minalloc(result2); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(result1, result2, tmp1, tmp2, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(result1)) + ASSERT(mpd_isnan(result2)) + + if (alloc_fail > 50) { + incr = (int)(alloc_count*0.02) + 1; + } + } + calc = mpd_to_sci(result1, 1); + compare_expected(calc, expected1, expstatus, token[0], ctx); + free(calc); + + calc = mpd_to_sci(result2, 1); + compare_expected(calc, expected2, expstatus, token[0], ctx); + free(calc); + + check_equalmem(tmp1, op1, token[0]); + check_equalmem(tmp2, op2, token[0]); + + + /* result1 == tmp1 */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_init_rand(result2); + ctx->status = 0; + + mpd_set_alloc_count(ctx); + func(tmp1, result2, tmp1, tmp2, ctx); + mpd_set_alloc(ctx); + + calc = mpd_to_sci(tmp1, 1); + compare_expected(calc, expected1, expstatus, token[0], ctx); + free(calc); + + calc = mpd_to_sci(result2, 1); + compare_expected(calc, expected2, expstatus, token[0], ctx); + free(calc); + + check_equalmem(tmp2, op2, token[0]); + + /* Allocation failures */ + incr = 1; + for (alloc_fail = 1; alloc_fail <= INT_MAX; alloc_fail += incr) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_minalloc(result2); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(tmp1, result2, tmp1, tmp2, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(tmp1)) + ASSERT(mpd_isnan(result2)) + + if (alloc_fail > 50) { + incr = (int)(alloc_count*0.02) + 1; + } + } + calc = mpd_to_sci(tmp1, 1); + compare_expected(calc, expected1, expstatus, token[0], ctx); + free(calc); + + calc = mpd_to_sci(result2, 1); + compare_expected(calc, expected2, expstatus, token[0], ctx); + free(calc); + + check_equalmem(tmp2, op2, token[0]); + + + /* result2 == tmp1 */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_init_rand(result1); + ctx->status = 0; + + mpd_set_alloc_count(ctx); + func(result1, tmp1, tmp1, tmp2, ctx); + mpd_set_alloc(ctx); + + calc = mpd_to_sci(result1, 1); + compare_expected(calc, expected1, expstatus, token[0], ctx); + free(calc); + + calc = mpd_to_sci(tmp1, 1); + compare_expected(calc, expected2, expstatus, token[0], ctx); + free(calc); + + check_equalmem(tmp2, op2, token[0]); + + /* Allocation failures */ + incr = 1; + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail += incr) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_minalloc(result1); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(result1, tmp1, tmp1, tmp2, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(result1)) + ASSERT(mpd_isnan(tmp1)) + + if (alloc_fail > 50) { + incr = (int)(alloc_count*0.02) + 1; + } + } + calc = mpd_to_sci(result1, 1); + compare_expected(calc, expected1, expstatus, token[0], ctx); + free(calc); + + calc = mpd_to_sci(tmp1, 1); + compare_expected(calc, expected2, expstatus, token[0], ctx); + free(calc); + + check_equalmem(tmp2, op2, token[0]); + + + /* result1 == tmp2 */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_init_rand(result2); + ctx->status = 0; + + mpd_set_alloc_count(ctx); + func(tmp2, result2, tmp1, tmp2, ctx); + mpd_set_alloc(ctx); + + calc = mpd_to_sci(tmp2, 1); + compare_expected(calc, expected1, expstatus, token[0], ctx); + free(calc); + + calc = mpd_to_sci(result2, 1); + compare_expected(calc, expected2, expstatus, token[0], ctx); + free(calc); + + check_equalmem(tmp1, op1, token[0]); + + /* Allocation failures */ + incr = 1; + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail += incr) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_minalloc(result2); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(tmp2, result2, tmp1, tmp2, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(tmp2)) + ASSERT(mpd_isnan(result2)) + + if (alloc_fail > 50) { + incr = (int)(alloc_count*0.02) + 1; + } + } + calc = mpd_to_sci(tmp2, 1); + compare_expected(calc, expected1, expstatus, token[0], ctx); + free(calc); + + calc = mpd_to_sci(result2, 1); + compare_expected(calc, expected2, expstatus, token[0], ctx); + free(calc); + + check_equalmem(tmp1, op1, token[0]); + + + /* result2 == tmp2 */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_init_rand(result1); + ctx->status = 0; + + mpd_set_alloc_count(ctx); + func(result1, tmp2, tmp1, tmp2, ctx); + mpd_set_alloc(ctx); + + calc = mpd_to_sci(result1, 1); + compare_expected(calc, expected1, expstatus, token[0], ctx); + free(calc); + + calc = mpd_to_sci(tmp2, 1); + compare_expected(calc, expected2, expstatus, token[0], ctx); + free(calc); + + check_equalmem(tmp1, op1, token[0]); + + /* Allocation failures */ + incr = 1; + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail += incr) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_minalloc(result1); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(result1, tmp2, tmp1, tmp2, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(result1)) + ASSERT(mpd_isnan(tmp2)) + + if (alloc_fail > 50) { + incr = (int)(alloc_count*0.02) + 1; + } + } + calc = mpd_to_sci(result1, 1); + compare_expected(calc, expected1, expstatus, token[0], ctx); + free(calc); + + calc = mpd_to_sci(tmp2, 1); + compare_expected(calc, expected2, expstatus, token[0], ctx); + free(calc); + + check_equalmem(tmp1, op1, token[0]); + + + /* result1 == tmp1, result2 == tmp2 */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + mpd_set_alloc_count(ctx); + func(tmp1, tmp2, tmp1, tmp2, ctx); + mpd_set_alloc(ctx); + + calc = mpd_to_sci(tmp1, 1); + compare_expected(calc, expected1, expstatus, token[0], ctx); + free(calc); + + calc = mpd_to_sci(tmp2, 1); + compare_expected(calc, expected2, expstatus, token[0], ctx); + free(calc); + + /* Allocation failures */ + incr = 1; + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail += incr) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(tmp1, tmp2, tmp1, tmp2, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(tmp1)) + ASSERT(mpd_isnan(tmp2)) + + if (alloc_fail > 50) { + incr = (int)(alloc_count*0.02) + 1; + } + } + calc = mpd_to_sci(tmp1, 1); + compare_expected(calc, expected1, expstatus, token[0], ctx); + free(calc); + + calc = mpd_to_sci(tmp2, 1); + compare_expected(calc, expected2, expstatus, token[0], ctx); + free(calc); + + + /* result1 == tmp2, result2 == tmp1 */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + mpd_set_alloc_count(ctx); + func(tmp2, tmp1, tmp1, tmp2, ctx); + mpd_set_alloc(ctx); + + calc = mpd_to_sci(tmp2, 1); + compare_expected(calc, expected1, expstatus, token[0], ctx); + free(calc); + + calc = mpd_to_sci(tmp1, 1); + compare_expected(calc, expected2, expstatus, token[0], ctx); + free(calc); + + /* Allocation failures */ + incr = 1; + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail += incr) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(tmp2, tmp1, tmp1, tmp2, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(tmp2)) + ASSERT(mpd_isnan(tmp1)) + + if (alloc_fail > 50) { + incr = (int)(alloc_count*0.02) + 1; + } + } + calc = mpd_to_sci(tmp2, 1); + compare_expected(calc, expected1, expstatus, token[0], ctx); + free(calc); + + calc = mpd_to_sci(tmp1, 1); + compare_expected(calc, expected2, expstatus, token[0], ctx); + free(calc); +} + +/* Test a binary function with a binary result; equal operands */ +static void +_Binres_EqualBinop_Ctx(char *token[], void (*func)(mpd_t *, mpd_t*, const mpd_t *, const mpd_t *, mpd_context_t *), mpd_context_t *ctx) +{ + mpd_context_t maxctx; + char *calc; + char *expected1, *expected2; + uint32_t expstatus; + int n; + + mpd_readcontext(&maxctx); + maxctx.traps = MPD_Malloc_error; + + n = scan_1op_2results(op, &expected1, &expected2, token, &maxctx); + + /* scan expected conditions */ + expstatus = scan_conditions(token+n); + + + /* distinct results */ + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + mpd_init_rand(result1); + mpd_init_rand(result2); + ctx->status = 0; + + func(result1, result2, tmp, tmp, ctx); + + /* hack #1 to resolve disagreement with results generated by decimal.py */ + if (expstatus&MPD_Invalid_operation && ctx->status&MPD_Division_impossible) { + expstatus = MPD_Division_impossible; + } + /* hack #2 to resolve disagreement with results generated by decimal.py */ + if (expstatus&MPD_Invalid_operation && ctx->status&MPD_Division_undefined) { + expstatus = MPD_Division_undefined; + } + /* hack #3 to resolve disagreement with results generated by decimal.py */ + if ((startswith(expected1, "-Inf") || startswith(expected1, "Inf")) && mpd_isnan(result1)) { + expected1 = "NaN"; + } + + calc = mpd_to_sci(result1, 1); + compare_expected(calc, expected1, expstatus, token[0], ctx); + free(calc); + + calc = mpd_to_sci(result2, 1); + compare_expected(calc, expected2, expstatus, token[0], ctx); + free(calc); + + check_equalmem(tmp, op, token[0]); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + mpd_minalloc(result1); + mpd_minalloc(result2); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(result1, result2, tmp, tmp, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(result1)) + ASSERT(mpd_isnan(result2)) + } + calc = mpd_to_sci(result1, 1); + compare_expected(calc, expected1, expstatus, token[0], ctx); + free(calc); + + calc = mpd_to_sci(result2, 1); + compare_expected(calc, expected2, expstatus, token[0], ctx); + free(calc); + + check_equalmem(tmp, op, token[0]); + + + /* result1 == tmp */ + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + mpd_init_rand(result2); + ctx->status = 0; + + func(tmp, result2, tmp, tmp, ctx); + + calc = mpd_to_sci(tmp, 1); + compare_expected(calc, expected1, expstatus, token[0], ctx); + free(calc); + + calc = mpd_to_sci(result2, 1); + compare_expected(calc, expected2, expstatus, token[0], ctx); + free(calc); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + mpd_minalloc(result2); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(tmp, result2, tmp, tmp, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(tmp)) + ASSERT(mpd_isnan(result2)) + } + calc = mpd_to_sci(tmp, 1); + compare_expected(calc, expected1, expstatus, token[0], ctx); + free(calc); + + calc = mpd_to_sci(result2, 1); + compare_expected(calc, expected2, expstatus, token[0], ctx); + free(calc); + + + /* result2 == tmp */ + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + mpd_init_rand(result1); + ctx->status = 0; + + func(result1, tmp, tmp, tmp, ctx); + + calc = mpd_to_sci(result1, 1); + compare_expected(calc, expected1, expstatus, token[0], ctx); + free(calc); + + calc = mpd_to_sci(tmp, 1); + compare_expected(calc, expected2, expstatus, token[0], ctx); + free(calc); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + mpd_minalloc(result1); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(result1, tmp, tmp, tmp, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(result1)) + ASSERT(mpd_isnan(tmp)) + } + calc = mpd_to_sci(result1, 1); + compare_expected(calc, expected1, expstatus, token[0], ctx); + free(calc); + + calc = mpd_to_sci(tmp, 1); + compare_expected(calc, expected2, expstatus, token[0], ctx); + free(calc); +} + +/* Test a ternary function */ +static void +_Res_Ternop_Ctx(char *token[], void (*func)(mpd_t *, const mpd_t *, const mpd_t *, const mpd_t *, mpd_context_t *), mpd_context_t *ctx) +{ + mpd_context_t maxctx; + char *calc; + char *expected; + uint32_t expstatus; + int n, incr; + + mpd_readcontext(&maxctx); + maxctx.traps = MPD_Malloc_error; + + n = scan_3ops_result(op1, op2, op3, &expected, token, &maxctx); + + /* scan expected conditions */ + expstatus = scan_conditions(token+n); + + + /* four distinct decimals */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_init_rand(tmp3); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_copy(tmp3, op3, ctx); + mpd_init_rand(result); + ctx->status = 0; + + mpd_set_alloc_count(ctx); + func(result, tmp1, tmp2, tmp3, ctx); + mpd_set_alloc(ctx); + + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp1, op1, token[0]); + check_equalmem(tmp2, op2, token[0]); + check_equalmem(tmp3, op3, token[0]); + + /* Allocation failures */ + incr = 1; + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail += incr) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_init_rand(tmp3); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_copy(tmp3, op3, ctx); + mpd_minalloc(result); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(result, tmp1, tmp2, tmp3, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(result)) + + if (alloc_fail > 100) { + incr = (int)(alloc_count*0.02) + 1; + } + } + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp1, op1, token[0]); + check_equalmem(tmp2, op2, token[0]); + check_equalmem(tmp3, op3, token[0]); + + + /* result == tmp1 */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_init_rand(tmp3); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_copy(tmp3, op3, ctx); + ctx->status = 0; + + mpd_set_alloc_count(ctx); + func(tmp1, tmp1, tmp2, tmp3, ctx); + mpd_set_alloc(ctx); + + calc = mpd_to_sci(tmp1, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp2, op2, token[0]); + check_equalmem(tmp3, op3, token[0]); + + /* Allocation failures */ + incr = 1; + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail += incr) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_init_rand(tmp3); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_copy(tmp3, op3, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(tmp1, tmp1, tmp2, tmp3, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(tmp1)) + + if (alloc_fail > 100) { + incr = (int)(alloc_count*0.02) + 1; + } + } + calc = mpd_to_sci(tmp1, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp2, op2, token[0]); + check_equalmem(tmp3, op3, token[0]); + + + /* result == tmp2 */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_init_rand(tmp3); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_copy(tmp3, op3, ctx); + ctx->status = 0; + + mpd_set_alloc_count(ctx); + func(tmp2, tmp1, tmp2, tmp3, ctx); + mpd_set_alloc(ctx); + + calc = mpd_to_sci(tmp2, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp1, op1, token[0]); + check_equalmem(tmp3, op3, token[0]); + + /* Allocation failures */ + incr = 1; + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail += incr) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_init_rand(tmp3); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_copy(tmp3, op3, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(tmp2, tmp1, tmp2, tmp3, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(tmp2)) + + if (alloc_fail > 100) { + incr = (int)(alloc_count*0.02) + 1; + } + } + calc = mpd_to_sci(tmp2, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp1, op1, token[0]); + check_equalmem(tmp3, op3, token[0]); + + + /* result == tmp3 */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_init_rand(tmp3); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_copy(tmp3, op3, ctx); + ctx->status = 0; + + mpd_set_alloc_count(ctx); + func(tmp3, tmp1, tmp2, tmp3, ctx); + mpd_set_alloc(ctx); + + calc = mpd_to_sci(tmp3, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp1, op1, token[0]); + check_equalmem(tmp2, op2, token[0]); + + /* Allocation failures */ + incr = 1; + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail += incr) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_init_rand(tmp3); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_copy(tmp3, op3, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(tmp3, tmp1, tmp2, tmp3, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(tmp3)) + + if (alloc_fail > 100) { + incr = (int)(alloc_count*0.02) + 1; + } + } + calc = mpd_to_sci(tmp3, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp1, op1, token[0]); + check_equalmem(tmp2, op2, token[0]); +} + +/* Test a ternary function, first and second operand equal */ +static void +_Res_EqEqOp_Ctx(char *token[], void (*func)(mpd_t *, const mpd_t *, const mpd_t *, const mpd_t *, mpd_context_t *), mpd_context_t *ctx) +{ + mpd_context_t maxctx; + char *calc; + char *expected; + uint32_t expstatus; + int n; + + mpd_readcontext(&maxctx); + maxctx.traps = MPD_Malloc_error; + + n = scan_2ops_result(op1, op2, &expected, token, &maxctx); + + /* scan expected conditions */ + expstatus = scan_conditions(token+n); + + + /* distinct result */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_init_rand(result); + ctx->status = 0; + + func(result, tmp1, tmp1, tmp2, ctx); + + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp1, op1, token[0]); + check_equalmem(tmp2, op2, token[0]); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_minalloc(result); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(result, tmp1, tmp1, tmp2, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(result)) + } + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp1, op1, token[0]); + check_equalmem(tmp2, op2, token[0]); + + + /* result == tmp1 */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + func(tmp1, tmp1, tmp1, tmp2, ctx); + + calc = mpd_to_sci(tmp1, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp2, op2, token[0]); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(tmp1, tmp1, tmp1, tmp2, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(tmp1)) + } + calc = mpd_to_sci(tmp1, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp2, op2, token[0]); + + + /* result == tmp2 */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + func(tmp2, tmp1, tmp1, tmp2, ctx); + + calc = mpd_to_sci(tmp2, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp1, op1, token[0]); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(tmp2, tmp1, tmp1, tmp2, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(tmp2)) + } + calc = mpd_to_sci(tmp2, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp1, op1, token[0]); +} + +/* Test a ternary function, first and third operand equal */ +static void +_Res_EqOpEq_Ctx(char *token[], void (*func)(mpd_t *, const mpd_t *, const mpd_t *, const mpd_t *, mpd_context_t *), mpd_context_t *ctx) +{ + mpd_context_t maxctx; + char *calc; + char *expected; + uint32_t expstatus; + int n; + + mpd_readcontext(&maxctx); + maxctx.traps = MPD_Malloc_error; + + n = scan_2ops_result(op1, op2, &expected, token, &maxctx); + + /* scan expected conditions */ + expstatus = scan_conditions(token+n); + + + /* distinct result */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_init_rand(result); + ctx->status = 0; + + func(result, tmp1, tmp2, tmp1, ctx); + + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp1, op1, token[0]); + check_equalmem(tmp2, op2, token[0]); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_minalloc(result); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(result, tmp1, tmp2, tmp1, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(result)) + } + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp1, op1, token[0]); + check_equalmem(tmp2, op2, token[0]); + + + /* result == tmp1 */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + func(tmp1, tmp1, tmp2, tmp1, ctx); + + calc = mpd_to_sci(tmp1, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp2, op2, token[0]); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(tmp1, tmp1, tmp2, tmp1, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(tmp1)) + } + calc = mpd_to_sci(tmp1, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp2, op2, token[0]); + + + /* result == tmp2 */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + func(tmp2, tmp1, tmp2, tmp1, ctx); + + calc = mpd_to_sci(tmp2, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp1, op1, token[0]); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(tmp2, tmp1, tmp2, tmp1, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(tmp2)) + } + calc = mpd_to_sci(tmp2, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp1, op1, token[0]); +} + +/* Test a ternary function, second and third operand equal */ +static void +_Res_OpEqEq_Ctx(char *token[], void (*func)(mpd_t *, const mpd_t *, const mpd_t *, const mpd_t *, mpd_context_t *), mpd_context_t *ctx) +{ + mpd_context_t maxctx; + char *calc; + char *expected; + uint32_t expstatus; + int n; + + mpd_readcontext(&maxctx); + maxctx.traps = MPD_Malloc_error; + + n = scan_2ops_result(op1, op2, &expected, token, &maxctx); + + /* scan expected conditions */ + expstatus = scan_conditions(token+n); + + + /* distinct result */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_init_rand(result); + ctx->status = 0; + + func(result, tmp2, tmp1, tmp1, ctx); + + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp1, op1, token[0]); + check_equalmem(tmp2, op2, token[0]); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_minalloc(result); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(result, tmp2, tmp1, tmp1, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(result)) + } + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp1, op1, token[0]); + check_equalmem(tmp2, op2, token[0]); + + + /* result == tmp1 */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + func(tmp1, tmp2, tmp1, tmp1, ctx); + + calc = mpd_to_sci(tmp1, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp2, op2, token[0]); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(tmp1, tmp2, tmp1, tmp1, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(tmp1)) + } + calc = mpd_to_sci(tmp1, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp2, op2, token[0]); + + + /* result == tmp2 */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + func(tmp2, tmp2, tmp1, tmp1, ctx); + + calc = mpd_to_sci(tmp2, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp1, op1, token[0]); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(tmp2, tmp2, tmp1, tmp1, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(tmp2)) + } + calc = mpd_to_sci(tmp2, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp1, op1, token[0]); +} + +/* Test a ternary function, first, second and third operand equal */ +static void +_Res_EqEqEq_Ctx(char *token[], void (*func)(mpd_t *, const mpd_t *, const mpd_t *, const mpd_t *, mpd_context_t *), mpd_context_t *ctx) +{ + mpd_context_t maxctx; + char *calc; + char *expected; + uint32_t expstatus; + int n; + + mpd_readcontext(&maxctx); + maxctx.traps = MPD_Malloc_error; + + n = scan_1op_result(op, &expected, token, &maxctx); + + /* scan expected conditions */ + expstatus = scan_conditions(token+n); + + + /* distinct result */ + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + mpd_init_rand(result); + ctx->status = 0; + + func(result, tmp, tmp, tmp, ctx); + + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp, op, token[0]); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + mpd_minalloc(result); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(result, tmp, tmp, tmp, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(result)) + } + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp, op, token[0]); + + + /* result == tmp */ + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + ctx->status = 0; + + func(tmp, tmp, tmp, tmp, ctx); + + calc = mpd_to_sci(tmp, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(tmp, tmp, tmp, tmp, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(tmp)) + } + calc = mpd_to_sci(tmp, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); +} + +/* + * Test a binary function that returns an additional integer result. + * Used for the comparison functions. + */ +static void +_Int_Res_Binop_Ctx(char *token[], int (*func)(mpd_t *, const mpd_t *, const mpd_t *, mpd_context_t *), mpd_context_t *ctx) +{ + mpd_context_t maxctx; + char *calc; + char *expected; + int int_result; + char buf[11]; + uint32_t expstatus; + int n; + + mpd_readcontext(&maxctx); + maxctx.traps = MPD_Malloc_error; + + n = scan_2ops_result(op1, op2, &expected, token, &maxctx); + + /* scan expected conditions */ + expstatus = scan_conditions(token+n); + + + /* three distinct decimals */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_init_rand(result); + ctx->status = 0; + + int_result = func(result, tmp1, tmp2, ctx); + + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + snprintf(buf, 11, "%d", int_result); + if (int_result != INT_MAX) { /* NaN cases are skipped for the int_retval */ + compare_expected(buf, expected, expstatus, token[0], ctx); + } + check_equalmem(tmp1, op1, token[0]); + check_equalmem(tmp2, op2, token[0]); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_minalloc(result); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + int_result = func(result, tmp1, tmp2, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(result)) + } + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + snprintf(buf, 11, "%d", int_result); + if (int_result != INT_MAX) { /* NaN cases are skipped for the int_retval */ + compare_expected(buf, expected, expstatus, token[0], ctx); + } + check_equalmem(tmp1, op1, token[0]); + check_equalmem(tmp2, op2, token[0]); + + + /* result == tmp1 */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + int_result = func(tmp1, tmp1, tmp2, ctx); + + calc = mpd_to_sci(tmp1, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + snprintf(buf, 11, "%d", int_result); + if (int_result != INT_MAX) { /* NaN cases are skipped for the int_retval */ + compare_expected(buf, expected, expstatus, token[0], ctx); + } + check_equalmem(tmp2, op2, token[0]); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + int_result = func(tmp1, tmp1, tmp2, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(tmp1)) + } + calc = mpd_to_sci(tmp1, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + snprintf(buf, 11, "%d", int_result); + if (int_result != INT_MAX) { /* NaN cases are skipped for the int_retval */ + compare_expected(buf, expected, expstatus, token[0], ctx); + } + check_equalmem(tmp2, op2, token[0]); + + + + /* result == tmp2 */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + int_result = func(tmp2, tmp1, tmp2, ctx); + + calc = mpd_to_sci(tmp2, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + snprintf(buf, 11, "%d", int_result); + if (int_result != INT_MAX) { /* NaN cases are skipped for the int_retval */ + compare_expected(buf, expected, expstatus, token[0], ctx); + } + check_equalmem(tmp1, op1, token[0]); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + int_result = func(tmp2, tmp1, tmp2, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(tmp2)) + } + calc = mpd_to_sci(tmp2, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + snprintf(buf, 11, "%d", int_result); + if (int_result != INT_MAX) { /* NaN cases are skipped for the int_retval */ + compare_expected(buf, expected, expstatus, token[0], ctx); + } + check_equalmem(tmp1, op1, token[0]); +} + +/* + * Test a binary function that returns an additional integer result. + * Equal operands. + * Used for the comparison functions. + */ +static void +_Int_Res_EqualBinop_Ctx(char *token[], int (*func)(mpd_t *, const mpd_t *, const mpd_t *, mpd_context_t *), mpd_context_t *ctx) +{ + mpd_context_t maxctx; + char *calc; + char *expected; + int int_result; + char buf[11]; + uint32_t expstatus; + int n; + + mpd_readcontext(&maxctx); + maxctx.traps = MPD_Malloc_error; + + n = scan_1op_result(op, &expected, token, &maxctx); + + /* scan expected conditions */ + expstatus = scan_conditions(token+n); + + + /* equal operands */ + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + mpd_init_rand(result); + ctx->status = 0; + + int_result = func(result, tmp, tmp, ctx); + + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + snprintf(buf, 11, "%d", int_result); + if (int_result != INT_MAX) { /* NaN cases are skipped for the int_retval */ + compare_expected(buf, expected, expstatus, token[0], ctx); + } + check_equalmem(tmp, op, token[0]); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + mpd_minalloc(result); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + int_result = func(result, tmp, tmp, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(result)) + } + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + snprintf(buf, 11, "%d", int_result); + if (int_result != INT_MAX) { /* NaN cases are skipped for the int_retval */ + compare_expected(buf, expected, expstatus, token[0], ctx); + } + check_equalmem(tmp, op, token[0]); + + + /* all parameters equal */ + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + ctx->status = 0; + + int_result = func(tmp, tmp, tmp, ctx); + + calc = mpd_to_sci(tmp, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + snprintf(buf, 11, "%d", int_result); + if (int_result != INT_MAX) { /* NaN cases are skipped for the int_retval */ + compare_expected(buf, expected, expstatus, token[0], ctx); + } + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + int_result = func(tmp, tmp, tmp, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(tmp)) + } + calc = mpd_to_sci(tmp, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + snprintf(buf, 11, "%d", int_result); + if (int_result != INT_MAX) { /* NaN cases are skipped for the int_retval */ + compare_expected(buf, expected, expstatus, token[0], ctx); + } +} + +/* + * Test a binary function that returns an additional integer result. + * Function does not take a context argument. + * Used for the comparison functions. + */ +static void +_Int_Res_Binop(char *token[], int (*func)(mpd_t *, const mpd_t *, const mpd_t *), mpd_context_t *ctx) +{ + mpd_context_t maxctx; + char *calc; + char *expected; + int int_result; + char buf[11]; + uint32_t expstatus; + int n; + + mpd_readcontext(&maxctx); + maxctx.traps = MPD_Malloc_error; + + n = scan_2ops_result(op1, op2, &expected, token, &maxctx); + + /* scan expected conditions */ + expstatus = scan_conditions(token+n); + + + /* three distinct decimals */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_init_rand(result); + ctx->status = 0; + + int_result = func(result, tmp1, tmp2); + + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + snprintf(buf, 11, "%d", int_result); + if (int_result != INT_MAX) { /* NaN cases are skipped for the int_retval */ + compare_expected(buf, expected, expstatus, token[0], ctx); + } + check_equalmem(tmp1, op1, token[0]); + check_equalmem(tmp2, op2, token[0]); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + mpd_minalloc(result); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + int_result = func(result, tmp1, tmp2); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(result)) + } + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + snprintf(buf, 11, "%d", int_result); + if (int_result != INT_MAX) { /* NaN cases are skipped for the int_retval */ + compare_expected(buf, expected, expstatus, token[0], ctx); + } + check_equalmem(tmp1, op1, token[0]); + check_equalmem(tmp2, op2, token[0]); + + + /* result == tmp1 */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + int_result = func(tmp1, tmp1, tmp2); + + calc = mpd_to_sci(tmp1, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + snprintf(buf, 11, "%d", int_result); + if (int_result != INT_MAX) { /* NaN cases are skipped for the int_retval */ + compare_expected(buf, expected, expstatus, token[0], ctx); + } + check_equalmem(tmp2, op2, token[0]); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + int_result = func(tmp1, tmp1, tmp2); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(tmp1)) + } + calc = mpd_to_sci(tmp1, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + snprintf(buf, 11, "%d", int_result); + if (int_result != INT_MAX) { /* NaN cases are skipped for the int_retval */ + compare_expected(buf, expected, expstatus, token[0], ctx); + } + check_equalmem(tmp2, op2, token[0]); + + + /* result == tmp2 */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + int_result = func(tmp2, tmp1, tmp2); + + calc = mpd_to_sci(tmp2, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + snprintf(buf, 11, "%d", int_result); + if (int_result != INT_MAX) { /* NaN cases are skipped for the int_retval */ + compare_expected(buf, expected, expstatus, token[0], ctx); + } + check_equalmem(tmp1, op1, token[0]); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + int_result = func(tmp2, tmp1, tmp2); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(tmp2)) + } + calc = mpd_to_sci(tmp2, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + snprintf(buf, 11, "%d", int_result); + if (int_result != INT_MAX) { /* NaN cases are skipped for the int_retval */ + compare_expected(buf, expected, expstatus, token[0], ctx); + } + check_equalmem(tmp1, op1, token[0]); +} + +/* + * Test a binary function that returns an additional integer result. + * Function does not take a context argument. + * Equal operands. + * Used for the comparison functions. + */ +static void +_Int_Res_EqualBinop(char *token[], int (*func)(mpd_t *, const mpd_t *, const mpd_t *), mpd_context_t *ctx) +{ + mpd_context_t maxctx; + char *calc; + char *expected; + int int_result; + char buf[11]; + uint32_t expstatus; + int n; + + mpd_readcontext(&maxctx); + maxctx.traps = MPD_Malloc_error; + + n = scan_1op_result(op, &expected, token, &maxctx); + + /* scan expected conditions */ + expstatus = scan_conditions(token+n); + + + /* equal operands */ + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + mpd_init_rand(result); + ctx->status = 0; + + int_result = func(result, tmp, tmp); + + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + snprintf(buf, 11, "%d", int_result); + if (int_result != INT_MAX) { /* NaN cases are skipped for the int_retval */ + compare_expected(buf, expected, expstatus, token[0], ctx); + } + check_equalmem(tmp, op, token[0]); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + mpd_minalloc(result); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + int_result = func(result, tmp, tmp); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(result)) + } + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + snprintf(buf, 11, "%d", int_result); + if (int_result != INT_MAX) { /* NaN cases are skipped for the int_retval */ + compare_expected(buf, expected, expstatus, token[0], ctx); + } + check_equalmem(tmp, op, token[0]); + + + /* all parameters equal */ + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + ctx->status = 0; + + int_result = func(tmp, tmp, tmp); + + calc = mpd_to_sci(tmp, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + snprintf(buf, 11, "%d", int_result); + if (int_result != INT_MAX) { /* NaN cases are skipped for the int_retval */ + compare_expected(buf, expected, expstatus, token[0], ctx); + } + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + int_result = func(tmp, tmp, tmp); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(tmp)) + } + calc = mpd_to_sci(tmp, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + snprintf(buf, 11, "%d", int_result); + if (int_result != INT_MAX) { /* NaN cases are skipped for the int_retval */ + compare_expected(buf, expected, expstatus, token[0], ctx); + } +} + +/* + * Test a binary function that returns only an integer result. + * Used for the cmp functions. + */ +enum {SKIP_NONE, SKIP_NAN, SKIP_NONINT}; +static void +_Int_Binop_Ctx(int skip, char *token[], int (*func)(const mpd_t *, const mpd_t *, mpd_context_t *), mpd_context_t *ctx) +{ + mpd_context_t maxctx; + int int_result; + char buf[11]; + char *expected; + uint32_t expstatus; + int n; + + mpd_readcontext(&maxctx); + maxctx.traps = MPD_Malloc_error; + + n = scan_2ops_result(op1, op2, &expected, token, &maxctx); + + /* scan expected conditions */ + expstatus = scan_conditions(token+n); + + + /* two distinct decimals */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + int_result = func(tmp1, tmp2, ctx); + + snprintf(buf, 11, "%d", int_result); + if (!(skip && int_result == INT_MAX)) { /* NaN cases are skipped for the int_retval */ + compare_expected(buf, expected, expstatus, token[0], ctx); + } + check_equalmem(tmp1, op1, token[0]); + check_equalmem(tmp2, op2, token[0]); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + int_result = func(tmp1, tmp2, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(int_result== INT_MAX) + } + snprintf(buf, 11, "%d", int_result); + if (!(skip && int_result == INT_MAX)) { /* NaN cases are skipped for the int_retval */ + compare_expected(buf, expected, expstatus, token[0], ctx); + } + check_equalmem(tmp1, op1, token[0]); + check_equalmem(tmp2, op2, token[0]); +} + +/* + * Test a binary function that returns only an integer result. + * Equal operands. + * Used for the cmp functions. + */ +static void +_Int_EqualBinop_Ctx(int skip, char *token[], int (*func)(const mpd_t *, const mpd_t *, mpd_context_t *), mpd_context_t *ctx) +{ + mpd_context_t maxctx; + int int_result; + char buf[11]; + char *expected; + uint32_t expstatus; + int n; + + mpd_readcontext(&maxctx); + maxctx.traps = MPD_Malloc_error; + + n = scan_1op_result(op, &expected, token, &maxctx); + + /* scan expected conditions */ + expstatus = scan_conditions(token+n); + + + /* equal operands */ + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + ctx->status = 0; + + int_result = func(tmp, tmp, ctx); + + snprintf(buf, 11, "%d", int_result); + if (!(skip && int_result == INT_MAX)) { /* NaN cases are skipped for the int_retval */ + compare_expected(buf, expected, expstatus, token[0], ctx); + } + check_equalmem(tmp, op, token[0]); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + int_result = func(tmp, tmp, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(int_result== INT_MAX) + } + snprintf(buf, 11, "%d", int_result); + if (!(skip && int_result == INT_MAX)) { /* NaN cases are skipped for the int_retval */ + compare_expected(buf, expected, expstatus, token[0], ctx); + } + check_equalmem(tmp, op, token[0]); +} + +/* + * Test a binary function that returns an int. + * The function does not take a context argument. + */ +static void +_Int_Binop(char *token[], int (*func)(const mpd_t *, const mpd_t *), mpd_context_t *ctx) +{ + mpd_context_t maxctx; + int int_result; + char buf[11]; + char *expected; + uint32_t expstatus; + int n; + + mpd_readcontext(&maxctx); + maxctx.traps = MPD_Malloc_error; + + n = scan_2ops_result(op1, op2, &expected, token, &maxctx); + + /* scan expected conditions */ + expstatus = scan_conditions(token+n); + + + /* two distinct decimals */ + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + int_result = func(tmp1, tmp2); + + snprintf(buf, 11, "%d", int_result); + compare_expected(buf, expected, expstatus, token[0], ctx); + check_equalmem(tmp1, op1, token[0]); + check_equalmem(tmp2, op2, token[0]); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp1); + mpd_init_rand(tmp2); + mpd_copy(tmp1, op1, ctx); + mpd_copy(tmp2, op2, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + int_result = func(tmp1, tmp2); + mpd_set_alloc(ctx); + + if (int_result != INT_MAX) { + break; + } + } + snprintf(buf, 11, "%d", int_result); + compare_expected(buf, expected, expstatus, token[0], ctx); + check_equalmem(tmp1, op1, token[0]); + check_equalmem(tmp2, op2, token[0]); +} + +/* + * Test a binary function that returns an int. + * Equal operands. + * The function does not take a context argument. + */ +static void +_Int_EqualBinop(char *token[], int (*func)(const mpd_t *, const mpd_t *), mpd_context_t *ctx) +{ + mpd_context_t maxctx; + int int_result; + char buf[11]; + char *expected; + uint32_t expstatus; + int n; + + mpd_readcontext(&maxctx); + maxctx.traps = MPD_Malloc_error; + + n = scan_1op_result(op, &expected, token, &maxctx); + + /* scan expected conditions */ + expstatus = scan_conditions(token+n); + + + /* equal operands */ + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + ctx->status = 0; + + int_result = func(tmp, tmp); + + snprintf(buf, 11, "%d", int_result); + compare_expected(buf, expected, expstatus, token[0], ctx); + check_equalmem(tmp, op, token[0]); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + int_result = func(tmp, tmp); + mpd_set_alloc(ctx); + + if (int_result != INT_MAX) { + break; + } + } + snprintf(buf, 11, "%d", int_result); + compare_expected(buf, expected, expstatus, token[0], ctx); + check_equalmem(tmp, op, token[0]); +} + +static mpd_ssize_t +scan_ssize(char *token[]) +{ + errno = 0; + if (token[1] == NULL) { + errno = 1; + return MPD_SSIZE_MAX; + } + return mpd_strtossize(token[1], NULL, 10); +} + +/* + * Test a function with an mpd_t and an mpd_ssize_t operand. + * Used for the shift functions. + */ +static void +_Res_Op_Lsize_Ctx(int skip, char *token[], void (*func)(mpd_t *, const mpd_t *, mpd_ssize_t, mpd_context_t *), mpd_context_t *ctx) +{ + mpd_context_t maxctx; + char *calc; + char *expected; + uint32_t expstatus; + mpd_ssize_t ssize; + int n; + + mpd_readcontext(&maxctx); + maxctx.traps = MPD_Malloc_error; + + n = scan_2ops_result(op1, op2, &expected, token, &maxctx); + + /* scan expected conditions */ + expstatus = scan_conditions(token+n); + + + /* only integers are allowed for ssize */ + if (skip && (mpd_isspecial(op2) || op2->exp != 0)) { + /* fprintf(stderr, "SKIP: %s\n", token[0]); */ + return; + } + ssize = mpd_get_ssize(op2, &maxctx); + if (maxctx.status&MPD_Invalid_operation) { + return; + } + + /* two distinct decimals */ + mpd_init_rand(tmp1); + mpd_copy(tmp1, op1, ctx); + mpd_init_rand(result); + ctx->status = 0; + + func(result, tmp1, ssize, ctx); + + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp1, op1, token[0]); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp1); + mpd_copy(tmp1, op1, ctx); + mpd_minalloc(result); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(result, tmp1, ssize, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(result)) + } + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + check_equalmem(tmp1, op1, token[0]); + + + /* result == tmp1 */ + mpd_init_rand(tmp1); + mpd_copy(tmp1, op1, ctx); + ctx->status = 0; + + func(tmp1, tmp1, ssize, ctx); + + calc = mpd_to_sci(tmp1, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); + + /* Allocation failures */ + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + mpd_init_rand(tmp1); + mpd_copy(tmp1, op1, ctx); + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + func(tmp1, tmp1, ssize, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(tmp1)) + } + calc = mpd_to_sci(tmp1, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + free(calc); +} + +static void +_Baseconv(char *token[], mpd_context_t *ctx) +{ + mpd_context_t maxctx; + uint32_t base; + uint16_t *data16; + uint32_t *data32; + size_t len16, len32; + size_t exp_len16, exp_len32; + char *expected; + uint32_t expstatus; + char *calc; + int n = 0; + int i, iter = 0; + + mpd_readcontext(&maxctx); + maxctx.traps = MPD_Malloc_error; + + n = scan_1op_result(op1, &expected, token, &maxctx); + ASSERT(mpd_isinteger(op1)) + + /* scan expected conditions */ + expstatus = scan_conditions(token+n); + + base = (1<<15); + len16 = mpd_sizeinbase(op1, base); + data16 = mpd_alloc((mpd_size_t)len16, sizeof *data16); + exp_len16 = mpd_export_u16(data16, len16, base, op1, ctx); + if (exp_len16 == SIZE_MAX) { + mpd_err_fatal("export_to_base failed"); + } + + mpd_import_u16(result, data16, exp_len16, MPD_POS, base, ctx); + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + + mpd_free(calc); + mpd_free(data16); + + /* Allocation failures */ + base = (1<<15); + len16 = mpd_sizeinbase(op1, base); + data16 = mpd_alloc((mpd_size_t)len16, sizeof *data16); + + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + exp_len16 = mpd_export_u16(data16, len16, base, op1, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(exp_len16 == SIZE_MAX) + } + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + mpd_import_u16(result, data16, exp_len16, MPD_POS, base, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(result)) + } + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + mpd_free(calc); + mpd_free(data16); + + + base = (1U<<16); + len16 = mpd_sizeinbase(op1, base); + data16 = mpd_alloc((mpd_size_t)len16, sizeof *data16); + len16 = mpd_export_u16(data16, len16, base, op1, ctx); + if (len16 == SIZE_MAX) { + mpd_err_fatal("export_to_base failed"); + } + + mpd_import_u16(result, data16, len16, MPD_POS, base, ctx); + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + + mpd_free(calc); + mpd_free(data16); + + + base = 9999; + len16 = mpd_sizeinbase(op1, base); + data16 = mpd_alloc((mpd_size_t)len16, sizeof *data16); + exp_len16 = mpd_export_u16(data16, len16, base, op1, ctx); + if (exp_len16 == SIZE_MAX) { + mpd_err_fatal("export_to_base failed"); + } + + mpd_import_u16(result, data16, exp_len16, MPD_POS, base, ctx); + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + + mpd_free(calc); + mpd_free(data16); + + +#ifdef RT_EXT_BASECONV + iter = 16; +#endif + for (i = 2; i <= iter; i++) { + + base = i; + len16 = mpd_sizeinbase(op1, base); + data16 = mpd_alloc((mpd_size_t)len16, sizeof *data16); + len16 = mpd_export_u16(data16, len16, base, op1, ctx); + if (len16 == SIZE_MAX) { + mpd_err_fatal("export_to_base failed"); + } + + mpd_import_u16(result, data16, len16, MPD_POS, base, ctx); + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + + mpd_free(calc); + mpd_free(data16); + } + +#ifdef RT_EXT_BASECONV + iter = 100; +#endif + for (i = 0; i < iter; i++) { + + base = random() % UINT16_MAX; + if (base < 2) base = 2; + + len16 = mpd_sizeinbase(op1, base); + data16 = mpd_alloc((mpd_size_t)len16, sizeof *data16); + len16 = mpd_export_u16(data16, len16, base, op1, ctx); + if (len16 == SIZE_MAX) { + mpd_err_fatal("export_to_base failed"); + } + + mpd_import_u16(result, data16, len16, MPD_POS, base, ctx); + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + + mpd_free(calc); + mpd_free(data16); + } + + + base = 1000000000; + len32 = mpd_sizeinbase(op1, base); + data32 = mpd_alloc((mpd_size_t)len32, sizeof *data32); + exp_len32 = mpd_export_u32(data32, len32, base, op1, ctx); + if (exp_len32 == SIZE_MAX) { + mpd_err_fatal("export_to_base failed"); + } + + mpd_import_u32(result, data32, len32, MPD_POS, base, ctx); + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + + mpd_free(calc); + mpd_free(data32); + + /* Allocation failures */ + base = 1000000000; + len32 = mpd_sizeinbase(op1, base); + data32 = mpd_alloc((mpd_size_t)len32, sizeof *data32); + + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + exp_len32 = mpd_export_u32(data32, len32, base, op1, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(exp_len32 == SIZE_MAX) + } + for (alloc_fail = 1; alloc_fail < INT_MAX; alloc_fail++) { + ctx->status = 0; + + mpd_set_alloc_fail(ctx); + mpd_import_u32(result, data32, exp_len32, MPD_POS, base, ctx); + mpd_set_alloc(ctx); + + if (!(ctx->status&MPD_Malloc_error)) { + break; + } + ASSERT(mpd_isnan(result)) + } + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + mpd_free(calc); + mpd_free(data32); + + + base = (1<<30); + len32 = mpd_sizeinbase(op1, base); + data32 = mpd_alloc((mpd_size_t)len32, sizeof *data32); + len32 = mpd_export_u32(data32, len32, base, op1, ctx); + if (len32 == SIZE_MAX) { + mpd_err_fatal("export_to_base failed"); + } + + mpd_import_u32(result, data32, len32, MPD_POS, base, ctx); + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + + mpd_free(calc); + mpd_free(data32); + + for (i = 2; i <= 16; i++) { + + base = i; + len32 = mpd_sizeinbase(op1, base); + data32 = mpd_alloc((mpd_size_t)len32, sizeof *data32); + len32 = mpd_export_u32(data32, len32, base, op1, ctx); + if (len32 == SIZE_MAX) { + mpd_err_fatal("export_to_base failed"); + } + + mpd_import_u32(result, data32, len32, MPD_POS, base, ctx); + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + + mpd_free(calc); + mpd_free(data32); + } + + for (i = 0; i < 100; i++) { + + base = random() % UINT32_MAX; + if (base < 2) base = 2; + + len32 = mpd_sizeinbase(op1, base); + data32 = mpd_alloc((mpd_size_t)len32, sizeof *data32); + len32 = mpd_export_u32(data32, len32, base, op1, ctx); + if (len32 == SIZE_MAX) { + mpd_err_fatal("export_to_base failed"); + } + + mpd_import_u32(result, data32, len32, MPD_POS, base, ctx); + calc = mpd_to_sci(result, 1); + compare_expected(calc, expected, expstatus, token[0], ctx); + + mpd_free(calc); + mpd_free(data32); + } +} + +/* + * Test a function returning an mpd_uint_t, accepting: + * op, context + * + * This function is used for: + * - mpd_get_uint + * - mpd_abs_uint + * - mpd_get_u64 + * - mpd_get_u32 + */ +static void +_uint_MpdCtx(char **token, mpd_uint_t (*func)(const mpd_t *, mpd_context_t *), mpd_context_t *ctx) +{ + mpd_context_t maxctx; + mpd_uint_t calc_uint; + char calc[23]; + char *expected; + uint32_t expstatus; + int n; + + mpd_readcontext(&maxctx); + maxctx.traps = MPD_Malloc_error; + + /* conversion should be done as if there were no limits */ + n = scan_1op_result(op, &expected, token, &maxctx); + + expstatus = scan_conditions(token+n); + + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + ctx->status = 0; + + calc_uint = func(tmp, ctx); + snprintf(calc, 23, "%" PRI_mpd_size_t, calc_uint); + + /* compare the calculated result to the expected result */ + compare_expected(calc, expected, expstatus, token[0], ctx); + check_equalmem(tmp, op, token[0]); +} + +/* + * Test a function returning an mpd_ssize_t, accepting: + * op, fmt, context + * + * This function is used for: + * - mpd_get_ssize + * - mpd_get_i64 + * - mpd_get_i32 + */ +static void +_ssize_MpdCtx(char **token, mpd_ssize_t (*func)(const mpd_t *, mpd_context_t *), mpd_context_t *ctx) +{ + mpd_context_t maxctx; + mpd_ssize_t calc_ssize; + char calc[23]; + char *expected; + uint32_t expstatus; + int n; + + mpd_readcontext(&maxctx); + maxctx.traps = MPD_Malloc_error; + + /* conversion should be done as if there were no limits */ + n = scan_1op_result(op, &expected, token, &maxctx); + + expstatus = scan_conditions(token+n); + + mpd_init_rand(tmp); + mpd_copy(tmp, op, ctx); + ctx->status = 0; + + calc_ssize = func(tmp, ctx); + snprintf(calc, 23, "%" PRI_mpd_ssize_t, calc_ssize); + + /* compare the calculated result to the expected result */ + compare_expected(calc, expected, expstatus, token[0], ctx); + check_equalmem(tmp, op, token[0]); +} + + +/* process a file */ +static void +doit(char *filename) +{ + FILE *file; + mpd_context_t ctx; + char *line; + char *tmpline; + char *token[MAXTOKEN+1]; + uint32_t testno; + mpd_ssize_t l; + + + mpd_testcontext(&ctx); + + ctx.traps = MPD_Malloc_error; + + if (strcmp(filename, "-") == 0) { + file = stdin; + } + else { + if ((file = fopen(filename, "r")) == NULL) { + mpd_err_fatal("could not open %s", filename); + } + } + + if ((line = mpd_alloc(MAXLINE+1, sizeof *line)) == NULL) { + mpd_err_fatal("out of memory"); + } + if ((tmpline = mpd_alloc(MAXLINE+1, sizeof *line)) == NULL) { + mpd_err_fatal("out of memory"); + } + + + while (fgets(line, MAXLINE+1, file) != NULL) { + + /* split a line into tokens */ + strcpy(tmpline, line); + if (split(token, tmpline) == 0) { + goto cleanup; + } + + + /* comments */ + if (startswith(token[0], "--")) { + goto cleanup; + } + /* end comments */ + + /* skip bool* tests in extra.decTest */ + if (startswith(token[0], "bool")) { + goto cleanup; + } + /* end skips */ + + + /* directives */ + if (startswith(token[0], "Precision")) { + l = scan_ssize(token); + if (errno != 0) { + mpd_err_fatal("%s: %s", filename, line); + } + /*if (!mpd_qsetprec(&ctx, l)) { + mpd_err_fatal("%s: %s", filename, line); + }*/ + /* use a wider range than officially allowed */ + ctx.prec = l; + goto cleanup; + } + + if (startswith(token[0], "Rounding")) { + if (eqtoken(token[1], "Ceiling")) + ctx.round = MPD_ROUND_CEILING; + else if (eqtoken(token[1], "Up")) + ctx.round = MPD_ROUND_UP; + else if (eqtoken(token[1], "Half_up")) + ctx.round = MPD_ROUND_HALF_UP; + else if (eqtoken(token[1], "Half_even")) + ctx.round = MPD_ROUND_HALF_EVEN; + else if (eqtoken(token[1], "Half_down")) + ctx.round = MPD_ROUND_HALF_DOWN; + else if (eqtoken(token[1], "Down")) + ctx.round = MPD_ROUND_DOWN; + else if (eqtoken(token[1], "Floor")) + ctx.round = MPD_ROUND_FLOOR; + else if (eqtoken(token[1], "05up")) + ctx.round = MPD_ROUND_05UP; + else + mpd_err_fatal("%s: %s", filename, line); + goto cleanup; + } + + if (startswith(token[0], "MaxExponent")) { + l = scan_ssize(token); + if (errno != 0) { + mpd_err_fatal("%s: %s", filename, line); + } + /*if (!mpd_qsetemax(&ctx, l)) { + mpd_err_fatal("%s: %s", filename, line); + }*/ + /* use a wider range than officially allowed */ + ctx.emax = l; + goto cleanup; + } + + if (startswith(token[0], "MinExponent")) { + l = scan_ssize(token); + if (errno != 0) { + mpd_err_fatal("%s: %s", filename, line); + } + /*if (!mpd_qsetemin(&ctx, l)) { + mpd_err_fatal("%s: %s", filename, line); + }*/ + /* use a wider range than officially allowed */ + ctx.emin = l; + goto cleanup; + } + + if (startswith(token[0], "Dectest")) { + if (token[1] == NULL) { + mpd_err_fatal("%s: %s", filename, line); + } + doit(token[1]); + goto cleanup; + } + /* end directives */ + + + /* optional directives */ + if (startswith(token[0], "Version")) { + goto cleanup; + } + + if (startswith(token[0], "Extended")) { + goto cleanup; + } + + if (startswith(token[0], "Clamp")) { + l = scan_ssize(token); + if (errno != 0) { + mpd_err_fatal("%s: %s", filename, line); + } + if (!mpd_qsetclamp(&ctx, (int)l)) { + mpd_err_fatal("%s: %s", filename, line); + } + goto cleanup; + } + if (startswith(token[0], "Locale")) { + if (token[1] == NULL) { + mpd_err_fatal("%s: %s", filename, line); + } + fprintf(stderr, "locale: %s\n", token[1]); + if (setlocale(LC_NUMERIC, token[1]) == NULL) { + mpd_err_fatal("%s: %s", filename, line); + } + goto cleanup; + } + /* end optional directives */ + + + /* + * Actual tests start here: + * - token[0] is the id + * - token[1] is the operation type + * - testno can be used for setting a watchpoint in the debugger + */ + testno = get_testno(token[0]); + (void)testno; + + /* The id is in the skip list */ + if (check_skip(token[0])) { + goto cleanup; + } +#ifdef CONFIG_32 + /* Skip coverage tests with excessive run time. */ + if (startswith(token[0], "cov64")) { + goto cleanup; + } +#endif + /* Translate operation type for powmod */ + if (startswith(token[0], "pwmx")) { + free(token[1]); + token[1] = malloc(sizeof("powmod")); + strcpy(token[1], "powmod"); + } + /* end skips */ + + + /* Unary functions with char * result */ + if (eqtoken(token[1], "tosci") || eqtoken(token[1], "apply")) { + _cp_MpdCtx(token, mpd_to_sci, &ctx); + } + else if (eqtoken(token[1], "toeng")) { + _cp_MpdCtx(token, mpd_to_eng, &ctx); + } + else if (eqtoken(token[1], "format")) { + _cp_MpdFmtCtx(token, mpd_format, &ctx); + } + /* Unary function with const char * result */ + else if (eqtoken(token[1], "class")) { + _ccp_MpdCtx(token, mpd_class, &ctx); + } + + /* Unary functions with mpd_t * result */ + else if (eqtoken(token[1], "abs")) { + _Res_Op_Ctx(token, mpd_abs, &ctx); + } + else if (eqtoken(token[1], "copy")) { + _Res_Op_Ctx(token, mpd_copy, &ctx); + } + else if (eqtoken(token[1], "copyabs")) { + _Res_Op_Ctx(token, mpd_copy_abs, &ctx); + } + else if (eqtoken(token[1], "copynegate")) { + _Res_Op_Ctx(token, mpd_copy_negate, &ctx); + } + else if (eqtoken(token[1], "exp")) { + ctx.allcr = 0; + _Res_Op_Ctx(token, mpd_exp, &ctx); + ctx.allcr = 1; + _Res_Op_Ctx(token, mpd_exp, &ctx); + } + else if (eqtoken(token[1], "invert")) { + _Res_Op_Ctx(token, mpd_invert, &ctx); + } + else if (eqtoken(token[1], "invroot")) { + _Res_Op_Ctx(token, mpd_invroot, &ctx); + } + else if (eqtoken(token[1], "ln")) { + ctx.allcr = 0; + _Res_Op_Ctx(token, mpd_ln, &ctx); + ctx.allcr = 1; + _Res_Op_Ctx(token, mpd_ln, &ctx); + } + else if (eqtoken(token[1], "log10")) { + ctx.allcr = 0; + _Res_Op_Ctx(token, mpd_log10, &ctx); + ctx.allcr = 1; + _Res_Op_Ctx(token, mpd_log10, &ctx); + } + else if (eqtoken(token[1], "logb")) { + _Res_Op_Ctx(token, mpd_logb, &ctx); + } + else if (eqtoken(token[1], "minus")) { + _Res_Op_Ctx(token, mpd_minus, &ctx); + } + else if (eqtoken(token[1], "nextminus")) { + _Res_Op_Ctx(token, mpd_next_minus, &ctx); + } + else if (eqtoken(token[1], "nextplus")) { + _Res_Op_Ctx(token, mpd_next_plus, &ctx); + } + else if (eqtoken(token[1], "plus")) { + _Res_Op_Ctx(token, mpd_plus, &ctx); + } + else if (eqtoken(token[1], "reduce")) { + _Res_Op_Ctx(token, mpd_reduce, &ctx); + } + else if (eqtoken(token[1], "squareroot")) { + _Res_Op_Ctx(token, mpd_sqrt, &ctx); + } + else if (eqtoken(token[1], "tointegral")) { + _Res_Op_Ctx(token, mpd_round_to_int, &ctx); + } + else if (eqtoken(token[1], "tointegralx")) { + _Res_Op_Ctx(token, mpd_round_to_intx, &ctx); + } + else if (eqtoken(token[1], "floor")) { + _Res_Op_Ctx(token, mpd_floor, &ctx); + } + else if (eqtoken(token[1], "ceil")) { + _Res_Op_Ctx(token, mpd_ceil, &ctx); + } + else if (eqtoken(token[1], "trunc")) { + _Res_Op_Ctx(token, mpd_trunc, &ctx); + } + + + /* Binary function returning an int */ + else if (eqtoken(token[1], "samequantum")) { + _Int_Binop(token, mpd_same_quantum, &ctx); + } + /* Binary function returning an int, equal operands */ + else if (eqtoken(token[1], "samequantum_eq")) { + _Int_EqualBinop(token, mpd_same_quantum, &ctx); + } + + /* Binary functions with mpd_t * result */ + else if (eqtoken(token[1], "add")) { + _Res_Binop_Ctx(token, mpd_add, &ctx); + } + else if (eqtoken(token[1], "and")) { + _Res_Binop_Ctx(token, mpd_and, &ctx); + } + else if (eqtoken(token[1], "copysign")) { + _Res_Binop_Ctx(token, mpd_copy_sign, &ctx); + } + else if (eqtoken(token[1], "divide")) { + _Res_Binop_Ctx(token, mpd_div, &ctx); + _Res_Binop_Ctx(token, mpd_test_newtondiv, &ctx); + } + else if (eqtoken(token[1], "divideint")) { + _Res_Binop_Ctx(token, mpd_divint, &ctx); + _Res_Binop_Ctx(token, mpd_test_newtondivint, &ctx); + } + else if (eqtoken(token[1], "max")) { + _Res_Binop_Ctx(token, mpd_max, &ctx); + } + else if (eqtoken(token[1], "maxmag")) { + _Res_Binop_Ctx(token, mpd_max_mag, &ctx); + } + else if (eqtoken(token[1], "min")) { + _Res_Binop_Ctx(token, mpd_min, &ctx); + } + else if (eqtoken(token[1], "minmag")) { + _Res_Binop_Ctx(token, mpd_min_mag, &ctx); + } + else if (eqtoken(token[1], "multiply")) { + _Res_Binop_Ctx(token, mpd_mul, &ctx); + } + else if (eqtoken(token[1], "nexttoward")) { + _Res_Binop_Ctx(token, mpd_next_toward, &ctx); + } + else if (eqtoken(token[1], "or")) { + _Res_Binop_Ctx(token, mpd_or, &ctx); + } + else if (eqtoken(token[1], "power")) { + ctx.allcr = 0; + _Res_Binop_Ctx(token, mpd_pow, &ctx); + ctx.allcr = 1; + _Res_Binop_Ctx(token, mpd_pow, &ctx); + } + else if (eqtoken(token[1], "quantize")) { + _Res_Binop_Ctx(token, mpd_quantize, &ctx); + } + else if (eqtoken(token[1], "resc")) { + _Res_Op_Lsize_Ctx(SKIP_NONINT, token, mpd_rescale, &ctx); + } + else if (eqtoken(token[1], "remainder")) { + _Res_Binop_Ctx(token, mpd_rem, &ctx); + _Res_Binop_Ctx(token, mpd_test_newtonrem, &ctx); + } + else if (eqtoken(token[1], "remaindernear")) { + _Res_Binop_Ctx(token, mpd_rem_near, &ctx); + } + else if (eqtoken(token[1], "rotate")) { + _Res_Binop_Ctx(token, mpd_rotate, &ctx); + } + else if (eqtoken(token[1], "scaleb")) { + _Res_Binop_Ctx(token, mpd_scaleb, &ctx); + } + else if (eqtoken(token[1], "shift")) { + _Res_Binop_Ctx(token, mpd_shift, &ctx); + _Res_Op_Lsize_Ctx(SKIP_NONINT, token, mpd_shiftn, &ctx); + } + else if (eqtoken(token[1], "subtract")) { + _Res_Binop_Ctx(token, mpd_sub, &ctx); + } + else if (eqtoken(token[1], "xor")) { + _Res_Binop_Ctx(token, mpd_xor, &ctx); + } + + /* Binary functions with mpd_t result, equal operands */ + else if (eqtoken(token[1], "add_eq")) { + _Res_EqualBinop_Ctx(token, mpd_add, &ctx); + } + else if (eqtoken(token[1], "and_eq")) { + _Res_EqualBinop_Ctx(token, mpd_and, &ctx); + } + else if (eqtoken(token[1], "copysign_eq")) { + _Res_EqualBinop_Ctx(token, mpd_copy_sign, &ctx); + } + else if (eqtoken(token[1], "divide_eq")) { + _Res_EqualBinop_Ctx(token, mpd_div, &ctx); + _Res_EqualBinop_Ctx(token, mpd_test_newtondiv, &ctx); + } + else if (eqtoken(token[1], "divideint_eq")) { + _Res_EqualBinop_Ctx(token, mpd_divint, &ctx); + _Res_EqualBinop_Ctx(token, mpd_test_newtondivint, &ctx); + } + else if (eqtoken(token[1], "max_eq")) { + _Res_EqualBinop_Ctx(token, mpd_max, &ctx); + } + else if (eqtoken(token[1], "maxmag_eq")) { + _Res_EqualBinop_Ctx(token, mpd_max_mag, &ctx); + } + else if (eqtoken(token[1], "min_eq")) { + _Res_EqualBinop_Ctx(token, mpd_min, &ctx); + } + else if (eqtoken(token[1], "minmag_eq")) { + _Res_EqualBinop_Ctx(token, mpd_min_mag, &ctx); + } + else if (eqtoken(token[1], "multiply_eq")) { + _Res_EqualBinop_Ctx(token, mpd_mul, &ctx); + } + else if (eqtoken(token[1], "nexttoward_eq")) { + _Res_EqualBinop_Ctx(token, mpd_next_toward, &ctx); + } + else if (eqtoken(token[1], "or_eq")) { + _Res_EqualBinop_Ctx(token, mpd_or, &ctx); + } + else if (eqtoken(token[1], "power_eq")) { + ctx.allcr = 0; + _Res_EqualBinop_Ctx(token, mpd_pow, &ctx); + ctx.allcr = 1; + _Res_EqualBinop_Ctx(token, mpd_pow, &ctx); + } + else if (eqtoken(token[1], "quantize_eq")) { + _Res_EqualBinop_Ctx(token, mpd_quantize, &ctx); + } + else if (eqtoken(token[1], "remainder_eq")) { + _Res_EqualBinop_Ctx(token, mpd_rem, &ctx); + _Res_EqualBinop_Ctx(token, mpd_test_newtonrem, &ctx); + } + else if (eqtoken(token[1], "remaindernear_eq")) { + _Res_EqualBinop_Ctx(token, mpd_rem_near, &ctx); + } + else if (eqtoken(token[1], "rotate_eq")) { + _Res_EqualBinop_Ctx(token, mpd_rotate, &ctx); + } + else if (eqtoken(token[1], "scaleb_eq")) { + _Res_EqualBinop_Ctx(token, mpd_scaleb, &ctx); + } + else if (eqtoken(token[1], "shift_eq")) { + _Res_EqualBinop_Ctx(token, mpd_shift, &ctx); + } + else if (eqtoken(token[1], "subtract_eq")) { + _Res_EqualBinop_Ctx(token, mpd_sub, &ctx); + } + else if (eqtoken(token[1], "xor_eq")) { + _Res_EqualBinop_Ctx(token, mpd_xor, &ctx); + } + + /* Binary function with binary result */ + else if (eqtoken(token[1], "divmod")) { + _Binres_Binop_Ctx(token, mpd_divmod, &ctx); + _Binres_Binop_Ctx(token, mpd_test_newtondivmod, &ctx); + } + + /* Binary function with binary result, equal operands */ + else if (eqtoken(token[1], "divmod_eq")) { + _Binres_EqualBinop_Ctx(token, mpd_divmod, &ctx); + _Binres_EqualBinop_Ctx(token, mpd_test_newtondivmod, &ctx); + } + + + /* Ternary functions with mpd_t result */ + else if (eqtoken(token[1], "fma")) { + _Res_Ternop_Ctx(token, mpd_fma, &ctx); + } + else if (eqtoken(token[1], "powmod")) { + _Res_Ternop_Ctx(token, mpd_powmod, &ctx); + } + + /* Ternary functions with mpd_t result, eq_eq_op */ + else if (eqtoken(token[1], "fma_eq_eq_op")) { + _Res_EqEqOp_Ctx(token, mpd_fma, &ctx); + } + else if (eqtoken(token[1], "powmod_eq_eq_op")) { + _Res_EqEqOp_Ctx(token, mpd_powmod, &ctx); + } + + /* Ternary functions with mpd_t result, eq_op_eq */ + else if (eqtoken(token[1], "fma_eq_op_eq")) { + _Res_EqOpEq_Ctx(token, mpd_fma, &ctx); + } + else if (eqtoken(token[1], "powmod_eq_op_eq")) { + _Res_EqOpEq_Ctx(token, mpd_powmod, &ctx); + } + + /* Ternary functions with mpd_t result, op_eq_eq */ + else if (eqtoken(token[1], "fma_op_eq_eq")) { + _Res_OpEqEq_Ctx(token, mpd_fma, &ctx); + } + else if (eqtoken(token[1], "powmod_op_eq_eq")) { + _Res_OpEqEq_Ctx(token, mpd_powmod, &ctx); + } + + /* Ternary functions with mpd_t result, eq_eq_eq */ + else if (eqtoken(token[1], "fma_eq_eq_eq")) { + _Res_EqEqEq_Ctx(token, mpd_fma, &ctx); + } + else if (eqtoken(token[1], "powmod_eq_eq_eq")) { + _Res_EqEqEq_Ctx(token, mpd_powmod, &ctx); + } + + /* Special cases for the comparison functions */ + else if (eqtoken(token[1], "compare")) { + _Int_Res_Binop_Ctx(token, mpd_compare, &ctx); + _Int_Binop_Ctx(SKIP_NAN, token, mpd_cmp, &ctx); + } + else if (eqtoken(token[1], "comparesig")) { + _Int_Res_Binop_Ctx(token, mpd_compare_signal, &ctx); + } + else if (eqtoken(token[1], "comparetotal")) { + _Int_Res_Binop(token, mpd_compare_total, &ctx); + _Int_Binop(token, mpd_cmp_total, &ctx); + } + else if (eqtoken(token[1], "comparetotmag")) { + _Int_Res_Binop(token, mpd_compare_total_mag, &ctx); + _Int_Binop(token, mpd_cmp_total_mag, &ctx); + } + + /* Special cases for the comparison functions, equal operands */ + else if (eqtoken(token[1], "compare_eq")) { + _Int_Res_EqualBinop_Ctx(token, mpd_compare, &ctx); + _Int_EqualBinop_Ctx(SKIP_NAN, token, mpd_cmp, &ctx); + } + else if (eqtoken(token[1], "comparesig_eq")) { + _Int_Res_EqualBinop_Ctx(token, mpd_compare_signal, &ctx); + } + else if (eqtoken(token[1], "comparetotal_eq")) { + _Int_Res_EqualBinop(token, mpd_compare_total, &ctx); + _Int_EqualBinop(token, mpd_cmp_total, &ctx); + } + else if (eqtoken(token[1], "comparetotmag_eq")) { + _Int_Res_EqualBinop(token, mpd_compare_total_mag, &ctx); + _Int_EqualBinop(token, mpd_cmp_total_mag, &ctx); + } + + /* Special cases for the shift functions */ + else if (eqtoken(token[1], "shiftleft")) { + _Res_Op_Lsize_Ctx(SKIP_NONINT, token, mpd_shiftl, &ctx); + } + else if (eqtoken(token[1], "shiftright")) { + _Res_Op_Lsize_Ctx(SKIP_NONINT, token, + (void (*)(mpd_t *, const mpd_t *, mpd_ssize_t, mpd_context_t *))mpd_shiftr, &ctx); + } + + /* Special case for the base conversion functions */ + else if (eqtoken(token[1], "baseconv")) { + _Baseconv(token, &ctx); + } + + /* Special cases for the get_int functions */ +#ifdef CONFIG_64 + else if (eqtoken(token[1], "get_uint64")) { + _uint_MpdCtx(token, mpd_get_uint, &ctx); + } + else if (eqtoken(token[1], "get_uint64_abs")) { + _uint_MpdCtx(token, mpd_abs_uint, &ctx); + } + else if (eqtoken(token[1], "get_u64")) { + _uint_MpdCtx(token, mpd_get_u64, &ctx); + } + else if (eqtoken(token[1], "get_ssize64")) { + _ssize_MpdCtx(token, mpd_get_ssize, &ctx); + } + else if (eqtoken(token[1], "get_i64")) { + _ssize_MpdCtx(token, mpd_get_i64, &ctx); + } +#else + else if (eqtoken(token[1], "get_uint32")) { + _uint_MpdCtx(token, mpd_get_uint, &ctx); + } + else if (eqtoken(token[1], "get_uint32_abs")) { + _uint_MpdCtx(token, mpd_abs_uint, &ctx); + } + else if (eqtoken(token[1], "get_u32")) { + _uint_MpdCtx(token, mpd_get_u32, &ctx); + } + else if (eqtoken(token[1], "get_ssize32")) { + _ssize_MpdCtx(token, mpd_get_ssize, &ctx); + } + else if (eqtoken(token[1], "get_i32")) { + _ssize_MpdCtx(token, mpd_get_i32, &ctx); + } +#endif + + else if (startswith(token[1], "get_")) { + ; + } + + else if (eqtoken(token[1], "rescale")) { + ; + } + + /* unknown operation */ + else { + mpd_err_fatal("%s: unknown operation: %s", filename, line); + } + /* end tests */ + + cleanup: + freetoken(token); + } + + mpd_free(line); + mpd_free(tmpline); + if (file != stdin) { + fclose(file); + } +} + + +int main(int argc, char **argv) +{ + mpd_ssize_t ma, limit; + int n = 1; + + if (argc == 2) { + limit = 2; + } + else if (argc == 3) { + if (strcmp(argv[n++], "--all") != 0) { + fputs("runtest: usage: runtest [--all] testfile\n", stderr); + exit(EXIT_FAILURE); + } + limit = MPD_MINALLOC_MAX; + } + else { + fputs("runtest: usage: runtest [--all] testfile\n", stderr); + exit(EXIT_FAILURE); + } + + srand((unsigned int)time(NULL)); + + for (ma = MPD_MINALLOC_MIN; ma <= limit; ma++) { + + /* DON'T do this in a real program. You have to be sure + * that no previously allocated decimals will ever be used. */ + MPD_MINALLOC = ma; + if (n == 2) { + fprintf(stderr, "minalloc: %" PRI_mpd_ssize_t "\n", MPD_MINALLOC); + } + + op = mpd_qnew(); + op1 = mpd_qnew(); + op2 = mpd_qnew(); + op3 = mpd_qnew(); + tmp = mpd_qnew(); + tmp1 = mpd_qnew(); + tmp2 = mpd_qnew(); + tmp3 = mpd_qnew(); + result = mpd_qnew(); + result1 = mpd_qnew(); + result2 = mpd_qnew(); + + doit(argv[n]); + + mpd_del(op); + mpd_del(op1); + mpd_del(op2); + mpd_del(op3); + mpd_del(tmp); + mpd_del(tmp1); + mpd_del(tmp2); + mpd_del(tmp3); + mpd_del(result); + mpd_del(result1); + mpd_del(result2); + + if (have_printed) { + fputc('\n', stderr); + } + } + + /* Valgrind */ + mpd_del(&mpd_ln10); + + return have_fail; +} + + + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/tests/test_transpose.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/tests/test_transpose.c Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,474 @@ +/* + * Copyright (c) 2008-2010 Stefan Krah. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + + +#include +#include +#include +#include +#include +#include "bits.h" +#include "constants.h" +#include "mpdecimal.h" +#include "mptypes.h" +#include "typearith.h" +#include "transpose.h" + + + +/* + * All the following is pasted from transpose.c for the sole reason of + * running the tests with uint8_t arrays, which allow greater sizes. + */ + + +#define BUFSIZE 4096 +#define SIDE 128 + + +static inline void pointerswap_c(uint8_t **a, uint8_t **b) +{ + uint8_t *tmp; + + tmp = *b; + *b = *a; + *a = tmp; +} + +/* Definition of the matrix transpose */ +static void +std_trans_c(uint8_t dest[], uint8_t src[], mpd_size_t rows, mpd_size_t cols) +{ + mpd_size_t idest, isrc; + mpd_size_t r, c; + + for (r = 0; r < rows; r++) { + isrc = r * cols; + idest = r; + for (c = 0; c < cols; c++) { + dest[idest] = src[isrc]; + isrc += 1; + idest += rows; + } + } +} + +/* + * Swap half-rows of 2^n * (2*2^n) matrix. + * FORWARD_CYCLE: even/odd permutation of the halfrows. + * BACKWARD_CYCLE: reverse the even/odd permutation. + */ +static int +swap_halfrows_pow2_c(uint8_t *matrix, mpd_size_t rows, mpd_size_t cols, int dir) +{ + uint8_t buf1[BUFSIZE]; + uint8_t buf2[BUFSIZE]; + uint8_t *readbuf, *writebuf, *hp; + mpd_size_t *done, dbits; + mpd_size_t b = BUFSIZE, stride; + mpd_size_t hn, hmax; /* halfrow number */ + mpd_size_t m, r=0; + mpd_size_t offset; + mpd_size_t next; + + + assert(cols == mul_size_t(2, rows)); + + if (dir == FORWARD_CYCLE) { + r = rows; + } + else if (dir == BACKWARD_CYCLE) { + r = 2; + } + else { + mpd_err_fatal("swap_halfrows_pow2_c: illegal argument for \"dir\""); + } + + m = cols - 1; + hmax = rows; /* cycles start at odd halfrows */ + dbits = 8 * sizeof *done; + if ((done = mpd_calloc(hmax/(sizeof *done) + 1, sizeof *done)) == NULL) { + return 0; + } + + for (hn = 1; hn <= hmax; hn += 2) { + + if (done[hn/dbits] & mpd_bits[hn%dbits]) { + continue; + } + + readbuf = buf1; writebuf = buf2; + + for (offset = 0; offset < cols/2; offset += b) { + + stride = (offset + b < cols/2) ? b : cols/2-offset; + + hp = matrix + hn*cols/2; + memcpy(readbuf, hp+offset, stride*(sizeof *readbuf)); + pointerswap_c(&readbuf, &writebuf); + + next = mulmod_size_t(hn, r, m); + hp = matrix + next*cols/2; + + while (next != hn) { + + memcpy(readbuf, hp+offset, stride*(sizeof *readbuf)); + memcpy(hp+offset, writebuf, stride*(sizeof *writebuf)); + pointerswap_c(&readbuf, &writebuf); + + done[next/dbits] |= mpd_bits[next%dbits]; + + next = mulmod_size_t(next, r, m); + hp = matrix + next*cols/2; + + } + + memcpy(hp+offset, writebuf, stride*(sizeof *writebuf)); + + done[hn/dbits] |= mpd_bits[hn%dbits]; + } + } + + mpd_free(done); + return 1; +} + +/* In-place transpose of a square matrix */ +static inline void +squaretrans_c(uint8_t *buf, mpd_size_t cols) +{ + uint8_t tmp; + mpd_size_t idest, isrc; + mpd_size_t r, c; + + for (r = 0; r < cols; r++) { + c = r+1; + isrc = r*cols + c; + idest = c*cols + r; + for (c = r+1; c < cols; c++) { + tmp = buf[isrc]; + buf[isrc] = buf[idest]; + buf[idest] = tmp; + isrc += 1; + idest += cols; + } + } +} + +/* + * Transpose 2^n * 2^n matrix. For cache efficiency, the matrix is split into + * square blocks with side length 'SIDE'. First, the blocks are transposed, + * then a square tranposition is done on each individual block. + */ +static void +squaretrans_pow2_c(uint8_t *matrix, mpd_size_t size) +{ + uint8_t buf1[SIDE*SIDE]; + uint8_t buf2[SIDE*SIDE]; + uint8_t *to, *from; + mpd_size_t b = size; + mpd_size_t r, c; + mpd_size_t i; + + while (b > SIDE) b >>= 1; + + for (r = 0; r < size; r += b) { + + for (c = r; c < size; c += b) { + + from = matrix + r*size + c; + to = buf1; + for (i = 0; i < b; i++) { + memcpy(to, from, b*(sizeof *to)); + from += size; + to += b; + } + squaretrans_c(buf1, b); + + if (r == c) { + to = matrix + r*size + c; + from = buf1; + for (i = 0; i < b; i++) { + memcpy(to, from, b*(sizeof *to)); + from += b; + to += size; + } + continue; + } + else { + from = matrix + c*size + r; + to = buf2; + for (i = 0; i < b; i++) { + memcpy(to, from, b*(sizeof *to)); + from += size; + to += b; + } + squaretrans_c(buf2, b); + + to = matrix + c*size + r; + from = buf1; + for (i = 0; i < b; i++) { + memcpy(to, from, b*(sizeof *to)); + from += b; + to += size; + } + + to = matrix + r*size + c; + from = buf2; + for (i = 0; i < b; i++) { + memcpy(to, from, b*(sizeof *to)); + from += b; + to += size; + } + } + } + } + +} + +/* + * In-place transposition of a 2^n x 2^n or a 2^n x (2*2^n) + * or a (2*2^n) x 2^n matrix. + */ +static int +transpose_pow2_c(uint8_t *matrix, mpd_size_t rows, mpd_size_t cols) +{ + mpd_size_t size = mul_size_t(rows, cols); + + assert(ispower2(rows)); + assert(ispower2(cols)); + + if (cols == rows) { + squaretrans_pow2_c(matrix, rows); + } + else if (cols == mul_size_t(2, rows)) { + if (!swap_halfrows_pow2_c(matrix, rows, cols, FORWARD_CYCLE)) { + return 0; + } + squaretrans_pow2_c(matrix, rows); + squaretrans_pow2_c(matrix+(size/2), rows); + } + else if (rows == mul_size_t(2, cols)) { + squaretrans_pow2_c(matrix, cols); + squaretrans_pow2_c(matrix+(size/2), cols); + if (!swap_halfrows_pow2_c(matrix, cols, rows, BACKWARD_CYCLE)) { + return 0; + } + } + else { + mpd_err_fatal("transpose_pow2_c: illegal matrix size"); + } + + return 1; +} + + +#include +#define UMOD_ARRAY (1ULL<<28) +#define UCHAR_ARRAY (1ULL<<29) + +/* The faster in-place functions are tested against std_trans(). */ +static int +testit_uint(void (* func)(mpd_uint_t *, mpd_size_t, mpd_size_t), mpd_size_t rows, mpd_size_t cols) +{ + mpd_uint_t *a = NULL, *src = NULL, *dest = NULL; + clock_t start_fast, end_fast, start_std, end_std; + mpd_size_t msize; + mpd_size_t i; + int ret = 1; + + msize = mul_size_t(rows, cols); + if ((a = mpd_alloc(msize, sizeof *a)) == NULL) { + goto error; + } + if ((src = mpd_alloc(msize, sizeof *src)) == NULL) { + goto error; + } + if ((dest = mpd_alloc(msize, sizeof *dest)) == NULL) { + goto error; + } + + for (i = 0; i < msize; i++) { + a[i] = src[i] = random(); + } + + start_std= clock(); + std_trans(dest, src, rows, cols); + end_std= clock(); + + start_fast = clock(); + func(a, rows, cols); + end_fast = clock(); + + for (i = 0; i < msize; i++) { + if (a[i] != dest[i]) { + fprintf(stderr, "FAIL: a[%"PRI_mpd_size_t"] = %"PRI_mpd_size_t + "\tdest[%"PRI_mpd_size_t"] = %"PRI_mpd_size_t"\n", + i, a[i], i, dest[i]); + exit(1); + } + } + + fprintf(stderr, "size: %10"PRI_mpd_size_t"\tstd_trans: %6.2f sec\t " + "in_place_trans: %6.2f sec\n", + msize, + (double)(end_std-start_std)/(double)CLOCKS_PER_SEC, + (double)(end_fast-start_fast)/(double)CLOCKS_PER_SEC); + + +out: + if (a) mpd_free(a); + if (src) mpd_free(src); + if (dest) mpd_free(dest); + return ret; + +error: + ret = 0; + goto out; +} + +/* The faster in-place functions are tested against std_trans(). */ +static int +testit_uchar(void (* func)(uint8_t *, mpd_size_t, mpd_size_t), mpd_size_t rows, mpd_size_t cols) +{ + uint8_t *a = NULL, *src = NULL, *dest = NULL; + clock_t start_fast, end_fast, start_std, end_std; + mpd_size_t msize; + mpd_size_t i; + int ret = 1; + + msize = mul_size_t(rows, cols); + if ((a = mpd_alloc(msize, sizeof *a)) == NULL) { + goto error; + } + if ((src = mpd_alloc(msize, sizeof *src)) == NULL) { + goto error; + } + if ((dest = mpd_alloc(msize, sizeof *dest)) == NULL) { + goto error; + } + + for (i = 0; i < msize; i++) { + a[i] = src[i] = random(); + } + + start_std= clock(); + std_trans_c(dest, src, rows, cols); + end_std= clock(); + + start_fast = clock(); + func(a, rows, cols); + end_fast = clock(); + + for (i = 0; i < msize; i++) { + if (a[i] != dest[i]) { + fprintf(stderr, "FAIL: a[%"PRI_mpd_size_t"] = %d\t" + "dest[%"PRI_mpd_size_t"] = %d\n", + i, a[i], i, dest[i]); + exit(1); + } + } + + fprintf(stderr, "size: %10"PRI_mpd_size_t"\tstd_trans: %6.2f sec\t " + "in_place_trans: %6.2f sec\n", + msize, + (double)(end_std-start_std)/(double)CLOCKS_PER_SEC, + (double)(end_fast-start_fast)/(double)CLOCKS_PER_SEC); + + +out: + if (a) mpd_free(a); + if (src) mpd_free(src); + if (dest) mpd_free(dest); + return ret; + +error: + ret = 0; + goto out; +} + + +#define transfunc_uint (void (*)(mpd_uint_t *, mpd_size_t, mpd_size_t)) +#define transfunc_uchar (void (*)(uint8_t *, mpd_size_t, mpd_size_t)) + + +int main(void) +{ + mpd_size_t rows, cols; + + + fprintf(stderr, "Running test_transpose ... \n"); + + fprintf(stderr, "\n2^n * 2^n mpd_uint_t matrices:\n\n"); + for (rows = 1; mul_size_t(rows, rows) <= UMOD_ARRAY; rows *= 2) { + if (!testit_uint(transfunc_uint transpose_pow2, rows, rows)) { + break; + } + } + + fprintf(stderr, "\n2^n * 2*2^n mpd_uint_t matrices:\n\n"); + for (rows = 8, cols = 16; mul_size_t(rows, cols) <= UMOD_ARRAY; rows *= 2, cols*=2) { + if (!testit_uint(transfunc_uint transpose_pow2, rows, cols)) { + break; + } + } + + fprintf(stderr, "\n2*2^n * 2^n mpd_uint_t matrices:\n\n"); + for (rows = 16, cols = 8; mul_size_t(rows, cols) <= UMOD_ARRAY; rows *= 2, cols*=2) { + if (!testit_uint(transfunc_uint transpose_pow2, rows, cols)) { + break; + } + } + + + fprintf(stderr, "\n2^n * 2^n uint8_t matrices:\n\n"); + for (rows = 1; mul_size_t(rows, rows) <= UCHAR_ARRAY; rows *= 2) { + if (!testit_uchar(transfunc_uchar transpose_pow2_c, rows, rows)) { + break; + } + } + + fprintf(stderr, "\n2^n * 2*2^n uint8_t matrices:\n\n"); + for (rows = 8, cols = 16; mul_size_t(rows, cols) <= UCHAR_ARRAY; rows *= 2, cols*=2) { + if (!testit_uchar(transfunc_uchar transpose_pow2_c, rows, cols)) { + break; + } + } + + fprintf(stderr, "\n2*2^n * 2^n uint8_t matrices:\n\n"); + for (rows = 16, cols = 8; mul_size_t(rows, cols) <= UCHAR_ARRAY; rows *= 2, cols*=2) { + if (!testit_uchar(transfunc_uchar transpose_pow2_c, rows, cols)) { + break; + } + } + + fprintf(stderr, "\ntest_transpose: PASS\n\n"); + + return 0; +} + + diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/tests/testdata_dist/baseconv.decTest --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/tests/testdata_dist/baseconv.decTest Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,406 @@ +Precision: 425000000 +Maxexponent: 425000000 +Minexponent: -425000000 + + +bconv0 baseconv 0 -> 0 +bconv1 baseconv 1 -> 1 +bconv2 baseconv 2 -> 2 +bconv3 baseconv 3 -> 3 +bconv4 baseconv 4 -> 4 +bconv5 baseconv 5 -> 5 +bconv6 baseconv 6 -> 6 +bconv7 baseconv 7 -> 7 +bconv8 baseconv 8 -> 8 +bconv9 baseconv 9 -> 9 +bconv10 baseconv 10 -> 10 +bconv11 baseconv 11 -> 11 +bconv12 baseconv 12 -> 12 +bconv13 baseconv 13 -> 13 +bconv14 baseconv 14 -> 14 +bconv15 baseconv 15 -> 15 +bconv16 baseconv 16 -> 16 +bconv17 baseconv 17 -> 17 +bconv18 baseconv 18 -> 18 +bconv19 baseconv 19 -> 19 +bconv20 baseconv 20 -> 20 +bconv21 baseconv 21 -> 21 +bconv22 baseconv 22 -> 22 +bconv23 baseconv 23 -> 23 +bconv24 baseconv 24 -> 24 +bconv25 baseconv 25 -> 25 +bconv26 baseconv 26 -> 26 +bconv27 baseconv 27 -> 27 +bconv28 baseconv 28 -> 28 +bconv29 baseconv 29 -> 29 +bconv30 baseconv 30 -> 30 +bconv31 baseconv 31 -> 31 +bconv32 baseconv 32 -> 32 +bconv33 baseconv 33 -> 33 +bconv34 baseconv 34 -> 34 +bconv35 baseconv 35 -> 35 +bconv36 baseconv 36 -> 36 +bconv37 baseconv 37 -> 37 +bconv38 baseconv 38 -> 38 +bconv39 baseconv 39 -> 39 +bconv40 baseconv 40 -> 40 +bconv41 baseconv 41 -> 41 +bconv42 baseconv 42 -> 42 +bconv43 baseconv 43 -> 43 +bconv44 baseconv 44 -> 44 +bconv45 baseconv 45 -> 45 +bconv46 baseconv 46 -> 46 +bconv47 baseconv 47 -> 47 +bconv48 baseconv 48 -> 48 +bconv49 baseconv 49 -> 49 +bconv50 baseconv 50 -> 50 +bconv51 baseconv 51 -> 51 +bconv52 baseconv 52 -> 52 +bconv53 baseconv 53 -> 53 +bconv54 baseconv 54 -> 54 +bconv55 baseconv 55 -> 55 +bconv56 baseconv 56 -> 56 +bconv57 baseconv 57 -> 57 +bconv58 baseconv 58 -> 58 +bconv59 baseconv 59 -> 59 +bconv60 baseconv 60 -> 60 +bconv61 baseconv 61 -> 61 +bconv62 baseconv 62 -> 62 +bconv63 baseconv 63 -> 63 +bconv64 baseconv 64 -> 64 +bconv65 baseconv 65 -> 65 +bconv66 baseconv 66 -> 66 +bconv67 baseconv 67 -> 67 +bconv68 baseconv 68 -> 68 +bconv69 baseconv 69 -> 69 +bconv70 baseconv 70 -> 70 +bconv71 baseconv 71 -> 71 +bconv72 baseconv 72 -> 72 +bconv73 baseconv 73 -> 73 +bconv74 baseconv 74 -> 74 +bconv75 baseconv 75 -> 75 +bconv76 baseconv 76 -> 76 +bconv77 baseconv 77 -> 77 +bconv78 baseconv 78 -> 78 +bconv79 baseconv 79 -> 79 +bconv80 baseconv 80 -> 80 +bconv81 baseconv 81 -> 81 +bconv82 baseconv 82 -> 82 +bconv83 baseconv 83 -> 83 +bconv84 baseconv 84 -> 84 +bconv85 baseconv 85 -> 85 +bconv86 baseconv 86 -> 86 +bconv87 baseconv 87 -> 87 +bconv88 baseconv 88 -> 88 +bconv89 baseconv 89 -> 89 +bconv90 baseconv 90 -> 90 +bconv91 baseconv 91 -> 91 +bconv92 baseconv 92 -> 92 +bconv93 baseconv 93 -> 93 +bconv94 baseconv 94 -> 94 +bconv95 baseconv 95 -> 95 +bconv96 baseconv 96 -> 96 +bconv97 baseconv 97 -> 97 +bconv98 baseconv 98 -> 98 +bconv99 baseconv 99 -> 99 +bconv0 baseconv 1 -> 1 +bconv1 baseconv 10 -> 10 +bconv2 baseconv 100 -> 100 +bconv3 baseconv 1000 -> 1000 +bconv4 baseconv 10000 -> 10000 +bconv5 baseconv 100000 -> 100000 +bconv6 baseconv 1000000 -> 1000000 +bconv7 baseconv 10000000 -> 10000000 +bconv8 baseconv 100000000 -> 100000000 +bconv9 baseconv 1000000000 -> 1000000000 +bconv10 baseconv 10000000000 -> 10000000000 +bconv11 baseconv 100000000000 -> 100000000000 +bconv12 baseconv 1000000000000 -> 1000000000000 +bconv13 baseconv 10000000000000 -> 10000000000000 +bconv14 baseconv 100000000000000 -> 100000000000000 +bconv15 baseconv 1000000000000000 -> 1000000000000000 +bconv16 baseconv 10000000000000000 -> 10000000000000000 +bconv17 baseconv 100000000000000000 -> 100000000000000000 +bconv18 baseconv 1000000000000000000 -> 1000000000000000000 +bconv19 baseconv 10000000000000000000 -> 10000000000000000000 +bconv20 baseconv 100000000000000000000 -> 100000000000000000000 +bconv21 baseconv 1000000000000000000000 -> 1000000000000000000000 +bconv22 baseconv 10000000000000000000000 -> 10000000000000000000000 +bconv23 baseconv 100000000000000000000000 -> 100000000000000000000000 +bconv24 baseconv 1000000000000000000000000 -> 1000000000000000000000000 +bconv25 baseconv 10000000000000000000000000 -> 10000000000000000000000000 +bconv26 baseconv 100000000000000000000000000 -> 100000000000000000000000000 +bconv27 baseconv 1000000000000000000000000000 -> 1000000000000000000000000000 +bconv28 baseconv 10000000000000000000000000000 -> 10000000000000000000000000000 +bconv29 baseconv 100000000000000000000000000000 -> 100000000000000000000000000000 +bconv30 baseconv 1000000000000000000000000000000 -> 1000000000000000000000000000000 +bconv31 baseconv 10000000000000000000000000000000 -> 10000000000000000000000000000000 +bconv32 baseconv 100000000000000000000000000000000 -> 100000000000000000000000000000000 +bconv33 baseconv 1000000000000000000000000000000000 -> 1000000000000000000000000000000000 +bconv34 baseconv 10000000000000000000000000000000000 -> 10000000000000000000000000000000000 +bconv35 baseconv 100000000000000000000000000000000000 -> 100000000000000000000000000000000000 +bconv36 baseconv 1000000000000000000000000000000000000 -> 1000000000000000000000000000000000000 +bconv37 baseconv 10000000000000000000000000000000000000 -> 10000000000000000000000000000000000000 +bconv38 baseconv 100000000000000000000000000000000000000 -> 100000000000000000000000000000000000000 +bconv39 baseconv 1000000000000000000000000000000000000000 -> 1000000000000000000000000000000000000000 +bconv40 baseconv 10000000000000000000000000000000000000000 -> 10000000000000000000000000000000000000000 +bconv41 baseconv 100000000000000000000000000000000000000000 -> 100000000000000000000000000000000000000000 +bconv42 baseconv 1000000000000000000000000000000000000000000 -> 1000000000000000000000000000000000000000000 +bconv43 baseconv 10000000000000000000000000000000000000000000 -> 10000000000000000000000000000000000000000000 +bconv44 baseconv 100000000000000000000000000000000000000000000 -> 100000000000000000000000000000000000000000000 +bconv45 baseconv 1000000000000000000000000000000000000000000000 -> 1000000000000000000000000000000000000000000000 +bconv46 baseconv 10000000000000000000000000000000000000000000000 -> 10000000000000000000000000000000000000000000000 +bconv47 baseconv 100000000000000000000000000000000000000000000000 -> 100000000000000000000000000000000000000000000000 +bconv48 baseconv 1000000000000000000000000000000000000000000000000 -> 1000000000000000000000000000000000000000000000000 +bconv49 baseconv 10000000000000000000000000000000000000000000000000 -> 10000000000000000000000000000000000000000000000000 +bconv50 baseconv 100000000000000000000000000000000000000000000000000 -> 100000000000000000000000000000000000000000000000000 +bconv51 baseconv 1000000000000000000000000000000000000000000000000000 -> 1000000000000000000000000000000000000000000000000000 +bconv52 baseconv 10000000000000000000000000000000000000000000000000000 -> 10000000000000000000000000000000000000000000000000000 +bconv53 baseconv 100000000000000000000000000000000000000000000000000000 -> 100000000000000000000000000000000000000000000000000000 +bconv54 baseconv 1000000000000000000000000000000000000000000000000000000 -> 1000000000000000000000000000000000000000000000000000000 +bconv55 baseconv 10000000000000000000000000000000000000000000000000000000 -> 10000000000000000000000000000000000000000000000000000000 +bconv56 baseconv 100000000000000000000000000000000000000000000000000000000 -> 100000000000000000000000000000000000000000000000000000000 +bconv57 baseconv 1000000000000000000000000000000000000000000000000000000000 -> 1000000000000000000000000000000000000000000000000000000000 +bconv58 baseconv 10000000000000000000000000000000000000000000000000000000000 -> 10000000000000000000000000000000000000000000000000000000000 +bconv59 baseconv 100000000000000000000000000000000000000000000000000000000000 -> 100000000000000000000000000000000000000000000000000000000000 +bconv60 baseconv 1000000000000000000000000000000000000000000000000000000000000 -> 1000000000000000000000000000000000000000000000000000000000000 +bconv61 baseconv 10000000000000000000000000000000000000000000000000000000000000 -> 10000000000000000000000000000000000000000000000000000000000000 +bconv62 baseconv 100000000000000000000000000000000000000000000000000000000000000 -> 100000000000000000000000000000000000000000000000000000000000000 +bconv63 baseconv 1000000000000000000000000000000000000000000000000000000000000000 -> 1000000000000000000000000000000000000000000000000000000000000000 +bconv64 baseconv 10000000000000000000000000000000000000000000000000000000000000000 -> 10000000000000000000000000000000000000000000000000000000000000000 +bconv65 baseconv 100000000000000000000000000000000000000000000000000000000000000000 -> 100000000000000000000000000000000000000000000000000000000000000000 +bconv66 baseconv 1000000000000000000000000000000000000000000000000000000000000000000 -> 1000000000000000000000000000000000000000000000000000000000000000000 +bconv67 baseconv 10000000000000000000000000000000000000000000000000000000000000000000 -> 10000000000000000000000000000000000000000000000000000000000000000000 +bconv68 baseconv 100000000000000000000000000000000000000000000000000000000000000000000 -> 100000000000000000000000000000000000000000000000000000000000000000000 +bconv69 baseconv 1000000000000000000000000000000000000000000000000000000000000000000000 -> 1000000000000000000000000000000000000000000000000000000000000000000000 +bconv70 baseconv 10000000000000000000000000000000000000000000000000000000000000000000000 -> 10000000000000000000000000000000000000000000000000000000000000000000000 +bconv71 baseconv 100000000000000000000000000000000000000000000000000000000000000000000000 -> 100000000000000000000000000000000000000000000000000000000000000000000000 +bconv72 baseconv 1000000000000000000000000000000000000000000000000000000000000000000000000 -> 1000000000000000000000000000000000000000000000000000000000000000000000000 +bconv73 baseconv 10000000000000000000000000000000000000000000000000000000000000000000000000 -> 10000000000000000000000000000000000000000000000000000000000000000000000000 +bconv74 baseconv 100000000000000000000000000000000000000000000000000000000000000000000000000 -> 100000000000000000000000000000000000000000000000000000000000000000000000000 +bconv75 baseconv 1000000000000000000000000000000000000000000000000000000000000000000000000000 -> 1000000000000000000000000000000000000000000000000000000000000000000000000000 +bconv76 baseconv 10000000000000000000000000000000000000000000000000000000000000000000000000000 -> 10000000000000000000000000000000000000000000000000000000000000000000000000000 +bconv77 baseconv 100000000000000000000000000000000000000000000000000000000000000000000000000000 -> 100000000000000000000000000000000000000000000000000000000000000000000000000000 +bconv78 baseconv 1000000000000000000000000000000000000000000000000000000000000000000000000000000 -> 1000000000000000000000000000000000000000000000000000000000000000000000000000000 +bconv79 baseconv 10000000000000000000000000000000000000000000000000000000000000000000000000000000 -> 10000000000000000000000000000000000000000000000000000000000000000000000000000000 +bconv80 baseconv 100000000000000000000000000000000000000000000000000000000000000000000000000000000 -> 100000000000000000000000000000000000000000000000000000000000000000000000000000000 +bconv81 baseconv 1000000000000000000000000000000000000000000000000000000000000000000000000000000000 -> 1000000000000000000000000000000000000000000000000000000000000000000000000000000000 +bconv82 baseconv 10000000000000000000000000000000000000000000000000000000000000000000000000000000000 -> 10000000000000000000000000000000000000000000000000000000000000000000000000000000000 +bconv83 baseconv 100000000000000000000000000000000000000000000000000000000000000000000000000000000000 -> 100000000000000000000000000000000000000000000000000000000000000000000000000000000000 +bconv84 baseconv 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -> 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +bconv85 baseconv 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -> 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +bconv86 baseconv 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -> 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +bconv87 baseconv 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -> 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +bconv88 baseconv 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -> 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +bconv89 baseconv 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -> 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +bconv90 baseconv 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -> 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +bconv91 baseconv 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -> 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +bconv92 baseconv 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -> 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +bconv93 baseconv 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -> 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +bconv94 baseconv 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -> 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +bconv95 baseconv 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -> 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +bconv96 baseconv 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -> 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +bconv97 baseconv 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -> 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +bconv98 baseconv 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -> 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +bconv99 baseconv 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -> 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +bconv0 baseconv 1 -> 1 +bconv1 baseconv 2 -> 2 +bconv2 baseconv 4 -> 4 +bconv3 baseconv 8 -> 8 +bconv4 baseconv 16 -> 16 +bconv5 baseconv 32 -> 32 +bconv6 baseconv 64 -> 64 +bconv7 baseconv 128 -> 128 +bconv8 baseconv 256 -> 256 +bconv9 baseconv 512 -> 512 +bconv10 baseconv 1024 -> 1024 +bconv11 baseconv 2048 -> 2048 +bconv12 baseconv 4096 -> 4096 +bconv13 baseconv 8192 -> 8192 +bconv14 baseconv 16384 -> 16384 +bconv15 baseconv 32768 -> 32768 +bconv16 baseconv 65536 -> 65536 +bconv17 baseconv 131072 -> 131072 +bconv18 baseconv 262144 -> 262144 +bconv19 baseconv 524288 -> 524288 +bconv20 baseconv 1048576 -> 1048576 +bconv21 baseconv 2097152 -> 2097152 +bconv22 baseconv 4194304 -> 4194304 +bconv23 baseconv 8388608 -> 8388608 +bconv24 baseconv 16777216 -> 16777216 +bconv25 baseconv 33554432 -> 33554432 +bconv26 baseconv 67108864 -> 67108864 +bconv27 baseconv 134217728 -> 134217728 +bconv28 baseconv 268435456 -> 268435456 +bconv29 baseconv 536870912 -> 536870912 +bconv30 baseconv 1073741824 -> 1073741824 +bconv31 baseconv 2147483648 -> 2147483648 +bconv32 baseconv 4294967296 -> 4294967296 +bconv33 baseconv 8589934592 -> 8589934592 +bconv34 baseconv 17179869184 -> 17179869184 +bconv35 baseconv 34359738368 -> 34359738368 +bconv36 baseconv 68719476736 -> 68719476736 +bconv37 baseconv 137438953472 -> 137438953472 +bconv38 baseconv 274877906944 -> 274877906944 +bconv39 baseconv 549755813888 -> 549755813888 +bconv40 baseconv 1099511627776 -> 1099511627776 +bconv41 baseconv 2199023255552 -> 2199023255552 +bconv42 baseconv 4398046511104 -> 4398046511104 +bconv43 baseconv 8796093022208 -> 8796093022208 +bconv44 baseconv 17592186044416 -> 17592186044416 +bconv45 baseconv 35184372088832 -> 35184372088832 +bconv46 baseconv 70368744177664 -> 70368744177664 +bconv47 baseconv 140737488355328 -> 140737488355328 +bconv48 baseconv 281474976710656 -> 281474976710656 +bconv49 baseconv 562949953421312 -> 562949953421312 +bconv50 baseconv 1125899906842624 -> 1125899906842624 +bconv51 baseconv 2251799813685248 -> 2251799813685248 +bconv52 baseconv 4503599627370496 -> 4503599627370496 +bconv53 baseconv 9007199254740992 -> 9007199254740992 +bconv54 baseconv 18014398509481984 -> 18014398509481984 +bconv55 baseconv 36028797018963968 -> 36028797018963968 +bconv56 baseconv 72057594037927936 -> 72057594037927936 +bconv57 baseconv 144115188075855872 -> 144115188075855872 +bconv58 baseconv 288230376151711744 -> 288230376151711744 +bconv59 baseconv 576460752303423488 -> 576460752303423488 +bconv60 baseconv 1152921504606846976 -> 1152921504606846976 +bconv61 baseconv 2305843009213693952 -> 2305843009213693952 +bconv62 baseconv 4611686018427387904 -> 4611686018427387904 +bconv63 baseconv 9223372036854775808 -> 9223372036854775808 +bconv64 baseconv 18446744073709551616 -> 18446744073709551616 +bconv65 baseconv 36893488147419103232 -> 36893488147419103232 +bconv66 baseconv 73786976294838206464 -> 73786976294838206464 +bconv67 baseconv 147573952589676412928 -> 147573952589676412928 +bconv68 baseconv 295147905179352825856 -> 295147905179352825856 +bconv69 baseconv 590295810358705651712 -> 590295810358705651712 +bconv70 baseconv 1180591620717411303424 -> 1180591620717411303424 +bconv71 baseconv 2361183241434822606848 -> 2361183241434822606848 +bconv72 baseconv 4722366482869645213696 -> 4722366482869645213696 +bconv73 baseconv 9444732965739290427392 -> 9444732965739290427392 +bconv74 baseconv 18889465931478580854784 -> 18889465931478580854784 +bconv75 baseconv 37778931862957161709568 -> 37778931862957161709568 +bconv76 baseconv 75557863725914323419136 -> 75557863725914323419136 +bconv77 baseconv 151115727451828646838272 -> 151115727451828646838272 +bconv78 baseconv 302231454903657293676544 -> 302231454903657293676544 +bconv79 baseconv 604462909807314587353088 -> 604462909807314587353088 +bconv80 baseconv 1208925819614629174706176 -> 1208925819614629174706176 +bconv81 baseconv 2417851639229258349412352 -> 2417851639229258349412352 +bconv82 baseconv 4835703278458516698824704 -> 4835703278458516698824704 +bconv83 baseconv 9671406556917033397649408 -> 9671406556917033397649408 +bconv84 baseconv 19342813113834066795298816 -> 19342813113834066795298816 +bconv85 baseconv 38685626227668133590597632 -> 38685626227668133590597632 +bconv86 baseconv 77371252455336267181195264 -> 77371252455336267181195264 +bconv87 baseconv 154742504910672534362390528 -> 154742504910672534362390528 +bconv88 baseconv 309485009821345068724781056 -> 309485009821345068724781056 +bconv89 baseconv 618970019642690137449562112 -> 618970019642690137449562112 +bconv90 baseconv 1237940039285380274899124224 -> 1237940039285380274899124224 +bconv91 baseconv 2475880078570760549798248448 -> 2475880078570760549798248448 +bconv92 baseconv 4951760157141521099596496896 -> 4951760157141521099596496896 +bconv93 baseconv 9903520314283042199192993792 -> 9903520314283042199192993792 +bconv94 baseconv 19807040628566084398385987584 -> 19807040628566084398385987584 +bconv95 baseconv 39614081257132168796771975168 -> 39614081257132168796771975168 +bconv96 baseconv 79228162514264337593543950336 -> 79228162514264337593543950336 +bconv97 baseconv 158456325028528675187087900672 -> 158456325028528675187087900672 +bconv98 baseconv 316912650057057350374175801344 -> 316912650057057350374175801344 +bconv99 baseconv 633825300114114700748351602688 -> 633825300114114700748351602688 +bconv0 baseconv 6491583314170016651960765600882241266678157369209968827293693478920422642346481531587856957822735272176502825702006352105971780102301850294086322213302322664347040715971849030973951339424556362307717779218076765556369695864662049459295802567800242575763709155319451802637688617894116374536041436438553255088598018340823760747136302987269567918733314283597905508534002559098376607421780045267678614483953523059894321696806071222585741217040857630480460199343123995957686828057955055817822471099217703508178497070025157348312770738150312853321283542425686124704814692054430786648641233918001350846520921868542146706115842138638604035732907440841257662610929924526023402966747601951086655344453076372535059350343585534773253557333850960007635423214139168749145966886108704409988193837007517140336251823622424393985492337611968149148379319670111733083686958890371624812909716895645978398587519379218716817321602447554096503954940038891579617470595230445818222826319325339987706275220382824180906767151452 -> 6491583314170016651960765600882241266678157369209968827293693478920422642346481531587856957822735272176502825702006352105971780102301850294086322213302322664347040715971849030973951339424556362307717779218076765556369695864662049459295802567800242575763709155319451802637688617894116374536041436438553255088598018340823760747136302987269567918733314283597905508534002559098376607421780045267678614483953523059894321696806071222585741217040857630480460199343123995957686828057955055817822471099217703508178497070025157348312770738150312853321283542425686124704814692054430786648641233918001350846520921868542146706115842138638604035732907440841257662610929924526023402966747601951086655344453076372535059350343585534773253557333850960007635423214139168749145966886108704409988193837007517140336251823622424393985492337611968149148379319670111733083686958890371624812909716895645978398587519379218716817321602447554096503954940038891579617470595230445818222826319325339987706275220382824180906767151452 +bconv1 baseconv 4111279081475686589703492345622963707727266174997802625882189307956954153902192710126460741811610238853328696116227406850135727953626340565034219448900881683684883608691229521286519078350025357285261827715383654277407876218513507584549916689827258877301790157273506446715760963508498885469258966198334440893694548555727773173147536093210593427724829596885869552273915851494583428170108447618828785448908040727858462941432613673636683856145276420428010154140577133784426034632981299516444125975607921808604605790479877488093002169388974010936725862921662219877488692069778006926757706085858986430479679228381497950744698172364364354932687043076968499766229181355411400736380404082838591457713447659358799143029381684625664202305335191893537522455528567800748632454649751212272508551793617234430584411216663042025939557613620312367095302867344424251051570178081633447563541458825805694563136971975316378916225952125882461081260669069949625871045264890932276381748349997938447804782519245868279275475352 -> 4111279081475686589703492345622963707727266174997802625882189307956954153902192710126460741811610238853328696116227406850135727953626340565034219448900881683684883608691229521286519078350025357285261827715383654277407876218513507584549916689827258877301790157273506446715760963508498885469258966198334440893694548555727773173147536093210593427724829596885869552273915851494583428170108447618828785448908040727858462941432613673636683856145276420428010154140577133784426034632981299516444125975607921808604605790479877488093002169388974010936725862921662219877488692069778006926757706085858986430479679228381497950744698172364364354932687043076968499766229181355411400736380404082838591457713447659358799143029381684625664202305335191893537522455528567800748632454649751212272508551793617234430584411216663042025939557613620312367095302867344424251051570178081633447563541458825805694563136971975316378916225952125882461081260669069949625871045264890932276381748349997938447804782519245868279275475352 +bconv2 baseconv 9600797335332092235690111207994089049375445106935598944380399485573174822825377869166990414613498587852823509452222008409000712400416624826815271770380383263075263047060384888381593154421862776767708719168600083946522763268546178543377340193031912449141416981269793084078728504576654693442409980856791320701417892396983663041850360754332772552495358615356273962089696011050766282398256234034836982339869960509240914982904785433483583973779742981292295206102251801464969120684108541500751525623824759490644283465196386670102843548273794500224788944449199133697628700050968582610902336660579177656621845710789382201067989946160402580947720168315431874321966668002843698612531052801151926147468971176444247635962008643173744974022961891904559751410589796142286323691985479739224838423258970926444135643916606765521543073389721638261079195805301217191632151706520777941367381340618851814311534541124394700069511419513100760137605926896495962368746752884289862024927775256038956312359544761436433461272791 -> 9600797335332092235690111207994089049375445106935598944380399485573174822825377869166990414613498587852823509452222008409000712400416624826815271770380383263075263047060384888381593154421862776767708719168600083946522763268546178543377340193031912449141416981269793084078728504576654693442409980856791320701417892396983663041850360754332772552495358615356273962089696011050766282398256234034836982339869960509240914982904785433483583973779742981292295206102251801464969120684108541500751525623824759490644283465196386670102843548273794500224788944449199133697628700050968582610902336660579177656621845710789382201067989946160402580947720168315431874321966668002843698612531052801151926147468971176444247635962008643173744974022961891904559751410589796142286323691985479739224838423258970926444135643916606765521543073389721638261079195805301217191632151706520777941367381340618851814311534541124394700069511419513100760137605926896495962368746752884289862024927775256038956312359544761436433461272791 +bconv3 baseconv 7391857188750838688926825764227067389520943548616283242202404754917931318372010666837031038390661458746271247088740990557650130784333324556842771423189123747055115965433981180219003780005468158937696544938642720016972150003379294733004464283339354283365767131403893643742260321585901979112044055415111875550468044920846892656160098835257261152341044149358306283151659341298340885383066792459518760909303200893733500565570419257141176691352501677872104603472695149194708141862009989045046069217976272761230973716640970061622460016952371487527884064643283124270612278205563307685817019338916023562360693679289303486203686892776512370440999449101169159821841240580776177313468492225025491786937102252424895258707986078084587381798744747683723049832887829922656062251228913742924056046062121265361299904402256389160514737937836491646159281983519255516145101733524659649030957407224920123274864377710913023997875614696779896852423601748304484143171016205991876729973271943704553053974709589492181423319279 -> 7391857188750838688926825764227067389520943548616283242202404754917931318372010666837031038390661458746271247088740990557650130784333324556842771423189123747055115965433981180219003780005468158937696544938642720016972150003379294733004464283339354283365767131403893643742260321585901979112044055415111875550468044920846892656160098835257261152341044149358306283151659341298340885383066792459518760909303200893733500565570419257141176691352501677872104603472695149194708141862009989045046069217976272761230973716640970061622460016952371487527884064643283124270612278205563307685817019338916023562360693679289303486203686892776512370440999449101169159821841240580776177313468492225025491786937102252424895258707986078084587381798744747683723049832887829922656062251228913742924056046062121265361299904402256389160514737937836491646159281983519255516145101733524659649030957407224920123274864377710913023997875614696779896852423601748304484143171016205991876729973271943704553053974709589492181423319279 +bconv4 baseconv 3810312944809156037330447947531565812222415566539036090576331099409637782665851600787099319843033866135488042538934917365940820340820797549748098901796010122900459983471249151829946082755744261111178419062574006617997092675569795239059680479946127950791244158625233081723752938714860889011144827373565865238321030098317014339335278466740284557736877680511037830476589248152692553095292251806612855373747175365425313772655605953292128342938903780907264891639800822117466494476655947032309532878099472930243933079173197542350967400374146431236761555027300506153270803473159970224896568034239437018861021357795008789408604622410923982351692684775466942939834767808784946292286891716007860849129275614267267226400533680419578008432029240296583121485171389459147456717015360473453605523544250780642711790535419038894134289988861827807918994395533473575529508651366584344695782740350763054033994327912466983158199068654685987490986855982699908908070024908329452891704114804725493591316839437780825369503285 -> 3810312944809156037330447947531565812222415566539036090576331099409637782665851600787099319843033866135488042538934917365940820340820797549748098901796010122900459983471249151829946082755744261111178419062574006617997092675569795239059680479946127950791244158625233081723752938714860889011144827373565865238321030098317014339335278466740284557736877680511037830476589248152692553095292251806612855373747175365425313772655605953292128342938903780907264891639800822117466494476655947032309532878099472930243933079173197542350967400374146431236761555027300506153270803473159970224896568034239437018861021357795008789408604622410923982351692684775466942939834767808784946292286891716007860849129275614267267226400533680419578008432029240296583121485171389459147456717015360473453605523544250780642711790535419038894134289988861827807918994395533473575529508651366584344695782740350763054033994327912466983158199068654685987490986855982699908908070024908329452891704114804725493591316839437780825369503285 +bconv5 baseconv 581664078828729394527814192141359952532315020374250650573514758865214035639697481467230138669155013681012285411141892582082940480015406380331044560139168192579068496210381226760275838011032288362321503710350917701271978881023760158155636167413308080567924335721397083086345069663466869008218332774078848618930452320633863085132519051664743279245782924386393783831350980873582281751070154892523902632342109872655636899945710409743770833827628787430788697901131193972931115008142992235521172398754458742331951303042997175644050805744963227496623814654782953338980510324494649885655092311791766190181848805492595062829358056724308720104246455161400109405757805114773952048173975404207567349809495261755140122408322404970089371408815604916043747303955412070895876264678544299565228647120386814322745272992396641738110564515816933340349465146535524257261196750271377184644939359494408817796743968138159504903166545968931680314836698502322818795297311358261187531528463383487383639163344512182961974823199 -> 581664078828729394527814192141359952532315020374250650573514758865214035639697481467230138669155013681012285411141892582082940480015406380331044560139168192579068496210381226760275838011032288362321503710350917701271978881023760158155636167413308080567924335721397083086345069663466869008218332774078848618930452320633863085132519051664743279245782924386393783831350980873582281751070154892523902632342109872655636899945710409743770833827628787430788697901131193972931115008142992235521172398754458742331951303042997175644050805744963227496623814654782953338980510324494649885655092311791766190181848805492595062829358056724308720104246455161400109405757805114773952048173975404207567349809495261755140122408322404970089371408815604916043747303955412070895876264678544299565228647120386814322745272992396641738110564515816933340349465146535524257261196750271377184644939359494408817796743968138159504903166545968931680314836698502322818795297311358261187531528463383487383639163344512182961974823199 +bconv6 baseconv 1597224394916957426933399884230583612104639862888511483918331543496001143084986596238268750856342059758559950609796869219361462753282519959227713376793165082148966467883242625003972828290211442846872783637563675925041812657465357267277979689805945554583733983793325297137473150872901207156306867197974234556666602743077351159781049142721111157102531109180568776365878222621157306803316710993369377551251056075978367047213207196276191716640136792208869116611017117779262947086537506688356841395763194316506751331411834065910515447193074504764739885052789214271633128249195002432841039680256131301866272632771764655682685319651680961500150302937998402225355396697376598748043777520517006966952703804972780573860280435964439028988227174501330209270744041587475823060881868285536437930908473024817379326179043481910640821923730555951877575062410803010077992810632578743139777895363484868415028605858151220981103015288693057936012042461201439738699857479012040063169558179733743022763535724129623801710174 -> 1597224394916957426933399884230583612104639862888511483918331543496001143084986596238268750856342059758559950609796869219361462753282519959227713376793165082148966467883242625003972828290211442846872783637563675925041812657465357267277979689805945554583733983793325297137473150872901207156306867197974234556666602743077351159781049142721111157102531109180568776365878222621157306803316710993369377551251056075978367047213207196276191716640136792208869116611017117779262947086537506688356841395763194316506751331411834065910515447193074504764739885052789214271633128249195002432841039680256131301866272632771764655682685319651680961500150302937998402225355396697376598748043777520517006966952703804972780573860280435964439028988227174501330209270744041587475823060881868285536437930908473024817379326179043481910640821923730555951877575062410803010077992810632578743139777895363484868415028605858151220981103015288693057936012042461201439738699857479012040063169558179733743022763535724129623801710174 +bconv7 baseconv 8494537335500467845803017335439749194665866425449590956859098829595307480455197439262576939094936789928457616118793601350107874469658143763506353198066447541086966098488178696658135213011285714070905546789142098294193815169056323095877646239449646656475541914581502280064977313970533084534992650999132235177084657865857250546997090536269712635726607992754108422522776214712915728655939119658726268871580936369466626718860739593731373436504240887061163908806291218460495488594599164551031312072256435775318731369167697540977550724973584789209120282066365833877498276544998095547772407620241766022441746081249003338436374014851293125970633876119079943143591658862800994849059573686889159389176733059003153379233034613816659792612350870850962288977481684383189663339739491881038826218412717657583061136813919073865983955302240374321847921699285608519193376869374796534203431191622133490411113868972789018853758277298883278108604215524686573147875405580681233813375229835369597122930336579071659011305493 -> 8494537335500467845803017335439749194665866425449590956859098829595307480455197439262576939094936789928457616118793601350107874469658143763506353198066447541086966098488178696658135213011285714070905546789142098294193815169056323095877646239449646656475541914581502280064977313970533084534992650999132235177084657865857250546997090536269712635726607992754108422522776214712915728655939119658726268871580936369466626718860739593731373436504240887061163908806291218460495488594599164551031312072256435775318731369167697540977550724973584789209120282066365833877498276544998095547772407620241766022441746081249003338436374014851293125970633876119079943143591658862800994849059573686889159389176733059003153379233034613816659792612350870850962288977481684383189663339739491881038826218412717657583061136813919073865983955302240374321847921699285608519193376869374796534203431191622133490411113868972789018853758277298883278108604215524686573147875405580681233813375229835369597122930336579071659011305493 +bconv8 baseconv 2919929564262280016326432682972161358466398665016186667001143486624361781190367706444851840197851079596727038093730712199821599251718299339847712563214201624995683686942329198072246518178490343968248165061243767218811498814159781475518688080319940902866549541615061520458199757996522296964801679163389000871217341745667749351644081047030377927111638883433437694480358033912683425282448334012389020309749763957841286214328790748178789279825754956979292994543580131252034787858035703411486731741680089897128428834711018833010096571422396443329799706146308213505878878844626004235264807575864007093926619480833541324015063471078104056420326915116947401067109851932075196138030983716126816420531224588360189015976494005035758026314038292977171140049459616389565699576337363391835485410520435322339155656601552455327045876615610928759606256719025379763038966556553425044449074741425173631085926651516889855508069207136099220288203380161521368983721439855498436947709681774705358138025820342312716902518601 -> 2919929564262280016326432682972161358466398665016186667001143486624361781190367706444851840197851079596727038093730712199821599251718299339847712563214201624995683686942329198072246518178490343968248165061243767218811498814159781475518688080319940902866549541615061520458199757996522296964801679163389000871217341745667749351644081047030377927111638883433437694480358033912683425282448334012389020309749763957841286214328790748178789279825754956979292994543580131252034787858035703411486731741680089897128428834711018833010096571422396443329799706146308213505878878844626004235264807575864007093926619480833541324015063471078104056420326915116947401067109851932075196138030983716126816420531224588360189015976494005035758026314038292977171140049459616389565699576337363391835485410520435322339155656601552455327045876615610928759606256719025379763038966556553425044449074741425173631085926651516889855508069207136099220288203380161521368983721439855498436947709681774705358138025820342312716902518601 +bconv9 baseconv 4443626716871286334620487546377151789025176693244491882959436724484366603768034884502489633564660833009856731580646131411675319919882017589877506937868448502406334198744937656638946567127023414568573508211760000932627934342820738148640158145395011152865009882761742036055119760224421358744931836393477713536940027313145741576813447418061374889876687509017855968575104732154582395247029091962791165645622637986551867577275463143508143180769914404151217527449357643870088881632182984619175942747964816977170294685829354832687433338227420239642880904971272968415767253933179473869456786463849682399363799880300575817039352752950976714029419412544885511510558593153484682012385603963509568541509714291147578741700793254604782043773003984171568431334016620128211596703726226281001856083733522300364401741811461550998767957058404960176412547675707687469107620763960960216261711509428754701027358761185791498601011310619603375093901126951607586513180349052831443595256419965684342691421793872592561337361799 -> 4443626716871286334620487546377151789025176693244491882959436724484366603768034884502489633564660833009856731580646131411675319919882017589877506937868448502406334198744937656638946567127023414568573508211760000932627934342820738148640158145395011152865009882761742036055119760224421358744931836393477713536940027313145741576813447418061374889876687509017855968575104732154582395247029091962791165645622637986551867577275463143508143180769914404151217527449357643870088881632182984619175942747964816977170294685829354832687433338227420239642880904971272968415767253933179473869456786463849682399363799880300575817039352752950976714029419412544885511510558593153484682012385603963509568541509714291147578741700793254604782043773003984171568431334016620128211596703726226281001856083733522300364401741811461550998767957058404960176412547675707687469107620763960960216261711509428754701027358761185791498601011310619603375093901126951607586513180349052831443595256419965684342691421793872592561337361799 +bconv10 baseconv 1379983260050275126662040280723604646692370455950839443636659233046708221508635523843245624754639895760158203939809524597138754045206863299402250888874724022255259118287086780799548920169691742269370474055931677320146112194021520434033403978884513204044886206979544743500199027444529245822948046518453462669157068562264135035866638320311606268725356006573505790752667952838845733950512592079864899075956727747469838881620875654541649015267766468157336998534993076189129919860717264208060443550512004946985594435836401146342820230029829255242839955703978787909712609008504253997989141168796241758138191509829848394288740719759670849184179448070838433146539972380087100607013490138311203014379148698312164236000668592466549171268146190896785659450024963132392937234670239232438182458692716451533268779528479850535110396263068820233830083290801990160104456027045411885593084907281946832353953660620733435160429868604053553016810703677982791127756958214547870412106647432595422414453204760607868194877004 -> 1379983260050275126662040280723604646692370455950839443636659233046708221508635523843245624754639895760158203939809524597138754045206863299402250888874724022255259118287086780799548920169691742269370474055931677320146112194021520434033403978884513204044886206979544743500199027444529245822948046518453462669157068562264135035866638320311606268725356006573505790752667952838845733950512592079864899075956727747469838881620875654541649015267766468157336998534993076189129919860717264208060443550512004946985594435836401146342820230029829255242839955703978787909712609008504253997989141168796241758138191509829848394288740719759670849184179448070838433146539972380087100607013490138311203014379148698312164236000668592466549171268146190896785659450024963132392937234670239232438182458692716451533268779528479850535110396263068820233830083290801990160104456027045411885593084907281946832353953660620733435160429868604053553016810703677982791127756958214547870412106647432595422414453204760607868194877004 +bconv11 baseconv 4448004345146142785629745920492406921764649218759123133036614841100463437011629993211230868726792557532585712700069142158344250332516149356892632985225868080334248588754780661656860500055366984154135010009885132356335418054751384205941100979013354786442763261683125776734514137006625850548304559910700088731913048374843428977968141423787708919133001100785192080257260526304127630707133028535275417603792702320876796709784655885681728626937916613857114266255524165487485164014078045502117716030363584390173296598551817990743667505702424160524751501993088051681468935089580937626823822269740730045193354394033094248754052088555769437778526886414858399214151748299570338391080383194414095504457700964670658371471938937962752629062102133111135965110654972651388800160857073847017908923803154218943527538354613400975236208341063327905151072247074453326667566166621560422749442530002459716596855708664719076429294913819527715642829015343357903395969762624289808091545969969680229018107472919740236991190584 -> 4448004345146142785629745920492406921764649218759123133036614841100463437011629993211230868726792557532585712700069142158344250332516149356892632985225868080334248588754780661656860500055366984154135010009885132356335418054751384205941100979013354786442763261683125776734514137006625850548304559910700088731913048374843428977968141423787708919133001100785192080257260526304127630707133028535275417603792702320876796709784655885681728626937916613857114266255524165487485164014078045502117716030363584390173296598551817990743667505702424160524751501993088051681468935089580937626823822269740730045193354394033094248754052088555769437778526886414858399214151748299570338391080383194414095504457700964670658371471938937962752629062102133111135965110654972651388800160857073847017908923803154218943527538354613400975236208341063327905151072247074453326667566166621560422749442530002459716596855708664719076429294913819527715642829015343357903395969762624289808091545969969680229018107472919740236991190584 +bconv12 baseconv 2675411530661697972430852898801661681502698725601172571530571267139305266067068990605579384929027908364303215846434929394554247086553392279476479296855434807079041303955261516583368959279253834202496061281854706711543327317843903215099744408470007033253076115472469649170930867914277417055267503051837522236460404514404931182596686375579480627613466011047745930273491508669951618778617997711861313935873877372750290889770810876122106979789226450975363691873070029146697956460040693676380099931213890120405670441375528776705152524091709217687625488405936113224802045838772147304101625714510665782464565037104478588470643266375927226542688313423898351945881149049810440655006623442314767290461020158407077494109406746809495626537933971612104303391508777961139105967191744574497198431310802821784957383741617925062521191542542344000749453787214577830269038984475801552098030692122315658253829545295267160142397789592713359314510135489102715798977500916690425600110311037282039995237351296286394154000516 -> 2675411530661697972430852898801661681502698725601172571530571267139305266067068990605579384929027908364303215846434929394554247086553392279476479296855434807079041303955261516583368959279253834202496061281854706711543327317843903215099744408470007033253076115472469649170930867914277417055267503051837522236460404514404931182596686375579480627613466011047745930273491508669951618778617997711861313935873877372750290889770810876122106979789226450975363691873070029146697956460040693676380099931213890120405670441375528776705152524091709217687625488405936113224802045838772147304101625714510665782464565037104478588470643266375927226542688313423898351945881149049810440655006623442314767290461020158407077494109406746809495626537933971612104303391508777961139105967191744574497198431310802821784957383741617925062521191542542344000749453787214577830269038984475801552098030692122315658253829545295267160142397789592713359314510135489102715798977500916690425600110311037282039995237351296286394154000516 +bconv13 baseconv 4457957454927537688461812152803933057893309313661798019888844725916350791923049671091185745445568272000568499916105636792706734333983954150779210807392529079159051278051278262292856024058644300396302761060186609931250532629877809175222068073564884697977277531507942532257281014395414331251905239774181030885476669871480912542821276866009014330598625959273400996805201352616929690225543712626296502785181776274581768976850416282975572063304675361082023309913467922778505608308226543611541487997877655071116584940944135004871269552163099800312817987690937062356716497503037678719348937277376495353097218905809972095176792270051607660593855462162004570037701710694067564048135023380433144703177863199360133492487411261415303726923760045298880744947675329182486533530390893441999080772950540810023230419515085660899162799632900732682585309047544487440036455753860667472938783490922429296280934298800001057796572412100608311248608380585967549537366641301878649954263074006333369819025341934262552309890685 -> 4457957454927537688461812152803933057893309313661798019888844725916350791923049671091185745445568272000568499916105636792706734333983954150779210807392529079159051278051278262292856024058644300396302761060186609931250532629877809175222068073564884697977277531507942532257281014395414331251905239774181030885476669871480912542821276866009014330598625959273400996805201352616929690225543712626296502785181776274581768976850416282975572063304675361082023309913467922778505608308226543611541487997877655071116584940944135004871269552163099800312817987690937062356716497503037678719348937277376495353097218905809972095176792270051607660593855462162004570037701710694067564048135023380433144703177863199360133492487411261415303726923760045298880744947675329182486533530390893441999080772950540810023230419515085660899162799632900732682585309047544487440036455753860667472938783490922429296280934298800001057796572412100608311248608380585967549537366641301878649954263074006333369819025341934262552309890685 +bconv14 baseconv 3901731478067379289321396414220735780483357993523766698533020834981794870543061749700585421631842605264554120650064237776849231193010333912125858536232044522879995336857450253908748494812208231407059194357661803991617918115858949711849246437663986051219000307965439372723683897296674439191008816828076852138736526857966973763732443605971175782980326694206497798763264608229163395058251422643872948895677391283969909824869680456203331471503477925261194825975690758841481994158180416464348234989705882018982843155697677832471562437079133638442212142453990720049730780393460717585117969598323477927436762280026841735600279774322194245541129512682758846245966261565742384251315954742766690109760090572216988257430135321316854504694510840470144404697890543591914116451687894936506325032717134703136027463896647962750522017499458133789196705162230164646819974564691027479003408667421624630291372474382917784211558461382326828652210777230867674043008511866052133772286465654038522233473020187460660858467078 -> 3901731478067379289321396414220735780483357993523766698533020834981794870543061749700585421631842605264554120650064237776849231193010333912125858536232044522879995336857450253908748494812208231407059194357661803991617918115858949711849246437663986051219000307965439372723683897296674439191008816828076852138736526857966973763732443605971175782980326694206497798763264608229163395058251422643872948895677391283969909824869680456203331471503477925261194825975690758841481994158180416464348234989705882018982843155697677832471562437079133638442212142453990720049730780393460717585117969598323477927436762280026841735600279774322194245541129512682758846245966261565742384251315954742766690109760090572216988257430135321316854504694510840470144404697890543591914116451687894936506325032717134703136027463896647962750522017499458133789196705162230164646819974564691027479003408667421624630291372474382917784211558461382326828652210777230867674043008511866052133772286465654038522233473020187460660858467078 +bconv15 baseconv 4654130777947871235106565465151461084422095964715670606799600540876586888520431823265237922949993426848914383289973098627957823808805773242274705666650695023817068332288028053602837119889249722883578055730426987399507049473986719006531206803575340503737373496865980264428850316818313804183401209750356641907562290186962372904449973454829861996980367983026979009094600005922713262266060683650857145428130022094608561372706439532649518814843814449204700558944204035509625563733066128217457931997800137938160343188836384417256521429544967954247542582708910236174322494792390375695183411985047668205931860675174911781721745206295733293972811633532505651050769641655572883401097916816090263881897772298810854275755073672651722154645883152186711420145164721595742845251862241337791179482125602816644393867478451265452176043215132978604355139427712275063409763557305852406678326116558135079952714119015577110992661915124492008146567447428795131052411419705837588440257141317020517357052079636975130227738598 -> 4654130777947871235106565465151461084422095964715670606799600540876586888520431823265237922949993426848914383289973098627957823808805773242274705666650695023817068332288028053602837119889249722883578055730426987399507049473986719006531206803575340503737373496865980264428850316818313804183401209750356641907562290186962372904449973454829861996980367983026979009094600005922713262266060683650857145428130022094608561372706439532649518814843814449204700558944204035509625563733066128217457931997800137938160343188836384417256521429544967954247542582708910236174322494792390375695183411985047668205931860675174911781721745206295733293972811633532505651050769641655572883401097916816090263881897772298810854275755073672651722154645883152186711420145164721595742845251862241337791179482125602816644393867478451265452176043215132978604355139427712275063409763557305852406678326116558135079952714119015577110992661915124492008146567447428795131052411419705837588440257141317020517357052079636975130227738598 +bconv16 baseconv 6649903495575087493771153800953242013577961180039294825715918202194499150476079787233663406652222968364362252354240762502617978661038662922733262331646118100984108166924536086333452849695885092699887063761418150639306461176675118215408077899621015915846473405233244980498161913123975518197703425854340616426702694437109878025845512326109951618461458985590879975476585800012874776322341807433988214260227054910347409817529283536125266823702079634388079248386880483269208890693943579691797774134822687353629137294554151538135718438084289761599848683755669444925895723323735128773089825168205026900265063639996642154127713550940387749894386305836520239159650767511265284302953611296989644915506174898626874724649914780591548426436707748279509955263711360123961926166504566481355303194932535142301013074380419820133190413672212572428476095781855697590992981269974045223785486638733173531369239381887362699000567417791991159639207176177432662607169533803575718624467572452144772728607033970088225282900175 -> 6649903495575087493771153800953242013577961180039294825715918202194499150476079787233663406652222968364362252354240762502617978661038662922733262331646118100984108166924536086333452849695885092699887063761418150639306461176675118215408077899621015915846473405233244980498161913123975518197703425854340616426702694437109878025845512326109951618461458985590879975476585800012874776322341807433988214260227054910347409817529283536125266823702079634388079248386880483269208890693943579691797774134822687353629137294554151538135718438084289761599848683755669444925895723323735128773089825168205026900265063639996642154127713550940387749894386305836520239159650767511265284302953611296989644915506174898626874724649914780591548426436707748279509955263711360123961926166504566481355303194932535142301013074380419820133190413672212572428476095781855697590992981269974045223785486638733173531369239381887362699000567417791991159639207176177432662607169533803575718624467572452144772728607033970088225282900175 +bconv17 baseconv 6996509737946222698867238485076694621072402094269933465387492099143920190430008452426636655634646089930541211959828173942908249372946155950666340823104513423028341919890120057436903702031139750685311557236021391352395003548947349765311587042634256761797972079037345627684387942495896111629633162262050670642880163266515392797316783031120495645608452562147927818125087740040341409692212832018116079662378726408235148798543023397186664678892318065117107346049325182299374158008079604898946210765714053312358673486613834225634180428808852322431968232498746105815007552707092614013713040649910857121689180545859262652255302431621339064799096669259074349938901637338742611849630443991508904205506842943602580668042817746870016056008707055751157074378339256292513649853132024359053663233577846538980614863871469148630959809396046996718160742627778735657199756690312550505304906971080827163200349464601681466034484938492553599162654183170713923036067698101789277789817077614926142926076267939580351751164613 -> 6996509737946222698867238485076694621072402094269933465387492099143920190430008452426636655634646089930541211959828173942908249372946155950666340823104513423028341919890120057436903702031139750685311557236021391352395003548947349765311587042634256761797972079037345627684387942495896111629633162262050670642880163266515392797316783031120495645608452562147927818125087740040341409692212832018116079662378726408235148798543023397186664678892318065117107346049325182299374158008079604898946210765714053312358673486613834225634180428808852322431968232498746105815007552707092614013713040649910857121689180545859262652255302431621339064799096669259074349938901637338742611849630443991508904205506842943602580668042817746870016056008707055751157074378339256292513649853132024359053663233577846538980614863871469148630959809396046996718160742627778735657199756690312550505304906971080827163200349464601681466034484938492553599162654183170713923036067698101789277789817077614926142926076267939580351751164613 +bconv18 baseconv 2116191489308263919842229695571138781766021241069159740738752037964402858674223351204521076524821256755791969175295015726825071758580326486219533321673110521760362531300810374010768467270360551883059931390497457733276857413061518590862834568969071329777624777482160698986908983416052990879749156251779374729403479279235763975000193847000043935597288269667966036560223039666194190128474629654935974693390857486562580101192392344336865753922553121763911200779847981928703530924663154609110960932106742121402848079856596929626043513118690430954732489587924420640003182292969887620959723057268259140753281689542673339334989018519236126840735193611255499741990454998982055551289298915399977830485160133786045165674897211092904631588046969789434726387390025850081843876418781470670389772265799766298216028384685477388376351519666960392987893514723791614620884896648568244970851225259152618635602860192263408161263225316340413871233482525782477895516139728427180060766617995836311771075569755754521011817600 -> 2116191489308263919842229695571138781766021241069159740738752037964402858674223351204521076524821256755791969175295015726825071758580326486219533321673110521760362531300810374010768467270360551883059931390497457733276857413061518590862834568969071329777624777482160698986908983416052990879749156251779374729403479279235763975000193847000043935597288269667966036560223039666194190128474629654935974693390857486562580101192392344336865753922553121763911200779847981928703530924663154609110960932106742121402848079856596929626043513118690430954732489587924420640003182292969887620959723057268259140753281689542673339334989018519236126840735193611255499741990454998982055551289298915399977830485160133786045165674897211092904631588046969789434726387390025850081843876418781470670389772265799766298216028384685477388376351519666960392987893514723791614620884896648568244970851225259152618635602860192263408161263225316340413871233482525782477895516139728427180060766617995836311771075569755754521011817600 +bconv19 baseconv 3657040042388187005449752005773508721366439997895215536309206196053846912612124235946651814867988061086285642444748304248510808131113589460573938621610768020550215610437863758979730599736952685795593974626173569859389589918139817934292825340027189615141761776726092613165279554452207845753530978243066966833901336309557395747038797045769718545056516557961518499578837572752707262714655620719706697257573611516777976662489356063065015549618913961849956103160803527968052164644400918259577486286055618902047069100230870185329523384762479375986191205884796678656663173298967382923840435881655695585395544831070515111803728298446234488834526842163124508944382765785026470495934874129744497219393610952160058482549741625298926474300205119898320251588510907483157020160499964457760009310269992780703907345598149078511197602468887997120082448986866409054761685103267338315908935215667060641522809660805954716651402684172617527591399391859874170975483983020855509846069201137998297873371909477001553808723203 -> 3657040042388187005449752005773508721366439997895215536309206196053846912612124235946651814867988061086285642444748304248510808131113589460573938621610768020550215610437863758979730599736952685795593974626173569859389589918139817934292825340027189615141761776726092613165279554452207845753530978243066966833901336309557395747038797045769718545056516557961518499578837572752707262714655620719706697257573611516777976662489356063065015549618913961849956103160803527968052164644400918259577486286055618902047069100230870185329523384762479375986191205884796678656663173298967382923840435881655695585395544831070515111803728298446234488834526842163124508944382765785026470495934874129744497219393610952160058482549741625298926474300205119898320251588510907483157020160499964457760009310269992780703907345598149078511197602468887997120082448986866409054761685103267338315908935215667060641522809660805954716651402684172617527591399391859874170975483983020855509846069201137998297873371909477001553808723203 +bconv20 baseconv 1907290300779366901668875172193763841989087145111836138769863659204469308435136296787416959119310340505452393350804633310447991517676423170036998132338742466135461248965301062141326103795708839916063047063036192632494906454583674217604242576574267094226403890117973872599991379051480082755531518226394839433698285060291452191292723350752127747720524992813693607046092903905308877425933439510926778650305775042848237025867471460987322373688586656255345989164159354409399460934144745853291332651720120121304556768190072283203161699248244038261036404617128287377578823923303263967968800629523261448086933363365341451104278167418197117594320820097375260567632321120596850440960789648875144459866401734976231298903922816887102453792302823573209977187798936517822870365439650437692621048399349559374424942222932055961494221573113023286117068158511640356530673948373162523061804707818573376705122020437295596158479382403894290215300817040246807634634310157974888632207481833550397293704329123701360403814274 -> 1907290300779366901668875172193763841989087145111836138769863659204469308435136296787416959119310340505452393350804633310447991517676423170036998132338742466135461248965301062141326103795708839916063047063036192632494906454583674217604242576574267094226403890117973872599991379051480082755531518226394839433698285060291452191292723350752127747720524992813693607046092903905308877425933439510926778650305775042848237025867471460987322373688586656255345989164159354409399460934144745853291332651720120121304556768190072283203161699248244038261036404617128287377578823923303263967968800629523261448086933363365341451104278167418197117594320820097375260567632321120596850440960789648875144459866401734976231298903922816887102453792302823573209977187798936517822870365439650437692621048399349559374424942222932055961494221573113023286117068158511640356530673948373162523061804707818573376705122020437295596158479382403894290215300817040246807634634310157974888632207481833550397293704329123701360403814274 +bconv21 baseconv 8328412344011357368290367522944439229409032228696578744651361596318999532108496171340817772581187387192418173158023347185481222055504397931495197777675780884698581348970769415719832334622554398689409623552828941950609808268247216338490168096836094778633394505288615107212721305045534758642753310373006413602629581180049118640023923877038380750468854335183575949093581005089379756478505487068462160099587767722454601624199095499753921546299936767762788071699069263568742532752237287172744750544171703951332022145813717793646206441639319365228865360965994579774363994171221712456133645368925794338746222938853603217313375705740738044103090276908803879718484581435424599650193398252323358235503208373675412086437184679679451678025933986993311321848436400383152155583674981369799366426975966215456068347642477142985913367820490341330688486585340535111257130535692049654058846836932550781187779455705941675984957765321261124949399497002051458474561284647792408852165320773973140760472304867880225855389417 -> 8328412344011357368290367522944439229409032228696578744651361596318999532108496171340817772581187387192418173158023347185481222055504397931495197777675780884698581348970769415719832334622554398689409623552828941950609808268247216338490168096836094778633394505288615107212721305045534758642753310373006413602629581180049118640023923877038380750468854335183575949093581005089379756478505487068462160099587767722454601624199095499753921546299936767762788071699069263568742532752237287172744750544171703951332022145813717793646206441639319365228865360965994579774363994171221712456133645368925794338746222938853603217313375705740738044103090276908803879718484581435424599650193398252323358235503208373675412086437184679679451678025933986993311321848436400383152155583674981369799366426975966215456068347642477142985913367820490341330688486585340535111257130535692049654058846836932550781187779455705941675984957765321261124949399497002051458474561284647792408852165320773973140760472304867880225855389417 +bconv22 baseconv 3315121038768652940226841837053631189007355646557192168697741746644011445033624817385995512923201063642574168250797419031368478058307151407279301815966103873082189098636837520628838577114326829121193713777142906501371351078847040437205965114283690325759508068643058547709123874837372230270155816123290986439667215213492834547149693039386842524862862238608218519477851035441158448519941219447776343525300360515704384334933803837579893117022747558657773292490375981252728912263905250082810734874391494302401911790419857932315996668291676744616309705631968456347189549177461576110195536630394610419034115639346784232281789456099159904848602568218079020991194570834047393672543883052873705792336747276258257811706642737214667938649317459395024679338953204268129881155389186775958574260853719304964487921028029594998601538531171731101589856327194508397584028911542802783359288738613215754262493292449386174119367403622975503466190145175796831773757599253334483168229013517946884835924006753796121456678624 -> 3315121038768652940226841837053631189007355646557192168697741746644011445033624817385995512923201063642574168250797419031368478058307151407279301815966103873082189098636837520628838577114326829121193713777142906501371351078847040437205965114283690325759508068643058547709123874837372230270155816123290986439667215213492834547149693039386842524862862238608218519477851035441158448519941219447776343525300360515704384334933803837579893117022747558657773292490375981252728912263905250082810734874391494302401911790419857932315996668291676744616309705631968456347189549177461576110195536630394610419034115639346784232281789456099159904848602568218079020991194570834047393672543883052873705792336747276258257811706642737214667938649317459395024679338953204268129881155389186775958574260853719304964487921028029594998601538531171731101589856327194508397584028911542802783359288738613215754262493292449386174119367403622975503466190145175796831773757599253334483168229013517946884835924006753796121456678624 +bconv23 baseconv 6804245394199269510260034849949978284687327306683921369181439323876828465556100484976178041716688674305463899900458911076905277468163343462137822632584182743731281984437488681436666726451834179529184078424856695673066640496971437284829916240678022419952687411772136464337324320225373507006271131972344443139360057945368240260971363067201402822727575125099568531251819191664536642544248372067289456726584341697288252957793751361011403471549699801466477354823166069693053656728777101314468017537429026176290497367558839666977995278745969891941831468149748702932620902604503605214651500623972887082337149658187829379376355016799927193548707291452731052528210116066324840524694921179631087998683512916419578405529971986301195979518917420386922728264097722572544898296499789395800327460813295878816222331616588596221312529112368413980403510595503226864025841040537005080129922706121337538857825719544388210087707021436458973221469743142609347923625197028964479981508482347547748024532911494015282509761609 -> 6804245394199269510260034849949978284687327306683921369181439323876828465556100484976178041716688674305463899900458911076905277468163343462137822632584182743731281984437488681436666726451834179529184078424856695673066640496971437284829916240678022419952687411772136464337324320225373507006271131972344443139360057945368240260971363067201402822727575125099568531251819191664536642544248372067289456726584341697288252957793751361011403471549699801466477354823166069693053656728777101314468017537429026176290497367558839666977995278745969891941831468149748702932620902604503605214651500623972887082337149658187829379376355016799927193548707291452731052528210116066324840524694921179631087998683512916419578405529971986301195979518917420386922728264097722572544898296499789395800327460813295878816222331616588596221312529112368413980403510595503226864025841040537005080129922706121337538857825719544388210087707021436458973221469743142609347923625197028964479981508482347547748024532911494015282509761609 +bconv24 baseconv 3686532736301042996488042910928063833489647059297391474122474701750564654110016258961447876266046086834852964908838784834587073241452184635035963961046386305821886799155716293425362673049188661792395475716317976976684769107610705711472976353536366804972042316389741529534690458188594239789604723997641379307797793779518138523424188676397613888973743393771726693858331232740765910599277581866664214078202391294789383117661180484224817280648201737647502698999700953581325303621031625442267785575612996856600367541945211555323989440032278872471874217949251450632203968103482980314632447449153203853357171784778655382011783931470854850604123884194777900839504131153587495521637254979399578885540352544495477433223752505186577601508341374172299226598461655364332506841640420208670096660203392391167006912846780603848291124277608802051055715882837409094312835075322549092043613679068069558022788103362582792012338193726573290684719371733833799193248715968095684163061578300710053097734086131318134072508442 -> 3686532736301042996488042910928063833489647059297391474122474701750564654110016258961447876266046086834852964908838784834587073241452184635035963961046386305821886799155716293425362673049188661792395475716317976976684769107610705711472976353536366804972042316389741529534690458188594239789604723997641379307797793779518138523424188676397613888973743393771726693858331232740765910599277581866664214078202391294789383117661180484224817280648201737647502698999700953581325303621031625442267785575612996856600367541945211555323989440032278872471874217949251450632203968103482980314632447449153203853357171784778655382011783931470854850604123884194777900839504131153587495521637254979399578885540352544495477433223752505186577601508341374172299226598461655364332506841640420208670096660203392391167006912846780603848291124277608802051055715882837409094312835075322549092043613679068069558022788103362582792012338193726573290684719371733833799193248715968095684163061578300710053097734086131318134072508442 +bconv25 baseconv 9806425993239671328964787689608564617574418553508282368444375580341116067815899987605980741331303696938727519029413939870373428052875303489792984890171196972473936801668287197162320517327985197071488157807745918869940805258349578098539677465223440959981935395385316060564419540393298777459389205890799953324298538353919505987331885955502016762413882044537481833192614088945899916184385227531944461676129718921921753347739724401194215163003353869584732936674043658664674098823275556920482819284164873966516006199321915776415829231211413908013546069047895409855580420073719001323986087951105311246597095642947881172848968202435175735519380160089738940599283457821680657206189943586937672628849320700468532705595996038074797550271126672411281331282751684452032124500847395101862340320849995645638709613152547119381445180543376086732985709904442004607047463811239459217966137017602452773783200231982049966238375060398810338741479314473594852526323287888398314240751714108340660375473679080175680982540941 -> 9806425993239671328964787689608564617574418553508282368444375580341116067815899987605980741331303696938727519029413939870373428052875303489792984890171196972473936801668287197162320517327985197071488157807745918869940805258349578098539677465223440959981935395385316060564419540393298777459389205890799953324298538353919505987331885955502016762413882044537481833192614088945899916184385227531944461676129718921921753347739724401194215163003353869584732936674043658664674098823275556920482819284164873966516006199321915776415829231211413908013546069047895409855580420073719001323986087951105311246597095642947881172848968202435175735519380160089738940599283457821680657206189943586937672628849320700468532705595996038074797550271126672411281331282751684452032124500847395101862340320849995645638709613152547119381445180543376086732985709904442004607047463811239459217966137017602452773783200231982049966238375060398810338741479314473594852526323287888398314240751714108340660375473679080175680982540941 +bconv26 baseconv 5916130888921052157563868436065271115971725780622350739858076731106466137697255123313723107278590516969456927830770686259430616477305047671993424735145212659806134287287638001542266925357294137882488836818840569304093986517803426139845072038852269292990680800969209238212679473117880626638045843893226192937862920572923354746205494457476368092131165953754632095472040614753795482618846078204922499068766980579883853147586963630596721642521066731371741755080071899209858124484832480865391717667048153041170504554040212726252583709450749236839364384220162930945690573814746579831780215988682605565267988407477367560243730168405685871433656925714418977440608757588341303558880594720065780582599444281764583014401520157253252207334351799111071355380057269389505231535948957424142627549398508762893929171384459289215449159164498928757202513442408578282203596362868300333913733923522235131526272986498880583818330739060535067111484420019640022198496840864323412417764897401201919435299597412888972729886738 -> 5916130888921052157563868436065271115971725780622350739858076731106466137697255123313723107278590516969456927830770686259430616477305047671993424735145212659806134287287638001542266925357294137882488836818840569304093986517803426139845072038852269292990680800969209238212679473117880626638045843893226192937862920572923354746205494457476368092131165953754632095472040614753795482618846078204922499068766980579883853147586963630596721642521066731371741755080071899209858124484832480865391717667048153041170504554040212726252583709450749236839364384220162930945690573814746579831780215988682605565267988407477367560243730168405685871433656925714418977440608757588341303558880594720065780582599444281764583014401520157253252207334351799111071355380057269389505231535948957424142627549398508762893929171384459289215449159164498928757202513442408578282203596362868300333913733923522235131526272986498880583818330739060535067111484420019640022198496840864323412417764897401201919435299597412888972729886738 +bconv27 baseconv 7275369226125959639152288581118257072486354584593886378635049043920221172449198271838883701950714119646253728366886207200431667633194156185049979953945084319274329428689189570940196597435917503503955733126091393101462333331817625535101453679407634517642160751823322283219139547397583540065078390480388873437631474059635741726218645220222514582640800410149535284105687101924210396486664754344141000519526708507190546015890733341893773711725518795544278775689603064725109311618981653001747651166525191121725854060274403796775730045061561272541678538174953324595712582582966609181850738981313274654973683910198578635364841605686095000492542853598957850649168239127355641352294310703161912533212101994409023855128599075323612962733518940042534688928722761021503474651443122070987854270654460834076028754869251114775457595448695183246026783131165897104690493291655974245507669403553417538538446975373429432818414524762970357885688657753258617452716146032543786726760696399029575673758164951870721717039111 -> 7275369226125959639152288581118257072486354584593886378635049043920221172449198271838883701950714119646253728366886207200431667633194156185049979953945084319274329428689189570940196597435917503503955733126091393101462333331817625535101453679407634517642160751823322283219139547397583540065078390480388873437631474059635741726218645220222514582640800410149535284105687101924210396486664754344141000519526708507190546015890733341893773711725518795544278775689603064725109311618981653001747651166525191121725854060274403796775730045061561272541678538174953324595712582582966609181850738981313274654973683910198578635364841605686095000492542853598957850649168239127355641352294310703161912533212101994409023855128599075323612962733518940042534688928722761021503474651443122070987854270654460834076028754869251114775457595448695183246026783131165897104690493291655974245507669403553417538538446975373429432818414524762970357885688657753258617452716146032543786726760696399029575673758164951870721717039111 +bconv28 baseconv 6936181853903661370294189648248327184827734642073493270422122131281973980787554898303935174911383626495892816275715112673338987288755715868481857300821172506884749192188289982807115712418841300156560406962004223009568721667373354101748696829640867604662898090507583814461683504817651669413529993177123797274962767996915351854056320679498229762727867700522585287428266151756817730538657228416066968330856073220614143749817918368727695675333976756671771168559497265397186285351296289607150944819038053052404298260860833847239961470959510963789777670647424489220427924069052035843610655539573317403576480138140507770258250233937846137745905433789026241541290129894032067761467194927877930901970375621983969081728588244400297449841487055080985108372281612450998413297731552804120065468245488020719508008272467925276208758416542010378563861619491118255936628383662509607074742149818208126190611711579905808043445878961660197452306483614131947589735097400551697760450512428137995480847506688754735583206629 -> 6936181853903661370294189648248327184827734642073493270422122131281973980787554898303935174911383626495892816275715112673338987288755715868481857300821172506884749192188289982807115712418841300156560406962004223009568721667373354101748696829640867604662898090507583814461683504817651669413529993177123797274962767996915351854056320679498229762727867700522585287428266151756817730538657228416066968330856073220614143749817918368727695675333976756671771168559497265397186285351296289607150944819038053052404298260860833847239961470959510963789777670647424489220427924069052035843610655539573317403576480138140507770258250233937846137745905433789026241541290129894032067761467194927877930901970375621983969081728588244400297449841487055080985108372281612450998413297731552804120065468245488020719508008272467925276208758416542010378563861619491118255936628383662509607074742149818208126190611711579905808043445878961660197452306483614131947589735097400551697760450512428137995480847506688754735583206629 +bconv29 baseconv 6598643693280921096277040697343237276354612940998612241915180995498884135486456917941502336856143039655852760319886039890057203623771893671304160111474793308339466148429137395501938619948630730482573531378741497564564478272172826558465171996542010455144732967169803703753153175850488283979722445728025916308259008376565303985907684134811513667076552564501127693845796083868723408308555272045717262999181209882153166393671613963881145827103377487772361618200465096156374703076175272664777364110710702230313312801052930769127495247951688592893534116971268391148600666199131844158004902702590444207540822850471928975467515588814183828088306013611431940021474417877757253302841455495351595543143465513692958962963606252741251648061876917688943307106721157290530319974950613636684454430278850331189346521135177535448718614345941552271157503715618418703044010369802931292837673229022567717006302803135528250568284434770091981809115229562524970028987999906270813570312987067785406168708579050380445152143496 -> 6598643693280921096277040697343237276354612940998612241915180995498884135486456917941502336856143039655852760319886039890057203623771893671304160111474793308339466148429137395501938619948630730482573531378741497564564478272172826558465171996542010455144732967169803703753153175850488283979722445728025916308259008376565303985907684134811513667076552564501127693845796083868723408308555272045717262999181209882153166393671613963881145827103377487772361618200465096156374703076175272664777364110710702230313312801052930769127495247951688592893534116971268391148600666199131844158004902702590444207540822850471928975467515588814183828088306013611431940021474417877757253302841455495351595543143465513692958962963606252741251648061876917688943307106721157290530319974950613636684454430278850331189346521135177535448718614345941552271157503715618418703044010369802931292837673229022567717006302803135528250568284434770091981809115229562524970028987999906270813570312987067785406168708579050380445152143496 +bconv30 baseconv 1004196103346472752674565281340460756966728517262459117954323520421589665427819254142667248662990584242535350070341879422090370943295920871511777118110197784868588411414095230519945091136202145363783889529990295304290900233150081340154309171129047759577137637693000830644427423231541229958760971795349358090445632395232394103411530421494557184062919901350843818778432950317879787413325611976705348300144554688207718145131366219857023385401503395786835765440122315352006748334989418131659627695401721511191840831346883531056207399376758786442181263361990977659310944230849094346885506255005665339603004141435656297078934280499292657930832503603522637716560755051817435846934856130834840354324344976737243935715184209403164420455494024164523600423794139107055254899265022876279581256403089243025870210433900835450349375321300997236945669785889231868991397723295039745819381692990957887095000009927818403461910686945480819856534450846233655354633300191460923627938361343548466791923855656708809373653602 -> 1004196103346472752674565281340460756966728517262459117954323520421589665427819254142667248662990584242535350070341879422090370943295920871511777118110197784868588411414095230519945091136202145363783889529990295304290900233150081340154309171129047759577137637693000830644427423231541229958760971795349358090445632395232394103411530421494557184062919901350843818778432950317879787413325611976705348300144554688207718145131366219857023385401503395786835765440122315352006748334989418131659627695401721511191840831346883531056207399376758786442181263361990977659310944230849094346885506255005665339603004141435656297078934280499292657930832503603522637716560755051817435846934856130834840354324344976737243935715184209403164420455494024164523600423794139107055254899265022876279581256403089243025870210433900835450349375321300997236945669785889231868991397723295039745819381692990957887095000009927818403461910686945480819856534450846233655354633300191460923627938361343548466791923855656708809373653602 +bconv31 baseconv 6752266525911602782261309781182101273913113769485915148140089178958274774606065364647471616727162257211032115563300881118239956504424028638683052023075476886057700162228045438788093014227668254148960390074403458248586810033916508707141095759145754594740061441508007404826827705354166300443543935902562958042346348525597557407385970641687427831021535306457943109637655867177425393712434541225028264700108528124148509580572509801048158964479817437794371869476899571468951093075328706316244378594833011981133468793686815563897806932066916704869658487449478084255890384023679963989773046553602989448081093681804074115952623378079909051486681530374478339690153072449088447631850934413244055912966562232116643709164876283876909834880165297902785336471373481752744050309591967035729193717321345489672215124100912773655784215673962706652767882041886384421822330939545828692146328669692576965861936240738309721988424656215816848239812450750485341730306776309524466777054854468126252423093449386197935663670290 -> 6752266525911602782261309781182101273913113769485915148140089178958274774606065364647471616727162257211032115563300881118239956504424028638683052023075476886057700162228045438788093014227668254148960390074403458248586810033916508707141095759145754594740061441508007404826827705354166300443543935902562958042346348525597557407385970641687427831021535306457943109637655867177425393712434541225028264700108528124148509580572509801048158964479817437794371869476899571468951093075328706316244378594833011981133468793686815563897806932066916704869658487449478084255890384023679963989773046553602989448081093681804074115952623378079909051486681530374478339690153072449088447631850934413244055912966562232116643709164876283876909834880165297902785336471373481752744050309591967035729193717321345489672215124100912773655784215673962706652767882041886384421822330939545828692146328669692576965861936240738309721988424656215816848239812450750485341730306776309524466777054854468126252423093449386197935663670290 +bconv32 baseconv 440257917310780857842885050379591596012036075071213321710948182473797857890030997135164519948347083742128114102407556300875737799780983942275954183063508915004952641113089072574255715897435224666678088129934983100393646248642715641003835014095502488063163943515735856096516326899705087514043632089486677424850306124503171834727275480343810326376593169392613877217949967881808319658787776776410711077590418512166345281650507834288980598016546605895203557155833554212440539414924697400487262258073768695629532591738713885342105556162405739880555951241630882786848561713953645293528153133509469619926532391448370511408130948529847493950976604742114277098648699436364503379391395909014535547756482651213882176818652911095524223923379596043074976709227531637518950502491681028014655168923801167906611729976386248768730674233570453750272640489228917425890079918437257960524790011173183448589629729179813335509345969256152080935282235527666763612946752944717359262890145332816666206536522986834929857422656 -> 440257917310780857842885050379591596012036075071213321710948182473797857890030997135164519948347083742128114102407556300875737799780983942275954183063508915004952641113089072574255715897435224666678088129934983100393646248642715641003835014095502488063163943515735856096516326899705087514043632089486677424850306124503171834727275480343810326376593169392613877217949967881808319658787776776410711077590418512166345281650507834288980598016546605895203557155833554212440539414924697400487262258073768695629532591738713885342105556162405739880555951241630882786848561713953645293528153133509469619926532391448370511408130948529847493950976604742114277098648699436364503379391395909014535547756482651213882176818652911095524223923379596043074976709227531637518950502491681028014655168923801167906611729976386248768730674233570453750272640489228917425890079918437257960524790011173183448589629729179813335509345969256152080935282235527666763612946752944717359262890145332816666206536522986834929857422656 +bconv33 baseconv 3621353659591906193508941253810506896901678343406310586994856313276653053044386287410607428317762846139129646965927449071502639869626408112761769728810904723010711845307914540552831499388815737207970770478797091482893485028243111795169729965554644305570976708388224925905702090112713699364147913641836531255143839947328484917942851975474838601541072125493686621084842258302052974571531215761432665069667504883053907461979969327201761124150368219635334419889799232992470439818171770840319533327219243806435915181225632660122600753485358227736681953614421734470723800561505404821108000842734274203713769000101632463457496443596861734020146282331400706437025446606691234423844959336358952705559868999324825139751226070870320775500819979806400494646682955514937244456822634567159242800461859730120499375643589320058157821284995810648062296525351884262824645523112359005602442729090064605796280713419223146575889922011828760185428898948751655444812589600293065062945975081449295839799302808126472998975032 -> 3621353659591906193508941253810506896901678343406310586994856313276653053044386287410607428317762846139129646965927449071502639869626408112761769728810904723010711845307914540552831499388815737207970770478797091482893485028243111795169729965554644305570976708388224925905702090112713699364147913641836531255143839947328484917942851975474838601541072125493686621084842258302052974571531215761432665069667504883053907461979969327201761124150368219635334419889799232992470439818171770840319533327219243806435915181225632660122600753485358227736681953614421734470723800561505404821108000842734274203713769000101632463457496443596861734020146282331400706437025446606691234423844959336358952705559868999324825139751226070870320775500819979806400494646682955514937244456822634567159242800461859730120499375643589320058157821284995810648062296525351884262824645523112359005602442729090064605796280713419223146575889922011828760185428898948751655444812589600293065062945975081449295839799302808126472998975032 +bconv34 baseconv 308795464510742559038105298998650304693743855190451369231852174029328147828968019648350478584774581215554346346526918171844510869198854254166843295074260340042544887166276876664752431549556107161510308500274009980876373166522982913840289527272231992347198001534349937259004557053378162709310644857639945270377504295414585529256963273256200779045365018036677454863035987215261988585637704991785837763798523983570544859576027424083994485787713082684449909069205930527190273288743083638328440085526809509431265121686599742496560540770977709747428376682194491019161559113803649831195695072597665413143218109307104138026431080332613297706716914987105375345654626687427798906556292847453594207675937769058998973367887583511032056963246095438264673043664061258189467479914955392559746430546324500326847830808190047702458062622776247297602194170423483162848016170210879216185544107801209608310208624210118062804148867599052086976867844545621306890327314696328264871352243288884669295810429126150722004356038 -> 308795464510742559038105298998650304693743855190451369231852174029328147828968019648350478584774581215554346346526918171844510869198854254166843295074260340042544887166276876664752431549556107161510308500274009980876373166522982913840289527272231992347198001534349937259004557053378162709310644857639945270377504295414585529256963273256200779045365018036677454863035987215261988585637704991785837763798523983570544859576027424083994485787713082684449909069205930527190273288743083638328440085526809509431265121686599742496560540770977709747428376682194491019161559113803649831195695072597665413143218109307104138026431080332613297706716914987105375345654626687427798906556292847453594207675937769058998973367887583511032056963246095438264673043664061258189467479914955392559746430546324500326847830808190047702458062622776247297602194170423483162848016170210879216185544107801209608310208624210118062804148867599052086976867844545621306890327314696328264871352243288884669295810429126150722004356038 +bconv35 baseconv 3726041560049006100163654455361941980588163637178625105040559810885265380853813660755795711159298663467502626939222207455776795011811588610725154667543293197865938235542423513004592889500903010573131092713197355793748384727271457585762087222467902810692695066088946860190086424091368150998598721211997257258125099799695191062205677399589742762903614733724680506773107185389405135718823311577607460101130575571498689138483313979792716858273984958318873410404523131884127872978608469487246944318221630200531908398278759310750307522599435665413739802758837182408478435577094399398384171679115775374798853208413837531844250684213948710739334653310823586014699507016691503283407741922804931865316127810210802323179207376593083151896740283801318867157189804347717098485324711798062857615642593358118168628921529175536682368036235022730428002163355353145571774505431895087068942661973353226557773935384585568337201959332169325578170719928539232910297892668474764498160502445962630055590605297452391791541743 -> 3726041560049006100163654455361941980588163637178625105040559810885265380853813660755795711159298663467502626939222207455776795011811588610725154667543293197865938235542423513004592889500903010573131092713197355793748384727271457585762087222467902810692695066088946860190086424091368150998598721211997257258125099799695191062205677399589742762903614733724680506773107185389405135718823311577607460101130575571498689138483313979792716858273984958318873410404523131884127872978608469487246944318221630200531908398278759310750307522599435665413739802758837182408478435577094399398384171679115775374798853208413837531844250684213948710739334653310823586014699507016691503283407741922804931865316127810210802323179207376593083151896740283801318867157189804347717098485324711798062857615642593358118168628921529175536682368036235022730428002163355353145571774505431895087068942661973353226557773935384585568337201959332169325578170719928539232910297892668474764498160502445962630055590605297452391791541743 +bconv36 baseconv 763910724292309486516326277415854118225332049044437015134006833421469612314738033380784731115337197371458681732393523523977599341492606588701422401444374099743578325687621481298789249783813593008548957814059579674887052565189633811888734731294529006436394504452875849915536743426289217024314215755563306884820438175200596397389213836073383556123392632828286911984646171313551189151600580667052605459246569857270359810232738347701166670513010038433944221388753438297395674031133204029575385667008503448682719455099422999994547982773975330618517861295624322461680941813568600806651446117610272011337588720333583866174530342054384298950397765080640768756053011763658354928222772680992044693112829645713742568148323121041527304157173121879422852240330978621677863034185799507545331453179012913449978214038546427613102912784362561820125841308606071796434962184879177846617529826432949065643809170390888677631530384588577149287816456390895559878277577380494507459146979906567844463858286613737185207131233 -> 763910724292309486516326277415854118225332049044437015134006833421469612314738033380784731115337197371458681732393523523977599341492606588701422401444374099743578325687621481298789249783813593008548957814059579674887052565189633811888734731294529006436394504452875849915536743426289217024314215755563306884820438175200596397389213836073383556123392632828286911984646171313551189151600580667052605459246569857270359810232738347701166670513010038433944221388753438297395674031133204029575385667008503448682719455099422999994547982773975330618517861295624322461680941813568600806651446117610272011337588720333583866174530342054384298950397765080640768756053011763658354928222772680992044693112829645713742568148323121041527304157173121879422852240330978621677863034185799507545331453179012913449978214038546427613102912784362561820125841308606071796434962184879177846617529826432949065643809170390888677631530384588577149287816456390895559878277577380494507459146979906567844463858286613737185207131233 +bconv37 baseconv 6411515545958508267730136820938002132508113759229495199541247104652604001059503338423976623452921787201156579581245598712866600199256520892211613414354436773279725384056227551456716358240653787674886753611647804186156853394862677853883332950900858273796500908751310696781256567131321998751357135507574514934672253934561944097811057342562882728600292526208941005701647200982238969900527040553971916032470069621890311699244595775579274839171496623843703670477165252423039634230051398552931354740090014182115836248477494264811315743487512372128756187403475153215582621466879547337803845868875677218447608584482034647674131040792972430980450078326214504048353860255244997647483297098048146469661610342026041301338514520321898973465757980269641911105381237851746688386235286919802211717729068835066589934638629523970293932883686360753917368800885117185991325557106614847018755355002701644869414562432732066345711871930472851440718916540312613617566701117164697552724160814098257993080941501402572355655342 -> 6411515545958508267730136820938002132508113759229495199541247104652604001059503338423976623452921787201156579581245598712866600199256520892211613414354436773279725384056227551456716358240653787674886753611647804186156853394862677853883332950900858273796500908751310696781256567131321998751357135507574514934672253934561944097811057342562882728600292526208941005701647200982238969900527040553971916032470069621890311699244595775579274839171496623843703670477165252423039634230051398552931354740090014182115836248477494264811315743487512372128756187403475153215582621466879547337803845868875677218447608584482034647674131040792972430980450078326214504048353860255244997647483297098048146469661610342026041301338514520321898973465757980269641911105381237851746688386235286919802211717729068835066589934638629523970293932883686360753917368800885117185991325557106614847018755355002701644869414562432732066345711871930472851440718916540312613617566701117164697552724160814098257993080941501402572355655342 +bconv38 baseconv 5174625584624399635838288474476124397203760920636997516118656069770822728294082492749226425608179967823341292123482520809599475995961416113033204588016354020749821257912770919045988476305124209613472190297598127117952435245070935995641443376127236275350158995712787426025492880516833993243056798578723222753765722871885579054282326817290307376724619125441999533393789689705173855158158930760119922239168783730127869648192538407984164482676536809333697348211617179165038177483255555747615585517167803897732394711264086748006469378716987797942387530452026798925622800651506758418722360064878321021237013720855453530839943553473628728898348109463323514238893536755093404757558600965373824422388594361035338899020856603579660866317948378744107552202155377928382155890911406870308625158970319654836274702831571102104395558006228709138525329337571500762473089961969115532087500298686625626553303153317111271265731670675591997951887513670696164727380539163706011247089942921882843877808412750098421753752774 -> 5174625584624399635838288474476124397203760920636997516118656069770822728294082492749226425608179967823341292123482520809599475995961416113033204588016354020749821257912770919045988476305124209613472190297598127117952435245070935995641443376127236275350158995712787426025492880516833993243056798578723222753765722871885579054282326817290307376724619125441999533393789689705173855158158930760119922239168783730127869648192538407984164482676536809333697348211617179165038177483255555747615585517167803897732394711264086748006469378716987797942387530452026798925622800651506758418722360064878321021237013720855453530839943553473628728898348109463323514238893536755093404757558600965373824422388594361035338899020856603579660866317948378744107552202155377928382155890911406870308625158970319654836274702831571102104395558006228709138525329337571500762473089961969115532087500298686625626553303153317111271265731670675591997951887513670696164727380539163706011247089942921882843877808412750098421753752774 +bconv39 baseconv 7163208824566942977148218402930665660687663125682202746391322700451342684941566945643962889878419371252587344191345409455421121862651441157094908122925603939811167255761501922529836164615866567730468003310641456683341227651215776783897261497424016815324650946620339823790757441162270394866242291053815472270918011381537885273997769204549005774733404245486598255591383194160320079197797897693672093342666584962497804702941491250327871060069405925739060917907264492564780120205604616939835556738392439582254619242199495859638526568262688928557403773788067344563251627306375519890338119135501231541471040146227738143000270536117844518543070033436884725515914035040465388084072126791625912299970445080530456380568877946496791520184904260387723710591569546944563044373730264833705711849508322878263146853245514784344288908926879315686479603681521311639279042773336407962820049615921728704542808741590678969226396640480579282556933457717117196373661806557610103528779614190574603333706950356767595599919390 -> 7163208824566942977148218402930665660687663125682202746391322700451342684941566945643962889878419371252587344191345409455421121862651441157094908122925603939811167255761501922529836164615866567730468003310641456683341227651215776783897261497424016815324650946620339823790757441162270394866242291053815472270918011381537885273997769204549005774733404245486598255591383194160320079197797897693672093342666584962497804702941491250327871060069405925739060917907264492564780120205604616939835556738392439582254619242199495859638526568262688928557403773788067344563251627306375519890338119135501231541471040146227738143000270536117844518543070033436884725515914035040465388084072126791625912299970445080530456380568877946496791520184904260387723710591569546944563044373730264833705711849508322878263146853245514784344288908926879315686479603681521311639279042773336407962820049615921728704542808741590678969226396640480579282556933457717117196373661806557610103528779614190574603333706950356767595599919390 +bconv40 baseconv 2442590512156701117031630849457190212515631854179642736927154149600700440091117348527893566301678725981445363707396308072362064192627996877900528379016271258485843917542590411330025226643520492807062043420095626267157212566054324457494027542423685584382725824987540264001060298472929399840148814277659779127514160521181701323428366451327159041320060056644755701962798811149306267781505838684110713067807827509356119600772484650829145745413269832979319281624763361480271814777357901600682023418709682284211749387582567399379397894854112063802397034107651634935041161377371024226477566190149557354212812482218568577263412802676072092824438826362788106625345066467727789258460551135902116876188425340113639931692913189919664142663638442724316612310664449136896951677550235918642162995049238264029634858046113401242567900047528060555287619662603681746132789103481894743474202147194118888177102446780097884374766335791538166576730272590064349313778412822102656012833524867720436833594297581407086029085112 -> 2442590512156701117031630849457190212515631854179642736927154149600700440091117348527893566301678725981445363707396308072362064192627996877900528379016271258485843917542590411330025226643520492807062043420095626267157212566054324457494027542423685584382725824987540264001060298472929399840148814277659779127514160521181701323428366451327159041320060056644755701962798811149306267781505838684110713067807827509356119600772484650829145745413269832979319281624763361480271814777357901600682023418709682284211749387582567399379397894854112063802397034107651634935041161377371024226477566190149557354212812482218568577263412802676072092824438826362788106625345066467727789258460551135902116876188425340113639931692913189919664142663638442724316612310664449136896951677550235918642162995049238264029634858046113401242567900047528060555287619662603681746132789103481894743474202147194118888177102446780097884374766335791538166576730272590064349313778412822102656012833524867720436833594297581407086029085112 +bconv41 baseconv 1462596005916429283054005263808163790493085277256453231136362550444441480911829345109591443209796206205996143605788272858462497102864836795580099108512867538985462460363572315797203463773416440512322096023170114565728430816931447392396454835561720670509142744287685313449298723358830190249313246457363242751828143859005804986813506198858810729333044170595730067552746331339779262417663260428610802775987697888879236785196789738964310600898237498919472772068139976011639976778386479608473763074300198139260661071265553356985348605590760754943853558347054379167855134033261973633120450687421999069146171053425998897271329228658178816747182297407815193265700669387893404841784049557008406972044325991980080200988020008211292852743534484626844455596854632964242521958009293964957224894494458576450042252938179217444854374907750450945728230867014663890313627130176356366699203739386867786915282879269309616437139780723092928085008432838059345028268923873475499721481787352411901385169430155594273302889117 -> 1462596005916429283054005263808163790493085277256453231136362550444441480911829345109591443209796206205996143605788272858462497102864836795580099108512867538985462460363572315797203463773416440512322096023170114565728430816931447392396454835561720670509142744287685313449298723358830190249313246457363242751828143859005804986813506198858810729333044170595730067552746331339779262417663260428610802775987697888879236785196789738964310600898237498919472772068139976011639976778386479608473763074300198139260661071265553356985348605590760754943853558347054379167855134033261973633120450687421999069146171053425998897271329228658178816747182297407815193265700669387893404841784049557008406972044325991980080200988020008211292852743534484626844455596854632964242521958009293964957224894494458576450042252938179217444854374907750450945728230867014663890313627130176356366699203739386867786915282879269309616437139780723092928085008432838059345028268923873475499721481787352411901385169430155594273302889117 +bconv42 baseconv 6003440810579011357507045403594805569479648469548145659676314975675693669555605403166849635619463768037287447283683759357892495488674382913703398731670134123141633248425059632858763785915841384370326798634937968413231654866526023610017045668366783935939450996424348449643388869278053038184741175697746596458028747658017251818090466912148886719813072540787397893148925658020888581382326398733953832989597079154000589107618102335200280135656609005288720668870933525199198931539113380157211442403200039476461777632567144891933528540531448462768277557245603834570087318563441866125250097881324642417557294031750278828906131619039336845594064848455503179335543707564986761779010789905209005665864612210671498279664536789564345869843664582285468055022400799042951851597918357849630840726094858848176940153919452364777054495261694861761379110185958789742113858039058125576792142784114673447347031879914005772415291291687621557738375491780919053257837439454060608958364580485351551249595826247169397001297650 -> 6003440810579011357507045403594805569479648469548145659676314975675693669555605403166849635619463768037287447283683759357892495488674382913703398731670134123141633248425059632858763785915841384370326798634937968413231654866526023610017045668366783935939450996424348449643388869278053038184741175697746596458028747658017251818090466912148886719813072540787397893148925658020888581382326398733953832989597079154000589107618102335200280135656609005288720668870933525199198931539113380157211442403200039476461777632567144891933528540531448462768277557245603834570087318563441866125250097881324642417557294031750278828906131619039336845594064848455503179335543707564986761779010789905209005665864612210671498279664536789564345869843664582285468055022400799042951851597918357849630840726094858848176940153919452364777054495261694861761379110185958789742113858039058125576792142784114673447347031879914005772415291291687621557738375491780919053257837439454060608958364580485351551249595826247169397001297650 +bconv43 baseconv 1930892885265622374044276870708337676283054679224386140053737953615882043569381134303993837045456520856063047650681085219439772289937295606119679527330113425798200499528366612606121904949118540780503011582572413765829037353442053804510263297888686630112839583898430467193615188808253166230639918940163923079913258367053098008008173327297371624183766421877813335411189617019649376072615805990005572079758249229689651653372624609354711132895085329722336426040525879603161827164960280164963826549155566469261174705834914448951779376194003732655331797515490820674887867133338858007686956496864655359146346438455899180907824046602740623937279566625725396576115363574082270342406526226783556135822375085497434833101313279873573516807009956992364962667056138144871066089118413655606360609484287233946958758510470849284132404254082493410759636089433559684148907763897378324494293431521337570825568677336980158347725143065207700294931436564337134040121552210547924978034399816125896806583156081026937672968723 -> 1930892885265622374044276870708337676283054679224386140053737953615882043569381134303993837045456520856063047650681085219439772289937295606119679527330113425798200499528366612606121904949118540780503011582572413765829037353442053804510263297888686630112839583898430467193615188808253166230639918940163923079913258367053098008008173327297371624183766421877813335411189617019649376072615805990005572079758249229689651653372624609354711132895085329722336426040525879603161827164960280164963826549155566469261174705834914448951779376194003732655331797515490820674887867133338858007686956496864655359146346438455899180907824046602740623937279566625725396576115363574082270342406526226783556135822375085497434833101313279873573516807009956992364962667056138144871066089118413655606360609484287233946958758510470849284132404254082493410759636089433559684148907763897378324494293431521337570825568677336980158347725143065207700294931436564337134040121552210547924978034399816125896806583156081026937672968723 +bconv44 baseconv 2128227718880978172629569009101386129143469234047390236985319375081177949255510453146383788406609947830533487946455389647682136675926151876852531056245602176864341646343141309108774297708682259144074848037053716758025297456975761252357335049185823413855793719540456150689763418336345199422245944040220946851227237340366200429484312712081027397321613346477994953512662199783059086828893414729699164757569347048637823566802714179220106095037167923898922319932535318738314133649360497390557153842876264288428047914295018316303728959460861503574522265258336207538910569918423404057814212814078255301175332947024499579836359543804035693201050965026371115670432220956677786149554262014180333503694551658670391204832002197527472206767629703047951711058347082547942544644031172338316258574999017084310088218727010871325879665511714828811142409366445563656896405327456802775618122951317858799233671931686432030388516513809176520437516753761846046491224541379217318649959162716304211059558486737090124874713619 -> 2128227718880978172629569009101386129143469234047390236985319375081177949255510453146383788406609947830533487946455389647682136675926151876852531056245602176864341646343141309108774297708682259144074848037053716758025297456975761252357335049185823413855793719540456150689763418336345199422245944040220946851227237340366200429484312712081027397321613346477994953512662199783059086828893414729699164757569347048637823566802714179220106095037167923898922319932535318738314133649360497390557153842876264288428047914295018316303728959460861503574522265258336207538910569918423404057814212814078255301175332947024499579836359543804035693201050965026371115670432220956677786149554262014180333503694551658670391204832002197527472206767629703047951711058347082547942544644031172338316258574999017084310088218727010871325879665511714828811142409366445563656896405327456802775618122951317858799233671931686432030388516513809176520437516753761846046491224541379217318649959162716304211059558486737090124874713619 +bconv45 baseconv 7112587341013296417883245182232309783033995891092827757735876586944732473748852580345349727993045804248235460727849956179351797880089092025905050220767567285788610972388919790514222434712795678499763686954349499281233857416743630743869400345495572042052411489134144398206084278219131423706940555811702842830805369366275914731128575866358256373239221396704487315057967528991822896730011283375924641204237077417754943121107202767085963141560239532697411010265224271452605423395383338254654603950322214155932723380004506694999620298247780633960338603844429486610040620953645606117414661494286718975579038062506022214247012470633767236546689354833800031601104523742558795104907734575644657628841467033297753882104056251390806528769232910604156190689097743027105720795902968216955803157762556227964539497343869985712107305303563757051687019953021473872487217729507570616444319917712343886700447518225671217138499687269609878420165040533953524324115454492503091456814698467434773089473777616514837129305594 -> 7112587341013296417883245182232309783033995891092827757735876586944732473748852580345349727993045804248235460727849956179351797880089092025905050220767567285788610972388919790514222434712795678499763686954349499281233857416743630743869400345495572042052411489134144398206084278219131423706940555811702842830805369366275914731128575866358256373239221396704487315057967528991822896730011283375924641204237077417754943121107202767085963141560239532697411010265224271452605423395383338254654603950322214155932723380004506694999620298247780633960338603844429486610040620953645606117414661494286718975579038062506022214247012470633767236546689354833800031601104523742558795104907734575644657628841467033297753882104056251390806528769232910604156190689097743027105720795902968216955803157762556227964539497343869985712107305303563757051687019953021473872487217729507570616444319917712343886700447518225671217138499687269609878420165040533953524324115454492503091456814698467434773089473777616514837129305594 +bconv46 baseconv 9699288818276549854335689312945720612571723333931837850529527838873671037566723448610470079396905442950474748706261218079965212657261363655245609034355289244097850206849861185177403434574663556540080597408594579455205712986685487089063400429329730101790849132445713357615860421911863085671131257406207115244013612859267252279732772534348928722883003176038407444582875372461733415683919034177576403950680584882467523210858382654713352234314791425722801777115064170561469572261573844372912528339829198527630890035503396746623001614611640932670232575753384499266601465252231641070361581852054970601407304902021418332566990260912846249837163861932304560797307269825128659595763262962299723570449585845050624429301701413517396256479143720522301033345949704239045155777395853731596108617475273683187458065030875232370157646494259806603125903365610269141807735679317778141172544543397902942704682859135824741836177986154805397512883137015835421200052821416178485135192529026808448820444527873359559175547176 -> 9699288818276549854335689312945720612571723333931837850529527838873671037566723448610470079396905442950474748706261218079965212657261363655245609034355289244097850206849861185177403434574663556540080597408594579455205712986685487089063400429329730101790849132445713357615860421911863085671131257406207115244013612859267252279732772534348928722883003176038407444582875372461733415683919034177576403950680584882467523210858382654713352234314791425722801777115064170561469572261573844372912528339829198527630890035503396746623001614611640932670232575753384499266601465252231641070361581852054970601407304902021418332566990260912846249837163861932304560797307269825128659595763262962299723570449585845050624429301701413517396256479143720522301033345949704239045155777395853731596108617475273683187458065030875232370157646494259806603125903365610269141807735679317778141172544543397902942704682859135824741836177986154805397512883137015835421200052821416178485135192529026808448820444527873359559175547176 +bconv47 baseconv 6012799035139312429408326100257968664231666805057439792483213815042270918792694072622746198116690858047740979869592179482969378755405781085012423013173159696912201318596213081729955668285664859222243423381961343546392744009362817402886453764593862659023853506617447213980074759411478539726305201023070687695279666917686153683068397131632283986621757986801671184822751122332173509257168047679456674846132812446247797046271167539796175037555388918845918920571997379903940944779260648853602433108445980296135729084763891100633805693090404443549368445317362362032070826663170050830091349576633574615281516156191698366157107533728535833879382481125878664850322681467757166471946133948443770671926735438131535304787064914914618089457619620184797550793853420182857316190339257471208275157532556031228171503075040002707917871856288915141013737178161590777415951604123532905781111565862521604155127860595697415897753828827196258455318546805457423115266536992316405693037520374676817264538718440628427782624090 -> 6012799035139312429408326100257968664231666805057439792483213815042270918792694072622746198116690858047740979869592179482969378755405781085012423013173159696912201318596213081729955668285664859222243423381961343546392744009362817402886453764593862659023853506617447213980074759411478539726305201023070687695279666917686153683068397131632283986621757986801671184822751122332173509257168047679456674846132812446247797046271167539796175037555388918845918920571997379903940944779260648853602433108445980296135729084763891100633805693090404443549368445317362362032070826663170050830091349576633574615281516156191698366157107533728535833879382481125878664850322681467757166471946133948443770671926735438131535304787064914914618089457619620184797550793853420182857316190339257471208275157532556031228171503075040002707917871856288915141013737178161590777415951604123532905781111565862521604155127860595697415897753828827196258455318546805457423115266536992316405693037520374676817264538718440628427782624090 +bconv48 baseconv 9919394750026539849552058455142940324804986571394146734628754344884646129540400337188573364384561996629039095484437976838304650267728321324191047492663324697670111224036571949665757517933624370846329296385209317493614452164214622795872352397017525424549137284622743275020996362070081098391439474505221996370196413894684409813360621865922609919658943625701299246634886899150971300063436178595755371976507876544993206828666232702345634907634016774125072429477776468884933618770823018417034257551062282973819554186921879150158146766003769219942048692257272315579679979987502091101699905187309180177277825457017735666405381257212572932433565510486149731214728374524199255191936645406037686369644679402896649555424732277973558272877575566703028017795012846122920442198905343668575803772622886054047408712883224036607929724589831999397971347481661567991667748120359375944349813628143741283558304215254421311864953294659525889872672012252796647940635491318957571904128683274444276904072274816298139561026992 -> 9919394750026539849552058455142940324804986571394146734628754344884646129540400337188573364384561996629039095484437976838304650267728321324191047492663324697670111224036571949665757517933624370846329296385209317493614452164214622795872352397017525424549137284622743275020996362070081098391439474505221996370196413894684409813360621865922609919658943625701299246634886899150971300063436178595755371976507876544993206828666232702345634907634016774125072429477776468884933618770823018417034257551062282973819554186921879150158146766003769219942048692257272315579679979987502091101699905187309180177277825457017735666405381257212572932433565510486149731214728374524199255191936645406037686369644679402896649555424732277973558272877575566703028017795012846122920442198905343668575803772622886054047408712883224036607929724589831999397971347481661567991667748120359375944349813628143741283558304215254421311864953294659525889872672012252796647940635491318957571904128683274444276904072274816298139561026992 +bconv49 baseconv 9233174483737664461625491046802593032578513416662868428994454671378779885631770646941186092718999934888583814715078081648273971810519569902944988673898344036411072326423644291415014771543710084101170197629453857189931052534827770762365497154770603400348185449568970993183249727025554733171076452528668427455303649865923792513669598337391437655324765818931261843079215552927774686787228690905262330190342601372125213353984288927685907074288555016734268380281858164038900625101200147614610331209521799116234489953907220176353809588001367624586415959134731122658518092822318659909563698161843077449455322965542971382450698296201138028978284392955864602626064490594872745888896108166301294814816943809622727265685427875062812097156800905035015577685504710899621905621276607080768286942946472561061238087950967465213808137167802398460211175386983617931863300945063575271565521877968104325881605480106370465224713852826459139171485188400225500972039078132716184835809441358637096071619898150348255381588795 -> 9233174483737664461625491046802593032578513416662868428994454671378779885631770646941186092718999934888583814715078081648273971810519569902944988673898344036411072326423644291415014771543710084101170197629453857189931052534827770762365497154770603400348185449568970993183249727025554733171076452528668427455303649865923792513669598337391437655324765818931261843079215552927774686787228690905262330190342601372125213353984288927685907074288555016734268380281858164038900625101200147614610331209521799116234489953907220176353809588001367624586415959134731122658518092822318659909563698161843077449455322965542971382450698296201138028978284392955864602626064490594872745888896108166301294814816943809622727265685427875062812097156800905035015577685504710899621905621276607080768286942946472561061238087950967465213808137167802398460211175386983617931863300945063575271565521877968104325881605480106370465224713852826459139171485188400225500972039078132716184835809441358637096071619898150348255381588795 +bconv50 baseconv 4773658278267840002596036440176553049013426168298463110992745530786499996857199722504465481275650863282552047289724105114259623114005344649606813472938151621041967905622779312365722730289368336279925000458546320360056506069925427256580562634411935582542300196189152299314961795119325701328593698002218043478211457414754552966763206603095932725768743291305948609920384730358957797020700925464444812450821593661398590529274762767668597215639639084924608296382635924407219898992048052975945795107027548030708406334455622458269822952244015740356221979997678070562061554243501720016988968531585381453053334104779910362463875486237634715139906783301119338089394658517426762218059409611442563091275992906197855105490612045994640670289334486317618559948192751887921347168729185624688493459329011641553734663884742554821014707290494285796089868419253588155541647852437659744082278785414647162099078322033267444285186226158971247217268779735644236987556103812085393444197218249815769366683183205051298829531546 -> 4773658278267840002596036440176553049013426168298463110992745530786499996857199722504465481275650863282552047289724105114259623114005344649606813472938151621041967905622779312365722730289368336279925000458546320360056506069925427256580562634411935582542300196189152299314961795119325701328593698002218043478211457414754552966763206603095932725768743291305948609920384730358957797020700925464444812450821593661398590529274762767668597215639639084924608296382635924407219898992048052975945795107027548030708406334455622458269822952244015740356221979997678070562061554243501720016988968531585381453053334104779910362463875486237634715139906783301119338089394658517426762218059409611442563091275992906197855105490612045994640670289334486317618559948192751887921347168729185624688493459329011641553734663884742554821014707290494285796089868419253588155541647852437659744082278785414647162099078322033267444285186226158971247217268779735644236987556103812085393444197218249815769366683183205051298829531546 +bconv51 baseconv 4094632320924064153761231911482497424314155152945311409551117897660105799751969320171226955014798077982639167608005744221327478580375399026267976689267238211480059795214306669550534361985335416113038520986095059405970306009985490908365755476437328846069538640672353505815812249332294876658407928179340284505072011585167835381010050566490494460274903264966736917232392936579095090524244294501459999891722297108322353817841272816011373661381933022572644403117108688081966160271042655834436305801080916634851382251588543921880768626480132642125936708057518447156537219322320111782473245369234467277066637895823964338340997097539202626954866557695983360175782798393450788228730902161785358425995318732639722818484711563865933227574822771278911983032986071767547298642644476322126039464627551377202504803512892500870402035403985038976381803246692556945361050113256801199120635778734800904433729075919834676133534773946450517427393564388258302574628466258341020331104746426178407338616654459452059342798475 -> 4094632320924064153761231911482497424314155152945311409551117897660105799751969320171226955014798077982639167608005744221327478580375399026267976689267238211480059795214306669550534361985335416113038520986095059405970306009985490908365755476437328846069538640672353505815812249332294876658407928179340284505072011585167835381010050566490494460274903264966736917232392936579095090524244294501459999891722297108322353817841272816011373661381933022572644403117108688081966160271042655834436305801080916634851382251588543921880768626480132642125936708057518447156537219322320111782473245369234467277066637895823964338340997097539202626954866557695983360175782798393450788228730902161785358425995318732639722818484711563865933227574822771278911983032986071767547298642644476322126039464627551377202504803512892500870402035403985038976381803246692556945361050113256801199120635778734800904433729075919834676133534773946450517427393564388258302574628466258341020331104746426178407338616654459452059342798475 +bconv52 baseconv 1195613688712462370161881989925595018995105996850531625209796544182902722193333496655703994623218098757350402402950600588390877213543585813175138154458884174772267583594117191629444294127019377440741892920797253096788840241362167172038198667965230928623364722367646125901761673811034885568702695161278732811884582700694847207660776903749095158752349819697283655239795988638699223941749918908012797892210965773604361822040016295912734277810151708448558789993471291953795386882139051352772553837769661718023417800292552016824846816764941873111114865589826347435137197824596658991275586878913761283282081547885379536437285882792873729874288784602528175738888625608623385170906876256297949136252314631085815621667525299521107807013095240141718850397972742263082543264403546582365503126458148009758981553535042838763563351858626379566066470859529696677757807101362322543604477402978708033954224787673687076159457061279844958619284891322053759905277576341377532876889612956634317541515974021649226322684382 -> 1195613688712462370161881989925595018995105996850531625209796544182902722193333496655703994623218098757350402402950600588390877213543585813175138154458884174772267583594117191629444294127019377440741892920797253096788840241362167172038198667965230928623364722367646125901761673811034885568702695161278732811884582700694847207660776903749095158752349819697283655239795988638699223941749918908012797892210965773604361822040016295912734277810151708448558789993471291953795386882139051352772553837769661718023417800292552016824846816764941873111114865589826347435137197824596658991275586878913761283282081547885379536437285882792873729874288784602528175738888625608623385170906876256297949136252314631085815621667525299521107807013095240141718850397972742263082543264403546582365503126458148009758981553535042838763563351858626379566066470859529696677757807101362322543604477402978708033954224787673687076159457061279844958619284891322053759905277576341377532876889612956634317541515974021649226322684382 +bconv53 baseconv 9499948044070535829617658000073109388317255533160818696004171990892444262466607310445073849981215946633688695059200704326207268272467694691711467087588393758881402434320715744255627690972846993619574537577977178962699161353713899897882183029682903217684523509563381983591114043081050894274344052322317793108904274522259440485781988975321013758944115257129413072546837038124957996751661675596274644497454059997227485645057080907724179993648305437705913134560410868578230840879348358091075170490814100259026828359851846141277765511289021492304068252204856885435121179719724905800150881050023353662023536789236444228860979703993824481841123900294830611488945988856246089733108517317304084609460862729147676217177998497864969056268945139843653602853863265637886328346845623285779260759566732055222069904458152147777699053937960838302815509944344571404628883046719473910600938845106101632722848805019593861914735528570426575802280782817868889233462099542164101168156251956011717993122439249891502735590307 -> 9499948044070535829617658000073109388317255533160818696004171990892444262466607310445073849981215946633688695059200704326207268272467694691711467087588393758881402434320715744255627690972846993619574537577977178962699161353713899897882183029682903217684523509563381983591114043081050894274344052322317793108904274522259440485781988975321013758944115257129413072546837038124957996751661675596274644497454059997227485645057080907724179993648305437705913134560410868578230840879348358091075170490814100259026828359851846141277765511289021492304068252204856885435121179719724905800150881050023353662023536789236444228860979703993824481841123900294830611488945988856246089733108517317304084609460862729147676217177998497864969056268945139843653602853863265637886328346845623285779260759566732055222069904458152147777699053937960838302815509944344571404628883046719473910600938845106101632722848805019593861914735528570426575802280782817868889233462099542164101168156251956011717993122439249891502735590307 +bconv54 baseconv 9681201181288346238161618847971252079317053722777557174860050929517087306003145811583730887554415412269163431310799022759645846508317654822005885690593660193203383584985052675972751012352733288376108146387509156887573116718157199749463765692840989210380774368587807627022401100844443165415781580743816277319667896566395177315449714696435758046861792630882362577222571381967245774608562450349980070290137767329706127528142322516034418205531204936537427350594715389389268666157501423000050981301720365257282545283855204948055125079972651075438323727489171453110884626111787922656372832138247128006763899488284285499432101730775536338063332412034139072744076207749172013795264917873150993264260711793377486271966928067095067225572100261255699461391011000420331725377560660886964853448763697738150442124085830891499994860379939366382720146286282434365772277730713332022886013353980598584107551105313755807966583991388879640960170881288132894265099953913547962938038542484006000610516526113737536843753800 -> 9681201181288346238161618847971252079317053722777557174860050929517087306003145811583730887554415412269163431310799022759645846508317654822005885690593660193203383584985052675972751012352733288376108146387509156887573116718157199749463765692840989210380774368587807627022401100844443165415781580743816277319667896566395177315449714696435758046861792630882362577222571381967245774608562450349980070290137767329706127528142322516034418205531204936537427350594715389389268666157501423000050981301720365257282545283855204948055125079972651075438323727489171453110884626111787922656372832138247128006763899488284285499432101730775536338063332412034139072744076207749172013795264917873150993264260711793377486271966928067095067225572100261255699461391011000420331725377560660886964853448763697738150442124085830891499994860379939366382720146286282434365772277730713332022886013353980598584107551105313755807966583991388879640960170881288132894265099953913547962938038542484006000610516526113737536843753800 +bconv55 baseconv 9131179347186210485354210531777409248283891976203783883553115821608718394283063228562203489420222087084600990598305683322930387205130447096251049481363203196834826757279518719511343992308741248697636433448891267876466457401127568360744155389333217218128820449012892657912424463449376577410301520164080629507138989219074296499522628176569327029008331113882681648558407635554283787639148011707933930752800329014763489669481545570477667563590991337877228940697488891269849643170902977953915538333408880556432346215005831215070180867380833561702241985225082739337224042085880239885734640381830484675976025427641832856929523400894091124961471976444480347814448787528993867409615566713022804642931330884278066080994760159529192295843357999713728956647790190859132479256973735030555572809285144239734673899611474854555418022761308707617796517809089243177699754503820322479457721748975076737681001289558455380655260960564294960096247406484175680073943389491185479014080674905450920168137074522193495576699698 -> 9131179347186210485354210531777409248283891976203783883553115821608718394283063228562203489420222087084600990598305683322930387205130447096251049481363203196834826757279518719511343992308741248697636433448891267876466457401127568360744155389333217218128820449012892657912424463449376577410301520164080629507138989219074296499522628176569327029008331113882681648558407635554283787639148011707933930752800329014763489669481545570477667563590991337877228940697488891269849643170902977953915538333408880556432346215005831215070180867380833561702241985225082739337224042085880239885734640381830484675976025427641832856929523400894091124961471976444480347814448787528993867409615566713022804642931330884278066080994760159529192295843357999713728956647790190859132479256973735030555572809285144239734673899611474854555418022761308707617796517809089243177699754503820322479457721748975076737681001289558455380655260960564294960096247406484175680073943389491185479014080674905450920168137074522193495576699698 +bconv56 baseconv 7698481258094403146365746957977140035675796188881949778279935692808725784247515527819944562646011182663822531793263915434304355340291172618174931130844883140400247300549821476375442490954876902556476720921530658747115171765087488876716545522533746049599568630405953005112902419025791888416044080669819858398123657778169254521282596436578106024316545969926320705196456992531493761155668147188247840593428124249756379938842449859258119623184923042737905971203254863348745747421111929956698767393089978716676780828671351164885913152462462970708833107693224111710452702145778997946491053290885718435918239667278439042874425410167830101967149409121922256716787347830534295885467397602486213807441252894485407823396393272217807341761687939062732449152739912158220633573465017341816078943803097741526255278101589441598502485919872153523958049458445978757638395812408691442581519625719785599517630840215791101031430981383362964880463874948001263987606863863271828983508557349586533621931953310262239703681564 -> 7698481258094403146365746957977140035675796188881949778279935692808725784247515527819944562646011182663822531793263915434304355340291172618174931130844883140400247300549821476375442490954876902556476720921530658747115171765087488876716545522533746049599568630405953005112902419025791888416044080669819858398123657778169254521282596436578106024316545969926320705196456992531493761155668147188247840593428124249756379938842449859258119623184923042737905971203254863348745747421111929956698767393089978716676780828671351164885913152462462970708833107693224111710452702145778997946491053290885718435918239667278439042874425410167830101967149409121922256716787347830534295885467397602486213807441252894485407823396393272217807341761687939062732449152739912158220633573465017341816078943803097741526255278101589441598502485919872153523958049458445978757638395812408691442581519625719785599517630840215791101031430981383362964880463874948001263987606863863271828983508557349586533621931953310262239703681564 +bconv57 baseconv 933060065234974016527711181504861388575102533129269785690302853498231817991947134292360950952101856967471244204652651492419507477989654620300897029910053158332011692601890477477147945347999269327709901969327382754998327046975300678322909722108001744075925483360331204154845618260578492569073508334779352167710947459548176844365443214086024243662366377809095464958025600961255772796769885300359015274605474487418721963066379476080375768055363700277522433801169869102150019595086994654926696439957345818046850460716296421098186533879009817972807294964864576668139398923125135995382958840548745127688451323438746558538934566101891264719832906741260833070035253803704214869788019686954032417776112581957940384236798658123199892655171797413164797100216826009596975610428188835267699359831720631410631897874655923509768303338960725077826723216786174737775813075634307466711571597587069966729884533501458825498058239488183915990645833750784838766328587800878774469119447579906874342772359035662967114904022 -> 933060065234974016527711181504861388575102533129269785690302853498231817991947134292360950952101856967471244204652651492419507477989654620300897029910053158332011692601890477477147945347999269327709901969327382754998327046975300678322909722108001744075925483360331204154845618260578492569073508334779352167710947459548176844365443214086024243662366377809095464958025600961255772796769885300359015274605474487418721963066379476080375768055363700277522433801169869102150019595086994654926696439957345818046850460716296421098186533879009817972807294964864576668139398923125135995382958840548745127688451323438746558538934566101891264719832906741260833070035253803704214869788019686954032417776112581957940384236798658123199892655171797413164797100216826009596975610428188835267699359831720631410631897874655923509768303338960725077826723216786174737775813075634307466711571597587069966729884533501458825498058239488183915990645833750784838766328587800878774469119447579906874342772359035662967114904022 +bconv58 baseconv 8038883002615703704817711911862573631598184532350530435306304742662761818506174740863161107218710591248429474505869142723362424325841608986479857960340812641468931707190856706113567181455663070048287958372239286426769745993344743936462361053162189475316360905577571414784434483605897269253415951627848309488238434241192539532390023707334930322340000989678795699670766612923333981370826878119568603663472145271623717616272357589311783113717275449073067014302505545212079840411851799030366865310043311737018881443143136533978313467111615432603601780757592400884052464821716864423403504520457105469054108324607400721053286538855433939074319618679512117954764457949331315493994536161026129900444056136076609980797546548783741551076295788967514999946510347511692235187508755164405085762930985940197444382124442591154480251201633180499607295170306628565018408429501895249294819056998450607556849233313831723351853975510008950914639767759938908141988175121511842989185772928894936186997526905376566482897707 -> 8038883002615703704817711911862573631598184532350530435306304742662761818506174740863161107218710591248429474505869142723362424325841608986479857960340812641468931707190856706113567181455663070048287958372239286426769745993344743936462361053162189475316360905577571414784434483605897269253415951627848309488238434241192539532390023707334930322340000989678795699670766612923333981370826878119568603663472145271623717616272357589311783113717275449073067014302505545212079840411851799030366865310043311737018881443143136533978313467111615432603601780757592400884052464821716864423403504520457105469054108324607400721053286538855433939074319618679512117954764457949331315493994536161026129900444056136076609980797546548783741551076295788967514999946510347511692235187508755164405085762930985940197444382124442591154480251201633180499607295170306628565018408429501895249294819056998450607556849233313831723351853975510008950914639767759938908141988175121511842989185772928894936186997526905376566482897707 +bconv59 baseconv 3477288854142490731453308883604363698829751766397042638356876850253912557247338116551870168124821056569996127469054311240879102450555238300980462038688068892262081046868630684935628207580363505258992064419769627794897173468730321524808387787706212803483062494226962378618607525039870400474223230921014856338958898766196395346023554116745162253468600784948922588126784720086522242771739618218637975556141323164020918978810455895710128282250206188167283189016982398737778938951187522454071794866807921318653478181070731398786350212822997212049193363719826518933973592933142062520193167778907208306443678518305032512335600961537825398303714858137969205446132451238421168442970087648162807376073119731016520674014003957964377493704707532556500892902334141487232605571926679460386872574429475589785505829312766948386930506654715547070137679370245359252654594742352109687646797295779853417079877636193674529230294434802044049588573118533569908762506547935107248958418026330435976254859127497135719090406579 -> 3477288854142490731453308883604363698829751766397042638356876850253912557247338116551870168124821056569996127469054311240879102450555238300980462038688068892262081046868630684935628207580363505258992064419769627794897173468730321524808387787706212803483062494226962378618607525039870400474223230921014856338958898766196395346023554116745162253468600784948922588126784720086522242771739618218637975556141323164020918978810455895710128282250206188167283189016982398737778938951187522454071794866807921318653478181070731398786350212822997212049193363719826518933973592933142062520193167778907208306443678518305032512335600961537825398303714858137969205446132451238421168442970087648162807376073119731016520674014003957964377493704707532556500892902334141487232605571926679460386872574429475589785505829312766948386930506654715547070137679370245359252654594742352109687646797295779853417079877636193674529230294434802044049588573118533569908762506547935107248958418026330435976254859127497135719090406579 +bconv60 baseconv 2221677747105253129991515895693385979724569432871380145709909530718311585737091713910399124294042457324430994460227074311444159889978483406629658751979986239680446734362375834578888485942564923457487781596423838203566853720781873224044052672664400055133298055288707561289476262511234729770857032076646438500888728322780583472810650158149544948348663360428127471726298380951465255539111140213958366265212137414548632842795281686274550071712160716669612293857952305282110342158240658908386925452263475209078348983063626076468083029240178143711647154226024682823666302924167928636391856500834843184981831601237807608871142898575842709404694094185754791961333009838578605964109011402622847017624478134015740283536363293627429540669280077722066831975856915393445006214492479475917786673418444578474035460021619978830224347366734838082892207246779092722149983149009420076091239392491088817325961950998424399462798695556389318078759893647649874540162041951424428718699396905706394685347502799434450024607265 -> 2221677747105253129991515895693385979724569432871380145709909530718311585737091713910399124294042457324430994460227074311444159889978483406629658751979986239680446734362375834578888485942564923457487781596423838203566853720781873224044052672664400055133298055288707561289476262511234729770857032076646438500888728322780583472810650158149544948348663360428127471726298380951465255539111140213958366265212137414548632842795281686274550071712160716669612293857952305282110342158240658908386925452263475209078348983063626076468083029240178143711647154226024682823666302924167928636391856500834843184981831601237807608871142898575842709404694094185754791961333009838578605964109011402622847017624478134015740283536363293627429540669280077722066831975856915393445006214492479475917786673418444578474035460021619978830224347366734838082892207246779092722149983149009420076091239392491088817325961950998424399462798695556389318078759893647649874540162041951424428718699396905706394685347502799434450024607265 +bconv61 baseconv 6446426203289022446944067871143037197618879166339874942086353847795290392527959325029947698985308278846383220354110601969138538949515123246333393559033666825374012551874900736878906311861971570062529195539956496704084300526582979150268755442065197947576476977166189713910679324122537049102391846344751779647915441175433890634271937654404329151036204407030790779486345967708651224904900903129117720763070841983481288288520372542887040574173556498319598074362332329040146022921765486281866963787213166610242675725213895679450714775512693266280058498003067425875076428907692828653495669685206937799319736371497416359037957424730850136602011598552974929360355776735376606974424054225673374202545263533459147680029943487405708869153706759472899551787354983815693536947175964416495988451139846884463710485969246475516974062004682822653887489507084088674228167842611112165393235719739369051338188836762977960293914749720683073799488793694630490483906002952032073744224976302710045176228512962355488343205725 -> 6446426203289022446944067871143037197618879166339874942086353847795290392527959325029947698985308278846383220354110601969138538949515123246333393559033666825374012551874900736878906311861971570062529195539956496704084300526582979150268755442065197947576476977166189713910679324122537049102391846344751779647915441175433890634271937654404329151036204407030790779486345967708651224904900903129117720763070841983481288288520372542887040574173556498319598074362332329040146022921765486281866963787213166610242675725213895679450714775512693266280058498003067425875076428907692828653495669685206937799319736371497416359037957424730850136602011598552974929360355776735376606974424054225673374202545263533459147680029943487405708869153706759472899551787354983815693536947175964416495988451139846884463710485969246475516974062004682822653887489507084088674228167842611112165393235719739369051338188836762977960293914749720683073799488793694630490483906002952032073744224976302710045176228512962355488343205725 +bconv62 baseconv 4058163341381129988163925181756534464821836830006112445399258125431199638977501538393833228651413348457942321559851603718519535685103294979426663988236497444112625420266257454931961604662935390106351137623206154017299678697090098122349589355298594817912461376487326627468956250288327115841039050839112583124161440117194561258184595566402806102882764334701154619759831535664108595086632091264110374173206374670920920753739197576276401902436609025037848621163010251140662292582615590273551834209681778927596896029873019754707570866120017453538393386512697720377539679664306184483075656672585127596958196904387044715504671353729194771737085689602383400560094063808145252520880489766128458765096981033662005102471346162930149407010064628165779721236051368024416609686846658331125401250706356927765990923632248406753711318575521543531367744508193411411852270736842910798723297818618598991061140777380210327008583967028167436981722517506960790579392485398385850481559309096608615138313611697766282570836002 -> 4058163341381129988163925181756534464821836830006112445399258125431199638977501538393833228651413348457942321559851603718519535685103294979426663988236497444112625420266257454931961604662935390106351137623206154017299678697090098122349589355298594817912461376487326627468956250288327115841039050839112583124161440117194561258184595566402806102882764334701154619759831535664108595086632091264110374173206374670920920753739197576276401902436609025037848621163010251140662292582615590273551834209681778927596896029873019754707570866120017453538393386512697720377539679664306184483075656672585127596958196904387044715504671353729194771737085689602383400560094063808145252520880489766128458765096981033662005102471346162930149407010064628165779721236051368024416609686846658331125401250706356927765990923632248406753711318575521543531367744508193411411852270736842910798723297818618598991061140777380210327008583967028167436981722517506960790579392485398385850481559309096608615138313611697766282570836002 +bconv63 baseconv 8406950892755523931376660654037202098146387857439041752733701540164535058871001088360557390059591304703327011597655300786583404802671361628304338238650834015763131261435738978120016074160349801814322881813215090602918833106312246883246662968423408218102590560005828415774667214358058816218908165140407741028808386573410234772695087736341345800546853400051852565435946321779856248773388131084478853534737063051919742708670239574091146744341484353507359591305645142329283716514049206525995125513678543179711673298132835805657558187822034894673063830270667077717144507131374867555857497241487349223175635123368379509733451513266131470778295874125292318184104285420415290106787149190632979426143432938539130082705142904692619987384214682396023421584099098106616997004420242583521086733427222102959507383836702741247378945251155207199029372749396016571483287604421094881805186053193055926290766231497649774874142816117601569504204785571109899954674170905188244667375034493358961286678829349195105698569686 -> 8406950892755523931376660654037202098146387857439041752733701540164535058871001088360557390059591304703327011597655300786583404802671361628304338238650834015763131261435738978120016074160349801814322881813215090602918833106312246883246662968423408218102590560005828415774667214358058816218908165140407741028808386573410234772695087736341345800546853400051852565435946321779856248773388131084478853534737063051919742708670239574091146744341484353507359591305645142329283716514049206525995125513678543179711673298132835805657558187822034894673063830270667077717144507131374867555857497241487349223175635123368379509733451513266131470778295874125292318184104285420415290106787149190632979426143432938539130082705142904692619987384214682396023421584099098106616997004420242583521086733427222102959507383836702741247378945251155207199029372749396016571483287604421094881805186053193055926290766231497649774874142816117601569504204785571109899954674170905188244667375034493358961286678829349195105698569686 +bconv64 baseconv 5647688966100354364057696188968969015429751356816251620994668637140555851871917355534030523702654179619022948515953760602790154851357593370075652536062282439891965113395509925572338068884604498514271028288558428358683336188255932484378244108914598258026642950898724806096609062135322993895216184994351574543383451289058826354140182936630814334378315448156164414366393500127371296356058022439297207590079530267863802647498160704827735225701131352098900156246616920726629420728242144555825846231688748321741255901840625653736252617643643181798802568589266059683380007034823111463828880641316648151016898222098440888797985538367105598165917764674813454904728893658758599621022207782389612144160989408564639394476394347146791391790897587340385813455563974153162604345037779011378663519524098502262812334457833225038976924794624162776585149230244765098191075549991370014046641083879817819075205118463678334114935856820727294228985903927335458758516518101235510006525099111744003362479932882328513730055697 -> 5647688966100354364057696188968969015429751356816251620994668637140555851871917355534030523702654179619022948515953760602790154851357593370075652536062282439891965113395509925572338068884604498514271028288558428358683336188255932484378244108914598258026642950898724806096609062135322993895216184994351574543383451289058826354140182936630814334378315448156164414366393500127371296356058022439297207590079530267863802647498160704827735225701131352098900156246616920726629420728242144555825846231688748321741255901840625653736252617643643181798802568589266059683380007034823111463828880641316648151016898222098440888797985538367105598165917764674813454904728893658758599621022207782389612144160989408564639394476394347146791391790897587340385813455563974153162604345037779011378663519524098502262812334457833225038976924794624162776585149230244765098191075549991370014046641083879817819075205118463678334114935856820727294228985903927335458758516518101235510006525099111744003362479932882328513730055697 +bconv65 baseconv 4303643024126988377813422678008252137074227312607602958902841494279719418066940860294572640212642986341810157508424117525175727568781972411091870791707959150235359888813728343454667077791290091906713945440123590859266784922331439886087241699669854876593854281538733124785668279591403336336568302343816823470551045529738293770563081676331864762766572662727041867148094538344365432675856819861522023038051110627371108753701062994789389071296990002878768656480929104940365255825579067979693997169155096197312633312996464150383625288961548833164228279244295203251828677253408077267538292334039365205809241284529420311083003350936517276149896533542045491473868435883710276935407588510712498950819735847398823054618846064349494679600895539980821742622931900910741469612604112826527076047997381271355199447570295695672651263700799426192699738726013352555384317577033163225594001365982347480710043230474742810217310250516965581149309286090229155832333270873077496862544454456673571132901197127905894820941626 -> 4303643024126988377813422678008252137074227312607602958902841494279719418066940860294572640212642986341810157508424117525175727568781972411091870791707959150235359888813728343454667077791290091906713945440123590859266784922331439886087241699669854876593854281538733124785668279591403336336568302343816823470551045529738293770563081676331864762766572662727041867148094538344365432675856819861522023038051110627371108753701062994789389071296990002878768656480929104940365255825579067979693997169155096197312633312996464150383625288961548833164228279244295203251828677253408077267538292334039365205809241284529420311083003350936517276149896533542045491473868435883710276935407588510712498950819735847398823054618846064349494679600895539980821742622931900910741469612604112826527076047997381271355199447570295695672651263700799426192699738726013352555384317577033163225594001365982347480710043230474742810217310250516965581149309286090229155832333270873077496862544454456673571132901197127905894820941626 +bconv66 baseconv 5335835484698834876944387633595737636036504202165508279086455820006198045442127520009100419147410481418310384188548200286998275148827760537031777287560961708745676522788474293906099128836292586856951761116483866453754578883428575421057966567029785713601122990542298812305298897558185958135958320187888750093995366388595619625472843981361516921230016506601835539514945240154597661038826270216496857084517022214141028223827296134286120266183100679765421006576219583917546731022060419457554414283660988293753592239015584013028292057752126673644043989399421525099114796194016110250758991374099908959713418677105003232295743420736405802941991296511941478174814055235413811644378166155793547136371895373947683208618280871108974693026337274536234402449637640948433348098220230834897129888411670938495475558490445196033887817289608928795985461110126005249676416480561282969944368908875995104981987298616923906885791503787489529250036531239020442656203742596827949760572879176388068999824193353175642440697264 -> 5335835484698834876944387633595737636036504202165508279086455820006198045442127520009100419147410481418310384188548200286998275148827760537031777287560961708745676522788474293906099128836292586856951761116483866453754578883428575421057966567029785713601122990542298812305298897558185958135958320187888750093995366388595619625472843981361516921230016506601835539514945240154597661038826270216496857084517022214141028223827296134286120266183100679765421006576219583917546731022060419457554414283660988293753592239015584013028292057752126673644043989399421525099114796194016110250758991374099908959713418677105003232295743420736405802941991296511941478174814055235413811644378166155793547136371895373947683208618280871108974693026337274536234402449637640948433348098220230834897129888411670938495475558490445196033887817289608928795985461110126005249676416480561282969944368908875995104981987298616923906885791503787489529250036531239020442656203742596827949760572879176388068999824193353175642440697264 +bconv67 baseconv 9129091747928019647658521399224576461375165290016306906223165566696625834526558333128057952933598410200090827763961361401310443343280365281373936236181125564771699359283222203311361818120518438365620016831594374224828701204091727510634424186798327991718205655447076322053511859816507583554196675368297852454036158180308979651709531932084491488415726926114180975339690954496597653950332090055438059501708751596192253547393886974114215674992857539499149127327172648622584808139655914533962860987370044411883932825928665967576246707952150433909775789244033111097886841015510913489356649504764493139660393909282867438500006930458566961479098010943853253658203508378170139917913005810228284199016726859325182660302051384205209976440472471615133380118443572994088979336213339432663549695022940786447588164053915597304534366557052109427352734925488245976215375939413713456547525640893432265002623220428365126968841314760740005829803839414722416534532318087228727968752113208444581791125880461493882422284019 -> 9129091747928019647658521399224576461375165290016306906223165566696625834526558333128057952933598410200090827763961361401310443343280365281373936236181125564771699359283222203311361818120518438365620016831594374224828701204091727510634424186798327991718205655447076322053511859816507583554196675368297852454036158180308979651709531932084491488415726926114180975339690954496597653950332090055438059501708751596192253547393886974114215674992857539499149127327172648622584808139655914533962860987370044411883932825928665967576246707952150433909775789244033111097886841015510913489356649504764493139660393909282867438500006930458566961479098010943853253658203508378170139917913005810228284199016726859325182660302051384205209976440472471615133380118443572994088979336213339432663549695022940786447588164053915597304534366557052109427352734925488245976215375939413713456547525640893432265002623220428365126968841314760740005829803839414722416534532318087228727968752113208444581791125880461493882422284019 +bconv68 baseconv 6900268356619689735328316924037308197731823978664151646536913448395060888600072144428907591584296316164895762596929158159223240873686583623459715465718416013955231933759988468600214280395215701151779881476822654331428402787838329980501266605629634666039232321654838070390904813276126247705089025960363730017795100421116278990168639641134931401043909104084654864047361458859633461233860093552239801820545348446366618513463235589670924359397456295125078269360780719667676367268772999769827119117523247254472958893414211427072099794161965964526565084372345182751970743069306765132666382655996709403103274830414754150703389454121766348106616371189856004868052566745344982606334278977139056432550805384684663957960585932902801839700120633871029140651911192017752102812898014750252764192143839943538114902737292849329973983868810816104335037222555349216487751849955516160631961554662024099406925850956972723049949156408781107316793143780496034007136738803366213062990156186687113354154240137096750043483483 -> 6900268356619689735328316924037308197731823978664151646536913448395060888600072144428907591584296316164895762596929158159223240873686583623459715465718416013955231933759988468600214280395215701151779881476822654331428402787838329980501266605629634666039232321654838070390904813276126247705089025960363730017795100421116278990168639641134931401043909104084654864047361458859633461233860093552239801820545348446366618513463235589670924359397456295125078269360780719667676367268772999769827119117523247254472958893414211427072099794161965964526565084372345182751970743069306765132666382655996709403103274830414754150703389454121766348106616371189856004868052566745344982606334278977139056432550805384684663957960585932902801839700120633871029140651911192017752102812898014750252764192143839943538114902737292849329973983868810816104335037222555349216487751849955516160631961554662024099406925850956972723049949156408781107316793143780496034007136738803366213062990156186687113354154240137096750043483483 +bconv69 baseconv 5902317478033285052639969958426443415331534100963298572917677485137767710777645791510067987040318815704002046102380559056499576069140225130856023710928274645788720336542561688179656835504067151964603553167820369875037901743403666333946356374149492654740989372381420656107998784874556101744289227529408280165171709363403901488493142660261651414890130272196299763703929030105182053095081485999142807673262280903020694356961712060482350227621125449488408596786220657518228358026972909057360682537642459428945199014596118227915678507873596275380578418781669067343652514458813143705051154895151314182485736623761416158306575176089589598309703147974223695592008076609875305046246341267219118112039891263647272358195902229726581191582355438917227138004383536527416530446888114334055621437548137537151617105080988069350154742754929628014882555546806889633775763716968380233499331929606549710246193613316709215506465990577298515265976613698771776843553680811656116953046619938220006356565765286924768574974365 -> 5902317478033285052639969958426443415331534100963298572917677485137767710777645791510067987040318815704002046102380559056499576069140225130856023710928274645788720336542561688179656835504067151964603553167820369875037901743403666333946356374149492654740989372381420656107998784874556101744289227529408280165171709363403901488493142660261651414890130272196299763703929030105182053095081485999142807673262280903020694356961712060482350227621125449488408596786220657518228358026972909057360682537642459428945199014596118227915678507873596275380578418781669067343652514458813143705051154895151314182485736623761416158306575176089589598309703147974223695592008076609875305046246341267219118112039891263647272358195902229726581191582355438917227138004383536527416530446888114334055621437548137537151617105080988069350154742754929628014882555546806889633775763716968380233499331929606549710246193613316709215506465990577298515265976613698771776843553680811656116953046619938220006356565765286924768574974365 +bconv70 baseconv 7618612588375161987973986123831447508619296856838465164293533739966823894018368729887300038633380083450627587448574134028751880065875262338564382018635166978406432591101743138739499298388611245974265417432879358052242826168409457912513107110950186720266321682523165985361471604318174445688405655205672649458716573299066311194975013589385530855390287294557039673142795989514335820324636631809173139755465221217477350803483231931418787491152967767757274597349476209505357303671510024719654094172114279799325194009355861115285435663306073203048885374201647859066080783247123888390983467494174600931975914093392656394217072436589498313016735514157722284236985627200904536095289967273299885219540575231309698221759603730404909751845431289018037071119511136610349966122938279522557290179469954193393045541041751948180641198956129228604171009531495649354104157212998085753206544094978165257504484578807276864804766426616551743121878029939397287482059538202220979362777420766635472700606552654691456630944882 -> 7618612588375161987973986123831447508619296856838465164293533739966823894018368729887300038633380083450627587448574134028751880065875262338564382018635166978406432591101743138739499298388611245974265417432879358052242826168409457912513107110950186720266321682523165985361471604318174445688405655205672649458716573299066311194975013589385530855390287294557039673142795989514335820324636631809173139755465221217477350803483231931418787491152967767757274597349476209505357303671510024719654094172114279799325194009355861115285435663306073203048885374201647859066080783247123888390983467494174600931975914093392656394217072436589498313016735514157722284236985627200904536095289967273299885219540575231309698221759603730404909751845431289018037071119511136610349966122938279522557290179469954193393045541041751948180641198956129228604171009531495649354104157212998085753206544094978165257504484578807276864804766426616551743121878029939397287482059538202220979362777420766635472700606552654691456630944882 +bconv71 baseconv 7274806580397344519284063172873246281828496073512420391960927384453048993171430811294852993953133663708264940676182576330989070389032188416756346293035717226172734540992730526151308370760779998487899686427975365105921621973758809647457269569506859547747806306991297068405274539447559239528419759016003913683231595280778096964234842143311379517005828368761680253350331820375653177170414943240127688715672454870195944166222433584575825723532119850409069952806340772013421198619665534555202624391346774809212468650895463599943403825940487774964329686020489685248597721079522907711459321744866816990610954240800102338348668095339816266447245172628383539174211561658298581030048802729109320621346110202491421791757970057077622991253600555741918519281783344059958489634830679464823307368001023379421864430160158082185304493791500244706870083457381611799110216505162039835249630972331472319205143569296727787128312968152640568396491580930348551130999142233580349309433232935446943355973407107156214224440615 -> 7274806580397344519284063172873246281828496073512420391960927384453048993171430811294852993953133663708264940676182576330989070389032188416756346293035717226172734540992730526151308370760779998487899686427975365105921621973758809647457269569506859547747806306991297068405274539447559239528419759016003913683231595280778096964234842143311379517005828368761680253350331820375653177170414943240127688715672454870195944166222433584575825723532119850409069952806340772013421198619665534555202624391346774809212468650895463599943403825940487774964329686020489685248597721079522907711459321744866816990610954240800102338348668095339816266447245172628383539174211561658298581030048802729109320621346110202491421791757970057077622991253600555741918519281783344059958489634830679464823307368001023379421864430160158082185304493791500244706870083457381611799110216505162039835249630972331472319205143569296727787128312968152640568396491580930348551130999142233580349309433232935446943355973407107156214224440615 +bconv72 baseconv 6130948253975489346677774988944106163747895783265816819009141290747852451565430157070458633568418091799100581240038365775110987148264812155911759707749008431645333271204025012839981017225764941361557471531893601564045350396896756840122816069474057770363495623100741920342319643357236464606424507006367902011893287733914920442908648126115412153422186144251960891357139215215592026327970026723175114913467734899145209542128404188980472550163684555903818702210116890758734639483837538831670270775867412845106430716975436568801904268966209479051378549439232083487587240656706323144565528743266161960719120375800051306298871290207293418017005955479866176336985731985283764079487364011713883768219165196913353154123285520395957189537840594148405201019435705205048585761314045517222391010397717138713678291199379489644406023369790871408489799126166800211249280667364400757052372503935756443048605432599878481650018018036096762090966416485795787543935549556092000259556169563879061236461507079130681270625925 -> 6130948253975489346677774988944106163747895783265816819009141290747852451565430157070458633568418091799100581240038365775110987148264812155911759707749008431645333271204025012839981017225764941361557471531893601564045350396896756840122816069474057770363495623100741920342319643357236464606424507006367902011893287733914920442908648126115412153422186144251960891357139215215592026327970026723175114913467734899145209542128404188980472550163684555903818702210116890758734639483837538831670270775867412845106430716975436568801904268966209479051378549439232083487587240656706323144565528743266161960719120375800051306298871290207293418017005955479866176336985731985283764079487364011713883768219165196913353154123285520395957189537840594148405201019435705205048585761314045517222391010397717138713678291199379489644406023369790871408489799126166800211249280667364400757052372503935756443048605432599878481650018018036096762090966416485795787543935549556092000259556169563879061236461507079130681270625925 +bconv73 baseconv 2678958050814855438011980110924244323210902342360468724311522260010738198181483026149998432356805208963963777995160925906539233063189268083826650111799451459581886658672068280964914964393628207391282082504655786637944928288796248087211811294173843458515796607606617768871561148449560208060792117386919551441709757668050534993235222494796280077717812390569608054078408592328262644394123921392451017829069514887231300312722917816057215249670096512382379565025509529794789542178756123968570011478858940154429527782037622132071463012809778679141237394162761585003270807195379677938890610594104065381176396282342993743761091890465767646745423865945246575020162172630639737161569848620243918182614571976940777945456694167437277678256741474766859741794654992638619448675100386839533693034646941003248458395060584905946437012088751694250783884538695072973473131512937858343940713533300864618124792139624682150515770784592009091045409633071683675848987325405286883483190515222978186952507953251192484870361219 -> 2678958050814855438011980110924244323210902342360468724311522260010738198181483026149998432356805208963963777995160925906539233063189268083826650111799451459581886658672068280964914964393628207391282082504655786637944928288796248087211811294173843458515796607606617768871561148449560208060792117386919551441709757668050534993235222494796280077717812390569608054078408592328262644394123921392451017829069514887231300312722917816057215249670096512382379565025509529794789542178756123968570011478858940154429527782037622132071463012809778679141237394162761585003270807195379677938890610594104065381176396282342993743761091890465767646745423865945246575020162172630639737161569848620243918182614571976940777945456694167437277678256741474766859741794654992638619448675100386839533693034646941003248458395060584905946437012088751694250783884538695072973473131512937858343940713533300864618124792139624682150515770784592009091045409633071683675848987325405286883483190515222978186952507953251192484870361219 +bconv74 baseconv 1433604913199497674078083474914984329856632815461977485808964290112742699243842118454632257768731064903980996844332397764881040042954540441183450066462705825315928638236440164547779152816344541552057173362160377239921110200948087717995344001956921723233249486869251158297270585414250065333563201135551477824777637564569500840812856514394406672140924513640570751884329574238314876095634048514675248989746921524201575075133617230827469481393704689216637201395892468685969520264008315836936284604180171762514187252148538883776176472924345179343865383884827486803317221574139524252865998797499402116636730467808567569817656360593510938642326360068969637589320557624621985202839567286526486926131587594999476321652210488347596240536648966259299861976821583032299397323373928356009457406421856858993230214235711413831059296448751018420030096070032872351464883917693967225907526345459366982173594073075347012260963163369355523277181104723236080617131840646102841251455769256280107677494490168666994323130447 -> 1433604913199497674078083474914984329856632815461977485808964290112742699243842118454632257768731064903980996844332397764881040042954540441183450066462705825315928638236440164547779152816344541552057173362160377239921110200948087717995344001956921723233249486869251158297270585414250065333563201135551477824777637564569500840812856514394406672140924513640570751884329574238314876095634048514675248989746921524201575075133617230827469481393704689216637201395892468685969520264008315836936284604180171762514187252148538883776176472924345179343865383884827486803317221574139524252865998797499402116636730467808567569817656360593510938642326360068969637589320557624621985202839567286526486926131587594999476321652210488347596240536648966259299861976821583032299397323373928356009457406421856858993230214235711413831059296448751018420030096070032872351464883917693967225907526345459366982173594073075347012260963163369355523277181104723236080617131840646102841251455769256280107677494490168666994323130447 +bconv75 baseconv 9509502087439293521915245914556012667120859453429588799101618722731573819091360650939844804078650572207481579114368041954962927591690413151539514339827409812517143865418129068157137548141538425093778101236468717678225278052294762257694619178735877449349242687058786086953658133226326630635836416906903445634157790895758720446578504578281952712086992016430676892265798993866494945592007642621955012311340761182040069681255863624421559440343018048806657197993910559458637272199081905616558770409596261493882619719522169737246413582412373468772343196102446759619161641353907132443320222236571544065118743662352967211727156497327231828204853316233291931245121981261002714034945910737026280302630694548036668140781375387922334129759545246568883986651913877871123446161111529630342458791066259563697797046846323689489622058506526027808173899921993177412154475515284590741287550290180104689965294436736202097880113113031790963944060391715754049096598243319655925264719458590524909063365293788615391600549199 -> 9509502087439293521915245914556012667120859453429588799101618722731573819091360650939844804078650572207481579114368041954962927591690413151539514339827409812517143865418129068157137548141538425093778101236468717678225278052294762257694619178735877449349242687058786086953658133226326630635836416906903445634157790895758720446578504578281952712086992016430676892265798993866494945592007642621955012311340761182040069681255863624421559440343018048806657197993910559458637272199081905616558770409596261493882619719522169737246413582412373468772343196102446759619161641353907132443320222236571544065118743662352967211727156497327231828204853316233291931245121981261002714034945910737026280302630694548036668140781375387922334129759545246568883986651913877871123446161111529630342458791066259563697797046846323689489622058506526027808173899921993177412154475515284590741287550290180104689965294436736202097880113113031790963944060391715754049096598243319655925264719458590524909063365293788615391600549199 +bconv76 baseconv 4067710689537320871849232028596019890094124528252777462007885299997247441633037514703726893344971731681036853177610970476237991686949525947759101458523337748744105111180336091024763227724041247966098511119921602883212159799916917673257371767804630928878629119716105307837083027827323519419479115170000208740771251424259282440603148004928318427343722466224467840437081495725842063664315946601338872383524986637145038835522730902737295885437161564775084225897608602355703430068054066888671109737692968558105215791951062838049130090345226160565888843510861559829559406688920922633386414214964809977393093311710710293305610560393766382970580823805751664973722002572513997506768317341907969803015335670841722249449604352187087311038724485915587222121563902141070629530397726046741316132604372111408172705209464331334487033647061504991750599409096060547584712215514566838414944330535512232821626204005290769233866562631963708531145880788234634868318151778571100035628380114530308836936226539602390045869124 -> 4067710689537320871849232028596019890094124528252777462007885299997247441633037514703726893344971731681036853177610970476237991686949525947759101458523337748744105111180336091024763227724041247966098511119921602883212159799916917673257371767804630928878629119716105307837083027827323519419479115170000208740771251424259282440603148004928318427343722466224467840437081495725842063664315946601338872383524986637145038835522730902737295885437161564775084225897608602355703430068054066888671109737692968558105215791951062838049130090345226160565888843510861559829559406688920922633386414214964809977393093311710710293305610560393766382970580823805751664973722002572513997506768317341907969803015335670841722249449604352187087311038724485915587222121563902141070629530397726046741316132604372111408172705209464331334487033647061504991750599409096060547584712215514566838414944330535512232821626204005290769233866562631963708531145880788234634868318151778571100035628380114530308836936226539602390045869124 +bconv77 baseconv 3811485366282181991185449609992379835364068910423038084123752549777775495328423022325496354002520125696510063848482205363898048203808352020069352074587796055595132952929486435926665508307191835077206504562365950478641345354404437988748646831254219152328931803561266682295291800994360062160106397654616189431899798197406883807407141275487819300776299215842458595160943031988530907299832371804923983767347515169199263892792934317357299020622216670200593430872334594094812241832634977075619235914127609964096250827939011169465409846825620733974974023090673181994743508948408435450466271071244766160592324527343693663528963823928584931432038490894738677809422764863550247297419446724028390823312956208154768241192636827842253967661698183139989167982144197331546467495827674490051196364311889090339091110789259946267136203559849863668483546801715109310548678105351252184290598725357432253067982366711587217519182604721349738901804566211889856255557444967049226171078141778124247455292456053215501302298179 -> 3811485366282181991185449609992379835364068910423038084123752549777775495328423022325496354002520125696510063848482205363898048203808352020069352074587796055595132952929486435926665508307191835077206504562365950478641345354404437988748646831254219152328931803561266682295291800994360062160106397654616189431899798197406883807407141275487819300776299215842458595160943031988530907299832371804923983767347515169199263892792934317357299020622216670200593430872334594094812241832634977075619235914127609964096250827939011169465409846825620733974974023090673181994743508948408435450466271071244766160592324527343693663528963823928584931432038490894738677809422764863550247297419446724028390823312956208154768241192636827842253967661698183139989167982144197331546467495827674490051196364311889090339091110789259946267136203559849863668483546801715109310548678105351252184290598725357432253067982366711587217519182604721349738901804566211889856255557444967049226171078141778124247455292456053215501302298179 +bconv78 baseconv 1990006068381464682049507550264302037762060389144914435155032181564512582025891607823250149058568412193385329414153759137054000955433528910483683140843695237118579512718408541440729462053300257176045331210843659285088277837145617911786897079697695822903441007426313983594108337849323523801461353403743354205332614568281522016124835207903049932403755935317561601917441459604496836970070735909956513671336330860323860179388331105289023853412948803361252289030773615479632718627401732040030962045909250635807312575103477559082544985107953795183152171682603428723813002693069914001266504241935848121105168305637550903127840183872570436135450397128584518510152749757839238010828541959435668309325917309393438110029245698090678671582148151378731513441520660610414440657938977851671873331032285873152157433944658015277107982301113691126105366410992148669718892349257122548807570025007125466370298794900665689909793941671147289356242383522692067149592303798561909497033391475359270730954911342570894131532358 -> 1990006068381464682049507550264302037762060389144914435155032181564512582025891607823250149058568412193385329414153759137054000955433528910483683140843695237118579512718408541440729462053300257176045331210843659285088277837145617911786897079697695822903441007426313983594108337849323523801461353403743354205332614568281522016124835207903049932403755935317561601917441459604496836970070735909956513671336330860323860179388331105289023853412948803361252289030773615479632718627401732040030962045909250635807312575103477559082544985107953795183152171682603428723813002693069914001266504241935848121105168305637550903127840183872570436135450397128584518510152749757839238010828541959435668309325917309393438110029245698090678671582148151378731513441520660610414440657938977851671873331032285873152157433944658015277107982301113691126105366410992148669718892349257122548807570025007125466370298794900665689909793941671147289356242383522692067149592303798561909497033391475359270730954911342570894131532358 +bconv79 baseconv 6015502869739087840490272225009583235686554415597820260864687529596382958074667901361875270833997129759447836372499555541652650451502594770436693287735337668554595929098876585393766197602427124862906155725316409444214451901418085327300532602678794493356481935382428415228909151655255164373511058123889329082619375667369210764727937344306215620616541202065239644000366634050592525680716301127542499939663309899544761500965235197405555980469459915477937424880270520272510181134527145637344414505867890548334494386092618208486156069437679989693532690668499343526981724430976888868585542016702257206431532422802162575894308454532674685186682402274196609885295851365911976479534913191915118210151797812795159108743079339204564318170806899555009259410527404594039497894336819299935284534331538880011864688710879036892746974953275405849133773110007259543807610050120756488168249583261372342667515892815096343346932768293662319876123910097532366065183592949456550921172097180847279701865234409426840668410766 -> 6015502869739087840490272225009583235686554415597820260864687529596382958074667901361875270833997129759447836372499555541652650451502594770436693287735337668554595929098876585393766197602427124862906155725316409444214451901418085327300532602678794493356481935382428415228909151655255164373511058123889329082619375667369210764727937344306215620616541202065239644000366634050592525680716301127542499939663309899544761500965235197405555980469459915477937424880270520272510181134527145637344414505867890548334494386092618208486156069437679989693532690668499343526981724430976888868585542016702257206431532422802162575894308454532674685186682402274196609885295851365911976479534913191915118210151797812795159108743079339204564318170806899555009259410527404594039497894336819299935284534331538880011864688710879036892746974953275405849133773110007259543807610050120756488168249583261372342667515892815096343346932768293662319876123910097532366065183592949456550921172097180847279701865234409426840668410766 +bconv80 baseconv 4721674509002784842344864141003393673089137680091440668260717371938345795302660565535881788240496853682038707484464310863889151722714658187786119386450529004684034710648752629248535147912138814920166176904926229674566090805847602244383193776500720254132610905647171991232089647680276174361654043546376396157894708786613176450217802422352783707604008874651507753601685162288117251635948934611119586655693590679777088408194900543274105112708385267612004468830226889125841321008539403641032011853954056310027563922203338751062114799121049136446957621664922927963650042590574198841196332234984513656542272799549698840401193003305283764561016970681896533793190753839906709681086564197501303764886900076252600084692622164483878741014064658238710677509984156669556507724226857069599520272720557151925768638001497467599390730948877998183219285938785277230485265916972621101328898463456445570037474012055243061252258859408976670671479137053446114565987363416858266084608753431705108235202206779212956615656596 -> 4721674509002784842344864141003393673089137680091440668260717371938345795302660565535881788240496853682038707484464310863889151722714658187786119386450529004684034710648752629248535147912138814920166176904926229674566090805847602244383193776500720254132610905647171991232089647680276174361654043546376396157894708786613176450217802422352783707604008874651507753601685162288117251635948934611119586655693590679777088408194900543274105112708385267612004468830226889125841321008539403641032011853954056310027563922203338751062114799121049136446957621664922927963650042590574198841196332234984513656542272799549698840401193003305283764561016970681896533793190753839906709681086564197501303764886900076252600084692622164483878741014064658238710677509984156669556507724226857069599520272720557151925768638001497467599390730948877998183219285938785277230485265916972621101328898463456445570037474012055243061252258859408976670671479137053446114565987363416858266084608753431705108235202206779212956615656596 +bconv81 baseconv 9510892144512085249275018397413722351535888803410628276542776410787927123434847518456778687187064714786890066386715732881311830074661041804981173834988813357626357664332734060141367516951356706230731874581947035415957390767207385350129876650445943888250294153598548602119653379910795874829810180533925922043189055449070682598387633907127369536141894111618036481012982562544619189381462522366417048046249419658821886339328607122138996901026714904797108534803209061856381909673693634617534574339342310733046709376826653416507892085968080489984441862034544938076632149184037423758350666641568104387017683563651749512844423775620691271709608581010474996031198621207797055078001455422495530416267114010872474914268815950284203068376243875177350897626724403359371624675822028221636433409884516411003658171567013289001684298493285255722701585168623074041390468611034184099866861509032454298088130296758273871134154763216914951740909725530074990202322051962686179414589290769763667044986291564890577004152222 -> 9510892144512085249275018397413722351535888803410628276542776410787927123434847518456778687187064714786890066386715732881311830074661041804981173834988813357626357664332734060141367516951356706230731874581947035415957390767207385350129876650445943888250294153598548602119653379910795874829810180533925922043189055449070682598387633907127369536141894111618036481012982562544619189381462522366417048046249419658821886339328607122138996901026714904797108534803209061856381909673693634617534574339342310733046709376826653416507892085968080489984441862034544938076632149184037423758350666641568104387017683563651749512844423775620691271709608581010474996031198621207797055078001455422495530416267114010872474914268815950284203068376243875177350897626724403359371624675822028221636433409884516411003658171567013289001684298493285255722701585168623074041390468611034184099866861509032454298088130296758273871134154763216914951740909725530074990202322051962686179414589290769763667044986291564890577004152222 +bconv82 baseconv 3456901425030618394011723130438256490792542318319735523515255306185196939308698752817940822865136996467848018629679285367233218672286722816451896768786204220320586683939393222905940971820644324646129629722387740145771943954328905513705485730905297265414752239534351869403772356050107132008214260482843718173822581181084159755349622083295193667670716324541786008529807599545149693843888823106530719118283570425691982953657691142444783384988527060080133138507780291068300382333834918941607068908852462046319362616584120851220241887029533755241068592099110060289167241261240766570600949484070935606431905912670648928290250704475703033553126233812366842077186976657108776720555272519485274610219573736531176760473936687354077338487468978295230805216233438751757588257783310113962844570833948121068093293399468034885968569831495375430608219776187246141046926597205943086575464162437066336461261879290448349244362708136983100666676756432364748374695161206527985367750583374748236697040433162574257657994893 -> 3456901425030618394011723130438256490792542318319735523515255306185196939308698752817940822865136996467848018629679285367233218672286722816451896768786204220320586683939393222905940971820644324646129629722387740145771943954328905513705485730905297265414752239534351869403772356050107132008214260482843718173822581181084159755349622083295193667670716324541786008529807599545149693843888823106530719118283570425691982953657691142444783384988527060080133138507780291068300382333834918941607068908852462046319362616584120851220241887029533755241068592099110060289167241261240766570600949484070935606431905912670648928290250704475703033553126233812366842077186976657108776720555272519485274610219573736531176760473936687354077338487468978295230805216233438751757588257783310113962844570833948121068093293399468034885968569831495375430608219776187246141046926597205943086575464162437066336461261879290448349244362708136983100666676756432364748374695161206527985367750583374748236697040433162574257657994893 +bconv83 baseconv 1114685497965416656732698379705177154332018255132868450308546205005993405567280072981566695061741881039048516102552874312269051663893747834026795621233419147538326924080953351805348216747199745827176484941805754634850882072791810734029161602760957279716941747344922081910423787336704993154447907572466248131412943004575414810460323173729936766860512018135659466077161376533906814970096913643985088546097058087017433587545159372869081036330282290692599635051036129999032787789351500982758970821530339993622053422466083530988850101164611989418201949687808631372265510607270878926847029899106166493196168843200497034157084670777050096818789192009101112230666951024673468455599767386395901573282160864807212191679488158066023583204287556099026421419828302458850552448077234437815451598944310816734580726283004477487254598344727512076754803216005237951552370014776640778150631007268249727659835185067225850551901050019535365052341639147479041197493091144131435616546556483209665736557431123925160778520001 -> 1114685497965416656732698379705177154332018255132868450308546205005993405567280072981566695061741881039048516102552874312269051663893747834026795621233419147538326924080953351805348216747199745827176484941805754634850882072791810734029161602760957279716941747344922081910423787336704993154447907572466248131412943004575414810460323173729936766860512018135659466077161376533906814970096913643985088546097058087017433587545159372869081036330282290692599635051036129999032787789351500982758970821530339993622053422466083530988850101164611989418201949687808631372265510607270878926847029899106166493196168843200497034157084670777050096818789192009101112230666951024673468455599767386395901573282160864807212191679488158066023583204287556099026421419828302458850552448077234437815451598944310816734580726283004477487254598344727512076754803216005237951552370014776640778150631007268249727659835185067225850551901050019535365052341639147479041197493091144131435616546556483209665736557431123925160778520001 +bconv84 baseconv 4631674675576889759774580763626146757314616877277276688821580847591125241225735322432478386501627625854306251733623874428127495008675943385205168037051093578061722771732017683543179179144921022217700703179037029787433663110453203011907955194739418988523319173536216235147483594651233042156771845192228067507504430126983098504199731847083090992921399795570743065369871623526423674280816910406843708674872183941723181027479292355933701100348267065858817661658539434890633630128909458410130894623225854374629504910047527824037576731766318807423128381424603981879198507514196724903158582298075327249541380671868410844433500977078393764765201588270475184527040319447750509502500248592071105439035508362936062879670073953461728598203549232685754534962081303480388328503169443465060785701125451911129197525848703961391592400511619394502912888633179308354807256663171097995207271107864865900234403718599165590670527562631249338155438288328566019355734457944780825214897697497647022919067727224315808251374972 -> 4631674675576889759774580763626146757314616877277276688821580847591125241225735322432478386501627625854306251733623874428127495008675943385205168037051093578061722771732017683543179179144921022217700703179037029787433663110453203011907955194739418988523319173536216235147483594651233042156771845192228067507504430126983098504199731847083090992921399795570743065369871623526423674280816910406843708674872183941723181027479292355933701100348267065858817661658539434890633630128909458410130894623225854374629504910047527824037576731766318807423128381424603981879198507514196724903158582298075327249541380671868410844433500977078393764765201588270475184527040319447750509502500248592071105439035508362936062879670073953461728598203549232685754534962081303480388328503169443465060785701125451911129197525848703961391592400511619394502912888633179308354807256663171097995207271107864865900234403718599165590670527562631249338155438288328566019355734457944780825214897697497647022919067727224315808251374972 +bconv85 baseconv 5054046050056162480616308689292024548964869387364190422046664401725285272589912290316921591529000996107139664638860857474291630684610120548839746031950778814237657029526620589407213043004465648249228138623631242102783559713715962998576004993902739199314713241903427496721703183412188760822003199242108016386325064523019036728327451956595083438052025928550379054896352039023411102914563041411340310861208383343232255940250328273276066044768014963719305806812780763480860826000566705246728310823754109703346572770708272626973496113309796285567744703659844373782029510124695943291513025323934796579111747179739099339847651916817808633677486719607359693437287945348611501450211335210548158310422843185416620577706151577788251170429894658017301128035163501614461426080704537662209999989390074486940698920319619141918892222935486806938495465456502087109970522080677318154911764017109643515547373078103899589635851628705637553657986340106557721543262227821943218743800561474658667899245079222411395627962954 -> 5054046050056162480616308689292024548964869387364190422046664401725285272589912290316921591529000996107139664638860857474291630684610120548839746031950778814237657029526620589407213043004465648249228138623631242102783559713715962998576004993902739199314713241903427496721703183412188760822003199242108016386325064523019036728327451956595083438052025928550379054896352039023411102914563041411340310861208383343232255940250328273276066044768014963719305806812780763480860826000566705246728310823754109703346572770708272626973496113309796285567744703659844373782029510124695943291513025323934796579111747179739099339847651916817808633677486719607359693437287945348611501450211335210548158310422843185416620577706151577788251170429894658017301128035163501614461426080704537662209999989390074486940698920319619141918892222935486806938495465456502087109970522080677318154911764017109643515547373078103899589635851628705637553657986340106557721543262227821943218743800561474658667899245079222411395627962954 +bconv86 baseconv 498798086249856996078905158527089252178252354616474394172461119910411171631292826073736602556970410082912069200470696003247765310664953329225394473530199291988638309691944270359924785028682212767297352333530901834996778251309520930768516293582423530621731217403165731121251151555770945037545406036989210387357400832932657285754731777142153396155556766391296931072723419377353904084664332660239729906912213077293702082263144782647170522782678472717601795640755406792373723360153845879320728491736575874624660417420637145112254661596762381651155864300611427965335254466320563531053670190079523989944583722257215623345414338537446967131163152599924262184793640362492531320591992541713749468141495745684405707800564874853466580233668785277968189425629507799781330615685510990987541085339778852756645896927436132968727171859406852630944464727944527160320701514605982443736736493640203160533925894246349169821977614700908740834415621048448039933001494956646808220009825648876027231476439483178930098804431 -> 498798086249856996078905158527089252178252354616474394172461119910411171631292826073736602556970410082912069200470696003247765310664953329225394473530199291988638309691944270359924785028682212767297352333530901834996778251309520930768516293582423530621731217403165731121251151555770945037545406036989210387357400832932657285754731777142153396155556766391296931072723419377353904084664332660239729906912213077293702082263144782647170522782678472717601795640755406792373723360153845879320728491736575874624660417420637145112254661596762381651155864300611427965335254466320563531053670190079523989944583722257215623345414338537446967131163152599924262184793640362492531320591992541713749468141495745684405707800564874853466580233668785277968189425629507799781330615685510990987541085339778852756645896927436132968727171859406852630944464727944527160320701514605982443736736493640203160533925894246349169821977614700908740834415621048448039933001494956646808220009825648876027231476439483178930098804431 +bconv87 baseconv 121084496246938756091360326968183447669408003357695636666809434165351641268048810034797802330249990483875867773810508313327536716135763308208501331181295930220779431854631232212252643298451102259222414943353545844517103624925210984235401542435209388315185310776864043097454488263484776327918820928848089893903414946895154202834659531337442361455332848693958803567164818358419400101377269195378942581561478555088084111930102186914135541816369426320520004163316326525600558153337686104116846449762760676421388019724379027306647329766806894319653514150396428629601049286326280060876408923013583131933537846421533082385816840354979038383045769148237482807999001641376034402680082390088048829341450432418674576144627129203205631880795851956476274791549026244858452693841928312590683754547684212576568334042442996455760137191812996355186679921483943941711572378411861774705402169183672753203888713353235469809533415041940845692623738373389551796918423796512694942156566866045678843956187455360350126116818 -> 121084496246938756091360326968183447669408003357695636666809434165351641268048810034797802330249990483875867773810508313327536716135763308208501331181295930220779431854631232212252643298451102259222414943353545844517103624925210984235401542435209388315185310776864043097454488263484776327918820928848089893903414946895154202834659531337442361455332848693958803567164818358419400101377269195378942581561478555088084111930102186914135541816369426320520004163316326525600558153337686104116846449762760676421388019724379027306647329766806894319653514150396428629601049286326280060876408923013583131933537846421533082385816840354979038383045769148237482807999001641376034402680082390088048829341450432418674576144627129203205631880795851956476274791549026244858452693841928312590683754547684212576568334042442996455760137191812996355186679921483943941711572378411861774705402169183672753203888713353235469809533415041940845692623738373389551796918423796512694942156566866045678843956187455360350126116818 +bconv88 baseconv 3137481737709257969498673800458092871980861386091007321911948095053233189128261087722833240292125529604620019280216502476026881444247410867562715300767082875579380442196012176010593786813248040975730912408874428617346092090222073050923633535808533617582795720854509485179351617389335866920030070035436976677262222920765227786329524253192080537960718788349744852406050038158128504037535349581689874764171665428874322444032992147559960663528882817269944494639575999037700918584478363248324361461568174198291278240276477382157142688857722988940751054263417697148253505495273865088092895313510095544438178398818997910540224495283959759019496843768790244096208762693305267120582145971159196622958470378578782511510638566519746278016005922104590038165979540061160654906602140582867267493377424462796039198934864883369751098703135613059224489083381239093433702296894306887513397693253101405485213688643815485747646810201887140599330602036386948395390572760471299638065909323753137250055492175311998736899910 -> 3137481737709257969498673800458092871980861386091007321911948095053233189128261087722833240292125529604620019280216502476026881444247410867562715300767082875579380442196012176010593786813248040975730912408874428617346092090222073050923633535808533617582795720854509485179351617389335866920030070035436976677262222920765227786329524253192080537960718788349744852406050038158128504037535349581689874764171665428874322444032992147559960663528882817269944494639575999037700918584478363248324361461568174198291278240276477382157142688857722988940751054263417697148253505495273865088092895313510095544438178398818997910540224495283959759019496843768790244096208762693305267120582145971159196622958470378578782511510638566519746278016005922104590038165979540061160654906602140582867267493377424462796039198934864883369751098703135613059224489083381239093433702296894306887513397693253101405485213688643815485747646810201887140599330602036386948395390572760471299638065909323753137250055492175311998736899910 +bconv89 baseconv 2046274752132102652044178363915018187996191471099129936085057563665084251800329916037507740480904949808815025253480679644915641694115569208333973860274654636228092750394071421192847367159807217458985278359873738287557215047356486989476970364299183473439826473802435074386745143765137402240377114548259894215298448722134941209647661328655017441203639139184654431025591953069342187753294012484397561486808415192839078718066963498778706567321081645587781132525051084153809411210437209897891178766353450347532715803329831957875980989175465813008789637909513545795020187951251841409542991599712705888791403161544671505051750360940168736268381589442872643007869270333779311675340043386598903905691555406559663117625224081682667164561831570755422842085457569271102177089884660998495831941953998605684252177294606750390252078219918941666127526447626239301212631127530029324651931025029184577610229758483555537728766740503839864160777811101838922959335322519869877028644070845623841344458233546715178955550674 -> 2046274752132102652044178363915018187996191471099129936085057563665084251800329916037507740480904949808815025253480679644915641694115569208333973860274654636228092750394071421192847367159807217458985278359873738287557215047356486989476970364299183473439826473802435074386745143765137402240377114548259894215298448722134941209647661328655017441203639139184654431025591953069342187753294012484397561486808415192839078718066963498778706567321081645587781132525051084153809411210437209897891178766353450347532715803329831957875980989175465813008789637909513545795020187951251841409542991599712705888791403161544671505051750360940168736268381589442872643007869270333779311675340043386598903905691555406559663117625224081682667164561831570755422842085457569271102177089884660998495831941953998605684252177294606750390252078219918941666127526447626239301212631127530029324651931025029184577610229758483555537728766740503839864160777811101838922959335322519869877028644070845623841344458233546715178955550674 +bconv90 baseconv 118602527536459346287751193895858339452846002549469567672070864971092145524351168921356901474700295498090943988126078212996156182208260965087675553829353411264172685784262097902975835505936786187885350305834382769010903305812298167161305432584149340741716813142196798892449073397871436885380305299413074324984593301399377917029044947569039001082971115246671903673763800474556420103836833600126591598131281320412550646566882790480990547073330861095656030934112972929902090660853879104723851870897920221056873164484529692866150707827279262057284693386859303190717797108165415381238767342852108225559390590583594063055600797489006392713705265225186415598014042360384159026486745015499846703494614334336523877321341526209689352446358288246204567860638557940344930196992220212409403846067662601157255298292873989204120276181150905755080578582091637732664052951816628594743961102799491016125721404659205345921999694920153184972342277772759217123721089263939416025455334863658907345554029248989723836157059 -> 118602527536459346287751193895858339452846002549469567672070864971092145524351168921356901474700295498090943988126078212996156182208260965087675553829353411264172685784262097902975835505936786187885350305834382769010903305812298167161305432584149340741716813142196798892449073397871436885380305299413074324984593301399377917029044947569039001082971115246671903673763800474556420103836833600126591598131281320412550646566882790480990547073330861095656030934112972929902090660853879104723851870897920221056873164484529692866150707827279262057284693386859303190717797108165415381238767342852108225559390590583594063055600797489006392713705265225186415598014042360384159026486745015499846703494614334336523877321341526209689352446358288246204567860638557940344930196992220212409403846067662601157255298292873989204120276181150905755080578582091637732664052951816628594743961102799491016125721404659205345921999694920153184972342277772759217123721089263939416025455334863658907345554029248989723836157059 +bconv91 baseconv 141523214243831696736556300460342600164991437925782534056938875593239973798240513308747077020959591382723510242830812715562287973914401103083251377158746287925992865570116456610888001686833962181140883357750299385879321747409378802053920059639577600664323584513509493210890208846766530074890180448612272923888776385753398188650889920755186156716174102510355275398264644143830980598780328955341333863870854267893277618322800225825199698142800067501272826843776047442502095981348280416592394728559086850878362872113166784738034562737547481048712021816109725324286263667609087599720088399605876339426281690899921707322404788744614038093739805335691361866038834727601619137983667959762224522083982537611768463322191011792835742597170769812166435032532577481827369961098718451918623773222349557194994003447199491905464356118150526173572534688020661065721086937847583481054809153151087072641282157075018408142570766926199625674574826493938287132805724356449496651251238196604832668799851646391746245687790 -> 141523214243831696736556300460342600164991437925782534056938875593239973798240513308747077020959591382723510242830812715562287973914401103083251377158746287925992865570116456610888001686833962181140883357750299385879321747409378802053920059639577600664323584513509493210890208846766530074890180448612272923888776385753398188650889920755186156716174102510355275398264644143830980598780328955341333863870854267893277618322800225825199698142800067501272826843776047442502095981348280416592394728559086850878362872113166784738034562737547481048712021816109725324286263667609087599720088399605876339426281690899921707322404788744614038093739805335691361866038834727601619137983667959762224522083982537611768463322191011792835742597170769812166435032532577481827369961098718451918623773222349557194994003447199491905464356118150526173572534688020661065721086937847583481054809153151087072641282157075018408142570766926199625674574826493938287132805724356449496651251238196604832668799851646391746245687790 +bconv92 baseconv 3755450700552863665060044164440695117584422252860478986173745322867745209614779273831966127705061480696706764100640653063971634591772417424084390816709703599482455816117308257634345915584090779505984655443805707415262368382173976373100121233914523389411586661755100602746712444669381841737021307878068126765907353018603600017566799738475118034508504479215123665403317828460935322952577893391668149239321212023827428768855115737489346208924902379096314265342724953280684525139381552163761085944222325645310968913992883000123998156149927369859435314134944162530581569179818418043727395011786716703273773764276795167415314523754634382979497550308615348622193521056016732666235046776787411935055325019689988118053181251754711441077098286631057593405428962426444610044707709312112751391716119181428065839212678467108667920598137851282151341853542029262329368308989554001704532573493495551607537210376600737472576072275509205179692612030860721552552758907794670464048854301950405064249324181471812407661875 -> 3755450700552863665060044164440695117584422252860478986173745322867745209614779273831966127705061480696706764100640653063971634591772417424084390816709703599482455816117308257634345915584090779505984655443805707415262368382173976373100121233914523389411586661755100602746712444669381841737021307878068126765907353018603600017566799738475118034508504479215123665403317828460935322952577893391668149239321212023827428768855115737489346208924902379096314265342724953280684525139381552163761085944222325645310968913992883000123998156149927369859435314134944162530581569179818418043727395011786716703273773764276795167415314523754634382979497550308615348622193521056016732666235046776787411935055325019689988118053181251754711441077098286631057593405428962426444610044707709312112751391716119181428065839212678467108667920598137851282151341853542029262329368308989554001704532573493495551607537210376600737472576072275509205179692612030860721552552758907794670464048854301950405064249324181471812407661875 +bconv93 baseconv 4426029146853417025367720356941836917027374665690585076231982072181802375719225879094506456287598162363440493415597520408360627367807804722812443804182212102710556201664485868653986822911921265542394980866096523331822292089857302503825766321327771183237905376259365828176815054427778913968925205733506946435101071448765190095173850484206969168240307124657049943843457022586339728033712198393245316138542945415417442170167968599828768340428535466623833744709544876932996806493692463913605935402535852488132547124697605104178986160936710519064021308902953927324921667723205719689496299860767067792226694958128596332229027015002027903447940262453023000075291669317898684350240664298882104520447369145419045026184705707568152975652762098104707650014974129272535862471796509436495984413583743333947417250306114061837245520856949355877078169228046739281945076768868416100568966965578154130496745483107654752942312090086395797772317049735055026500775123228843889909232945016464589328812434640081087048664735 -> 4426029146853417025367720356941836917027374665690585076231982072181802375719225879094506456287598162363440493415597520408360627367807804722812443804182212102710556201664485868653986822911921265542394980866096523331822292089857302503825766321327771183237905376259365828176815054427778913968925205733506946435101071448765190095173850484206969168240307124657049943843457022586339728033712198393245316138542945415417442170167968599828768340428535466623833744709544876932996806493692463913605935402535852488132547124697605104178986160936710519064021308902953927324921667723205719689496299860767067792226694958128596332229027015002027903447940262453023000075291669317898684350240664298882104520447369145419045026184705707568152975652762098104707650014974129272535862471796509436495984413583743333947417250306114061837245520856949355877078169228046739281945076768868416100568966965578154130496745483107654752942312090086395797772317049735055026500775123228843889909232945016464589328812434640081087048664735 +bconv94 baseconv 413407499190474245721197465692910644958622579600913565853472039268567791652162926569498188805321540617337163791646710401358612444285196358383191307559495640131471396834119964403690734877144096768341947344066709264888680562181101263567481821983454864512458596952511461723240430185665355805538078457741385224030543001798423357134159475328623269319345988839566717899074071292746576996914030876785981180876783530417782402711186149569023253546669751482836857646495795951764884394064173649164310261889845729207571444055131288806769864413903731285884677081889267276510528616757768402954822263919820875327072313002782675421089097077711511251152353417005893212365773436180534046558288295233081211870361618205643281808406059443286138311705900611735555649996466157009958017918933232162590335690943459553940432074482632197931974705524930098697790174415963631066825802347639934588819616403204859798452365774787980022363637121755679727053200780149141137687144151946275776966273205804764324553145275906291633127239 -> 413407499190474245721197465692910644958622579600913565853472039268567791652162926569498188805321540617337163791646710401358612444285196358383191307559495640131471396834119964403690734877144096768341947344066709264888680562181101263567481821983454864512458596952511461723240430185665355805538078457741385224030543001798423357134159475328623269319345988839566717899074071292746576996914030876785981180876783530417782402711186149569023253546669751482836857646495795951764884394064173649164310261889845729207571444055131288806769864413903731285884677081889267276510528616757768402954822263919820875327072313002782675421089097077711511251152353417005893212365773436180534046558288295233081211870361618205643281808406059443286138311705900611735555649996466157009958017918933232162590335690943459553940432074482632197931974705524930098697790174415963631066825802347639934588819616403204859798452365774787980022363637121755679727053200780149141137687144151946275776966273205804764324553145275906291633127239 +bconv95 baseconv 4520681172690179122037740039999613294057255663272734016948645560400846423498678985416150639182861221351816256638062343564565809241108598064120473492553864621106868100377712775651782960332435071117902507303071761356012183447317894340243374350852674336635677686530295081582125149940043529149042472144875142072371125204575422756989039256493750055126206173936957857223711223392842023193497906156007779757149979675544017556086109407668310760520782670396166925609571394129339909626170620440736755018292780437388858027762778677770232121618213477703702004548714507956410792693743374390048361000309515510251053361456438373404972397367152294319017196837938402122720657271244976683356316930170942271846739396024576861209197805952229495078037698207625789762446755347836696375635545175511611685014700798101157819376657939005968710745756546012795629290878370047738922776362159745410226662256043489876720016077195444613717733053475319593298099836642512122825327858854186179147755511552654961604083141117204553564212 -> 4520681172690179122037740039999613294057255663272734016948645560400846423498678985416150639182861221351816256638062343564565809241108598064120473492553864621106868100377712775651782960332435071117902507303071761356012183447317894340243374350852674336635677686530295081582125149940043529149042472144875142072371125204575422756989039256493750055126206173936957857223711223392842023193497906156007779757149979675544017556086109407668310760520782670396166925609571394129339909626170620440736755018292780437388858027762778677770232121618213477703702004548714507956410792693743374390048361000309515510251053361456438373404972397367152294319017196837938402122720657271244976683356316930170942271846739396024576861209197805952229495078037698207625789762446755347836696375635545175511611685014700798101157819376657939005968710745756546012795629290878370047738922776362159745410226662256043489876720016077195444613717733053475319593298099836642512122825327858854186179147755511552654961604083141117204553564212 +bconv96 baseconv 4752934392506115203776955925114374421888387530452017608298438543417001637871959570232817170915202164912029405619800038334324822516105634767127448499687495203912805111534772015726151501041295928398181015565625988526688120779765901727919555960722521488196012794023719086495224321439131203693047876517094516213849526749245822788006993741407113505990357625149618320986688736271317463030131702394003893446117169451284957928172206561724326823671196352062940410575141913778205064398021138947784958575209694149143987468189846007454178765665941220124399916141385475578948128700218759144360903107297198957777795733106077381886435990980246528154578624667984408319537247518378827211797604316495161767454028441813738269331274246361068766799963883624946544944055846262043689124618439762729180406120501492936736550905857964540348336638021953026440878710394136756855074164023469925934399003240647929056541230411615643763409379492774415376898112917935720874933251752676191115149524402940329413566452554881845625403582 -> 4752934392506115203776955925114374421888387530452017608298438543417001637871959570232817170915202164912029405619800038334324822516105634767127448499687495203912805111534772015726151501041295928398181015565625988526688120779765901727919555960722521488196012794023719086495224321439131203693047876517094516213849526749245822788006993741407113505990357625149618320986688736271317463030131702394003893446117169451284957928172206561724326823671196352062940410575141913778205064398021138947784958575209694149143987468189846007454178765665941220124399916141385475578948128700218759144360903107297198957777795733106077381886435990980246528154578624667984408319537247518378827211797604316495161767454028441813738269331274246361068766799963883624946544944055846262043689124618439762729180406120501492936736550905857964540348336638021953026440878710394136756855074164023469925934399003240647929056541230411615643763409379492774415376898112917935720874933251752676191115149524402940329413566452554881845625403582 +bconv97 baseconv 9440459917940859737378342172502343174665932245324208175145619290395032516234610870287748581194581953230497789517063425451112766475246780379408405805480233601616323311860187678137014412277661309181845742090049365361108712847493832900182576044354227929543851842115981956013992238017506897721214999154224240074880236385458111487366906005595115488232282445545779402862156170051814917490327110748633254506425013425657193896985983945936707437349677120715038924970838207248597726578790595627282787695617262854360845552686317427560136719320839454144810825662155925324280481930396251122861875665282363400812537676534534212255298144149378261891210594916048569660530383085561290634455983667583161703600593574455514882227405682732241081459493903372569117958779207608864201920977655743667175153293670665012521685214989654199506016458748355973187882466079202506231067733853004794890869959253635984166267067113931558452982319482550236235363692233587793277706095095421835317620216908929998627896995578156402084481140 -> 9440459917940859737378342172502343174665932245324208175145619290395032516234610870287748581194581953230497789517063425451112766475246780379408405805480233601616323311860187678137014412277661309181845742090049365361108712847493832900182576044354227929543851842115981956013992238017506897721214999154224240074880236385458111487366906005595115488232282445545779402862156170051814917490327110748633254506425013425657193896985983945936707437349677120715038924970838207248597726578790595627282787695617262854360845552686317427560136719320839454144810825662155925324280481930396251122861875665282363400812537676534534212255298144149378261891210594916048569660530383085561290634455983667583161703600593574455514882227405682732241081459493903372569117958779207608864201920977655743667175153293670665012521685214989654199506016458748355973187882466079202506231067733853004794890869959253635984166267067113931558452982319482550236235363692233587793277706095095421835317620216908929998627896995578156402084481140 +bconv98 baseconv 6704886872507410943521042950791113144577915980841725166060511226204138145394314521104430465504689530540078949710319466249121985246527296056648028474984175774720196046741947700217437210280185308245932651849976382399724052481747749677724507166310908910959976175868245625043071403512812598943508493713790369112251144031591554038385995504194239090851220644540890902596429309453678660681727912003169323034260665137554293950287316648014163760996895994661890730473061402662402938816519578036579623054695262607503915822342733646369296115677530888398689752950928393422090860233673510949078389045234114703739319143306592624524476807557496800809129250211623316637431274033120957833970536207043450663219080219913062475181618134805756777371462456137801488606781977034991206523703225205324401044625775271386324467775015859888342366632607836863630164181334949645837546372900939097845512142401684877569394627266290892397886824734784386115026838858550196257887475567160537308617570136423381156671125001863184307060166 -> 6704886872507410943521042950791113144577915980841725166060511226204138145394314521104430465504689530540078949710319466249121985246527296056648028474984175774720196046741947700217437210280185308245932651849976382399724052481747749677724507166310908910959976175868245625043071403512812598943508493713790369112251144031591554038385995504194239090851220644540890902596429309453678660681727912003169323034260665137554293950287316648014163760996895994661890730473061402662402938816519578036579623054695262607503915822342733646369296115677530888398689752950928393422090860233673510949078389045234114703739319143306592624524476807557496800809129250211623316637431274033120957833970536207043450663219080219913062475181618134805756777371462456137801488606781977034991206523703225205324401044625775271386324467775015859888342366632607836863630164181334949645837546372900939097845512142401684877569394627266290892397886824734784386115026838858550196257887475567160537308617570136423381156671125001863184307060166 +bconv99 baseconv 1155968992608422289594104162818340523170202305209406440396958692240490603649155770909178606143549313015767809829007406432212771080436655252878304905072402738816801551610567766153067073802189286181952144746202629891675215247548892774554807321037972799740861548353429692303649457967202470726168558507714348340834394787597044865285791917229839283803381754995945324742970782152022063374956931939357268847072511766715685009718368127529225488556733251967125395825343393134672282273926070348752742065771661403885298644066488545086645522992379147037625570455758692245653173385562916183902301107591474359052067454234538869737454412735563791526436027650366275283973423818557128399836668678046965511869261784714423275036274417573095996245649139906638721073160619388970589962186269504429261527201672006306620953765275871423637434777343915177962243495106776735301904977080800465873621397235009091525453243093729333196771296396575732423443653180032738027692341835972878252342567845075568912167896200494980620699997 -> 1155968992608422289594104162818340523170202305209406440396958692240490603649155770909178606143549313015767809829007406432212771080436655252878304905072402738816801551610567766153067073802189286181952144746202629891675215247548892774554807321037972799740861548353429692303649457967202470726168558507714348340834394787597044865285791917229839283803381754995945324742970782152022063374956931939357268847072511766715685009718368127529225488556733251967125395825343393134672282273926070348752742065771661403885298644066488545086645522992379147037625570455758692245653173385562916183902301107591474359052067454234538869737454412735563791526436027650366275283973423818557128399836668678046965511869261784714423275036274417573095996245649139906638721073160619388970589962186269504429261527201672006306620953765275871423637434777343915177962243495106776735301904977080800465873621397235009091525453243093729333196771296396575732423443653180032738027692341835972878252342567845075568912167896200494980620699997 +bconv100 baseconv 1155968992608422289594104162818340523170202305209406440396958692240490603649155770909178606143549313015767809829007406432212771080436655252878304905072402738816801551610567766153067073802189286181952144746202629891675215247548892774554807321037972799740861548353429692303649457967202470726168558507714348340834394787597044865285791917229839283803381754995945324742970782152022063374956931939357268847072511766715685009718368127529225488556733251967125395825343393134672282273926000000000000000000000000000e-27 -> 1155968992608422289594104162818340523170202305209406440396958692240490603649155770909178606143549313015767809829007406432212771080436655252878304905072402738816801551610567766153067073802189286181952144746202629891675215247548892774554807321037972799740861548353429692303649457967202470726168558507714348340834394787597044865285791917229839283803381754995945324742970782152022063374956931939357268847072511766715685009718368127529225488556733251967125395825343393134672282273926 diff -r 5738c611ff2a -r 6a1c8fcce229 Lib/test/mpdecimal/tests/testdata_dist/binop_eq.decTest --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/mpdecimal/tests/testdata_dist/binop_eq.decTest Sun Mar 06 08:37:10 2011 +0100 @@ -0,0 +1,4403 @@ +rounding: half_even +minExponent: -425000000 +maxExponent: 425000000 +precision: 116 +add_eq0 add_eq -68882998635339425466863586221872749420664434040997630548413636880417776447375217744441898147384895863101 -> -137765997270678850933727172443745498841328868081995261096827273760835552894750435488883796294769791726202 +precision: 27 +add_eq1 add_eq +926069853 -> 1852139706 +precision: 104 +add_eq2 add_eq -Infinity -> -Infinity +precision: 60 +add_eq3 add_eq -8820.48161934364928397387702871614085555803 -> -17640.96323868729856794775405743228171111606 +precision: 81 +add_eq4 add_eq -Inf -> -Infinity +precision: 65 +add_eq5 add_eq -Infinity -> -Infinity +precision: 21 +add_eq6 add_eq -41146525508063927 -> -82293051016127854 +precision: 100 +add_eq7 add_eq -640779228952153854324783733225497121450750153631275044917206111.363254604874E372237657 -> -1.281558457904307708649567466450994242901500307262550089834412222726509209748E+372237720 +precision: 200 +add_eq8 add_eq -.72116638699980904869901174037193762E-281846212 -> -1.44233277399961809739802348074387524E-281846212 +precision: 9 +add_eq9 add_eq +3963 -> 7926 +precision: 197 +add_eq10 add_eq +Infinity -> Infinity +precision: 25 +add_eq11 add_eq -841927932107286e-405002793 -> -1.683855864214572E-405002778 +precision: 278 +add_eq12 add_eq -3517549183442249435902332621531559266259972062322982119140819412759484205433918206253017294915590806165845935005424341503996896726514682476445398431715443301052137989323169545244329718144192803327334857518333767517480135363761842046382210536060518935444198e398717947 -> -7.035098366884498871804665243063118532519944124645964238281638825518968410867836412506034589831181612331691870010848683007993793453029364952890796863430886602104275978646339090488659436288385606654669715036667535034960270727523684092764421072121037870888396E+398718202 +precision: 11 +add_eq13 add_eq +.76369594E+12091955 -> 1.52739188E+12091955 +precision: 209 +add_eq14 add_eq 32114357810775993591114159996371569108094497047513614776553638227043929220222753032336575946843532666826332077968459480186193928185252093942655055069988232897191850662169080168E210809195 -> 6.4228715621551987182228319992743138216188994095027229553107276454087858440445506064673151893687065333652664155936918960372387856370504187885310110139976465794383701324338160336E+210809370 +precision: 91 +add_eq15 add_eq -683782424084810246040057425006165512383833369904542138586101023485116423473570209518851E-144358604 -> -1.367564848169620492080114850012331024767666739809084277172202046970232846947140419037702E-144358517 +precision: 50 +add_eq16 add_eq +1267347059903124863110810459903860343e+49166897 -> 2.534694119806249726221620919807720686E+49166933 +precision: 270 +add_eq17 add_eq +78335694705835409168279849498675702041507853050549836858612575283244278521895568230879473041358260903726542258255570776755457195670.730087634337415691 -> 156671389411670818336559698997351404083015706101099673717225150566488557043791136461758946082716521807453084516511141553510914391341.460175268674831382 +precision: 16 +add_eq18 add_eq 18782798955 -> 37565597910 +precision: 113 +add_eq19 add_eq -4486843092694772134107751364987281242190440510117042803804564046896411244822763252656467974536213231 -> -8973686185389544268215502729974562484380881020234085607609128093792822489645526505312935949072426462 +precision: 38 +add_eq20 add_eq -901977655537195169885649E-56154430 -> -1.803955311074390339771298E-56154406 +precision: 279 +add_eq21 add_eq -41020926029803077426429938239115259275974555103608e+50687786 -> -8.2041852059606154852859876478230518551949110207216E+50687835 +precision: 152 +add_eq22 add_eq 722590581407189452508623101309612881747559526871370484948419036376573920445450935713374778661e249520908 -> 1.445181162814378905017246202619225763495119053742740969896838072753147840890901871426749557322E+249521001 +precision: 29 +add_eq23 add_eq +NaN17682947140354228 -> NaN17682947140354228 +precision: 92 +add_eq24 add_eq +78187728223254 -> 156375456446508 +precision: 238 +add_eq25 add_eq 12035738496035655654113279124069329789099674489152244040643800319431728361487628565627194976813764326598882877782267641805846186981551451340539388430380183201731.147530052764182929482275247292610015164041288138324209975148651928310754856 -> 24071476992071311308226558248138659578199348978304488081287600638863456722975257131254389953627528653197765755564535283611692373963102902681078776860760366403462.295060105528365858964550494585220030328082576276648419950297303856621509712 +precision: 112 +add_eq26 add_eq +.316263196622360666159649274338764679732457803938000057007804734681046581081544 -> 0.632526393244721332319298548677529359464915607876000114015609469362093162163088 +precision: 231 +add_eq27 add_eq -59152987280932162156481514650568.1285947062956147640295546879923358550787162777520206136269763277635073569161760472149242147259031774687063595845026958470299409595859E-326452505 -> -1.183059745618643243129630293011362571894125912295280591093759846717101574325555040412272539526555270147138323520944298484294518063549374127191690053916940598819191718E-326452473 +precision: 28 +add_eq28 add_eq +2.9 -> 5.8 +precision: 295 +add_eq29 add_eq -166481718.5736723183090642309015096774184499313924931 -> -332963437.1473446366181284618030193548368998627849862 +precision: 23 +add_eq30 add_eq -10035306653863455567418E-141720971 -> -2.0070613307726911134836E-141720949 +precision: 234 +add_eq31 add_eq -423174079716064871547932.282964040855085851149609577090301E-172503494 -> -8.46348159432129743095864565928081710171702299219154180602E-172503471 +precision: 82 +add_eq32 add_eq -.17003636072120956345384192382685586606717196052648183079 -> -0.34007272144241912690768384765371173213434392105296366158 +precision: 90 +add_eq33 add_eq -Infinity -> -Infinity +precision: 214 +add_eq34 add_eq -sNaN569700261294529223612019718361067381689000251635299219367345742029813 -> -NaN569700261294529223612019718361067381689000251635299219367345742029813 Invalid_operation +precision: 287 +add_eq35 add_eq +5771523088748479951946530196652401119286587936706699468953779092626962476851306023704482010546792424614335797557912786200898834618105607501378362356684443032987181495731042582020218582892825972994486684021973962567897318.34887412080471432724266103423565612431830143140392700899 -> 11543046177496959903893060393304802238573175873413398937907558185253924953702612047408964021093584849228671595115825572401797669236211215002756724713368886065974362991462085164040437165785651945988973368043947925135794636.69774824160942865448532206847131224863660286280785401798 +precision: 142 +add_eq36 add_eq 2028600036427364398260742061502856151478098265552449778897236584544445887329861879092498916734655679e-329961115 -> 4.057200072854728796521484123005712302956196531104899557794473169088891774659723758184997833469311358E-329961016 +precision: 210 +add_eq37 add_eq -Infinity -> -Infinity +precision: 211 +add_eq38 add_eq 4568410453503752177388774481356461780004248228202230921355717057115494091647106251171625328193087073160231.691637576449618906621582446029970116748076619911246E+151952700 -> 9.136820907007504354777548962712923560008496456404461842711434114230988183294212502343250656386174146320463383275152899237813243164892059940233496153239822492E+151952805 +precision: 211 +add_eq39 add_eq .52536726643468151065419659927947894515446446983972037683107440234475026741743289E-187150116 -> 1.05073453286936302130839319855895789030892893967944075366214880468950053483486578E-187150116 +precision: 277 +add_eq40 add_eq -NaN -> -NaN +precision: 107 +add_eq41 add_eq -.9898219813603694947950150122 -> -1.9796439627207389895900300244 +precision: 166 +add_eq42 add_eq -Inf -> -Infinity +precision: 69 +add_eq43 add_eq +.67733215748051657183618E-394638690 -> 1.35466431496103314367236E-394638690 +precision: 36 +add_eq44 add_eq -.53567e38218481 -> -1.07134E+38218481 +precision: 241 +add_eq45 add_eq -5933594434192137114522076617896271304795030810595678085104997073130435122883533385569443506418245768215845619782657120227082751786111682799201599877360884493167191623695541057791060179485613449517507232463453576577226627 -> -11867188868384274229044153235792542609590061621191356170209994146260870245767066771138887012836491536431691239565314240454165503572223365598403199754721768986334383247391082115582120358971226899035014464926907153154453254 +precision: 39 +add_eq46 add_eq -694742502821120 -> -1389485005642240 +precision: 18 +add_eq47 add_eq -6322662136772517 -> -12645324273545034 +precision: 96 +add_eq48 add_eq -9811057708849.19690 -> -19622115417698.39380 +precision: 81 +add_eq49 add_eq -6193645583645366942466324000895867674129131722128691323238910038913521320900e251229105 -> -1.2387291167290733884932648001791735348258263444257382646477820077827042641800E+251229181 +precision: 145 +add_eq50 add_eq .5717388168181675479793798739060408912049207989649671796926969366450135894836902236013024655143602745074686249263838743970546398768701908532 -> 1.1434776336363350959587597478120817824098415979299343593853938732900271789673804472026049310287205490149372498527677487941092797537403817064 +precision: 126 +add_eq51 add_eq -742417.16107347101461684E-210860490 -> -1.48483432214694202923368E-210860484 +precision: 70 +add_eq52 add_eq +.4147462128592503113428922134014127094305387978534613164e292173290 -> 8.294924257185006226857844268028254188610775957069226328E+292173289 +precision: 184 +add_eq53 add_eq -59042579837112433.28823459 -> -118085159674224866.57646918 +precision: 78 +add_eq54 add_eq 2138229604703280612812582395860887783091451115517627323984446894987139 -> 4276459209406561225625164791721775566182902231035254647968893789974278 +precision: 55 +add_eq55 add_eq Infinity -> Infinity +precision: 222 +add_eq56 add_eq -Inf -> -Infinity +precision: 279 +add_eq57 add_eq +41094596135399713403246823474078307069107822795335763689946690767396405022667973730807370589925435013992557442771640167438807128906730514443083292367585949216305642230099755191573714077.815996474697569867545140169708787929580752589e-99871031 -> 8.2189192270799426806493646948156614138215645590671527379893381534792810045335947461614741179850870027985114885543280334877614257813461028886166584735171898432611284460199510383147428155631992949395139735090280339417575859161505178E-99870847 +precision: 96 +add_eq58 add_eq +2342 -> 4684 +precision: 189 +add_eq59 add_eq 88363636657384329808587257235557508476723.869186837350558423020210128115479843904174576662967182e339296179 -> 1.76727273314768659617174514471115016953447738373674701116846040420256230959687808349153325934364E+339296220 +precision: 254 +add_eq60 add_eq -3915550331730799919376204001967445446.8238574829622312267204594245909618840193637066697552186398295941958269E-159611691 -> -7.8311006634615998387524080039348908936477149659244624534409188491819237680387274133395104372796591883916538E-159611655 +precision: 61 +add_eq61 add_eq -7448126356976537703479857244852938971. -> -14896252713953075406959714489705877942 +precision: 193 +add_eq62 add_eq -.7443354698489434118719516435014834509600686596305434865861710265366178762661142583163778017665533559112779215400051670312e-366268463 -> -1.4886709396978868237439032870029669019201373192610869731723420530732357525322285166327556035331067118225558430800103340624E-366268463 +precision: 226 +add_eq63 add_eq -427287263481430898626788150413858765928614414513456 -> -854574526962861797253576300827717531857228829026912 +precision: 286 +add_eq64 add_eq -Infinity -> -Infinity +precision: 73 +add_eq65 add_eq +.63040096714975097354768E29087504 -> 1.26080193429950194709536E+29087504 +precision: 55 +add_eq66 add_eq +309368017634711871158101159217.75 -> 618736035269423742316202318435.50 +precision: 73 +add_eq67 add_eq 565530548738927273500157239856350E144402084 -> 1.131061097477854547000314479712700E+144402117 +precision: 275 +add_eq68 add_eq +.2191064293665E+56294531 -> 4.382128587330E+56294530 +precision: 125 +add_eq69 add_eq -9162979361027963961437402257741194518726084932821319541340898958167245082874E-412490594 -> -1.8325958722055927922874804515482389037452169865642639082681797916334490165748E-412490518 +precision: 114 +add_eq70 add_eq +.83976365223031017909241454875373895182262480854965 -> 1.67952730446062035818482909750747790364524961709930 +precision: 276 +add_eq71 add_eq +Infinity -> Infinity +precision: 171 +add_eq72 add_eq +93437126.5656440703974331304880224005670593221387603259963064789530971661208392569522293249553579645328678596428836972354616711296798281362150327077058259553551901 -> 186874253.1312881407948662609760448011341186442775206519926129579061943322416785139044586499107159290657357192857673944709233422593596562724300654154116519107103802 +precision: 81 +add_eq73 add_eq -Infinity -> -Infinity +precision: 70 +add_eq74 add_eq +.57794096682626731208e+379515947 -> 1.15588193365253462416E+379515947 +precision: 85 +add_eq75 add_eq -14.E81271140 -> -2.8E+81271141 +precision: 188 +add_eq76 add_eq -.9775730277544241491641919159161146268812545245448365010502323485315730768639820872219334361751891761721586e-122514192 -> -1.9551460555088482983283838318322292537625090490896730021004646970631461537279641744438668723503783523443172E-122514192 +precision: 231 +add_eq77 add_eq -Inf -> -Infinity +precision: 203 +add_eq78 add_eq -68042781045397771522292816039054557083033306588911360015087581119217856166638733208934376292915624102298 -> -136085562090795543044585632078109114166066613177822720030175162238435712333277466417868752585831248204596 +precision: 58 +add_eq79 add_eq +2735 -> 5470 +precision: 88 +add_eq80 add_eq -19705249430226192533720143206917680527709728894 -> -39410498860452385067440286413835361055419457788 +precision: 55 +add_eq81 add_eq +47268891E+388844743 -> 9.4537782E+388844750 +precision: 201 +add_eq82 add_eq +3719250081060827753353824022158305622506216360754075.343124138338091822866213968351332987878402624804147886759050006497706233809809904852000945896192 -> 7438500162121655506707648044316611245012432721508150.686248276676183645732427936702665975756805249608295773518100012995412467619619809704001891792384 +precision: 147 +add_eq83 add_eq -4507408729632993075285946137322E-89370884 -> -9.014817459265986150571892274644E-89370854 +precision: 213 +add_eq84 add_eq -18946245529698534527477539207880208950270436731425498206E-232510777 -> -3.7892491059397069054955078415760417900540873462850996412E-232510722 +precision: 202 +add_eq85 add_eq -.1160872466843020474546838053439180148944913736126154985031388319394436070740662614711081444253895763299276200973534109640860998120660460037206923900325693893491333 -> -0.2321744933686040949093676106878360297889827472252309970062776638788872141481325229422162888507791526598552401947068219281721996241320920074413847800651387786982666 +precision: 30 +add_eq86 add_eq +6196e75176987 -> 1.2392E+75176991 +precision: 261 +add_eq87 add_eq -20879909611696889805431128844755965033513611733955477497132526447325463645980750E284153687 -> -4.1759819223393779610862257689511930067027223467910954994265052894650927291961500E+284153766 +precision: 260 +add_eq88 add_eq 15777051784869834774217858131277114219650548011830230269.6947702542201715E+267645544 -> 3.15541035697396695484357162625542284393010960236604605393895405084403430E+267645599 +precision: 248 +add_eq89 add_eq -.3314890988993856871148614278938772314142062006887188202057252839938411079203255942778079702275160362202511571e-407488052 -> -6.629781977987713742297228557877544628284124013774376404114505679876822158406511885556159404550320724405023142E-407488053 +precision: 2 +add_eq90 add_eq +71 -> 1.4E+2 Rounded Inexact +precision: 169 +add_eq91 add_eq -1936775583675620553757985801533.70200615809472790357079104472296497694860747244500893262888e+332724190 -> -3.87355116735124110751597160306740401231618945580714158208944592995389721494489001786525776E+332724220 +precision: 28 +add_eq92 add_eq 6028281e-27055986 -> 1.2056562E-27055979 +precision: 19 +add_eq93 add_eq Inf -> Infinity +precision: 146 +add_eq94 add_eq -7568122499468077614447019230803397447228374908277620527455659417553638386889418513078019026614286213332688743684803573734265 -> -15136244998936155228894038461606794894456749816555241054911318835107276773778837026156038053228572426665377487369607147468530 +precision: 196 +add_eq95 add_eq 1604660763980250714158392427075712533728179793879263829846207609818838505030558242648447646527046196504349689732999397279905555406298238798104303993704824017.672662433601 -> 3209321527960501428316784854151425067456359587758527659692415219637677010061116485296895293054092393008699379465998794559811110812596477596208607987409648035.345324867202 +precision: 23 +add_eq96 add_eq -75101505200232748675 -> -150203010400465497350 +precision: 184 +add_eq97 add_eq +31422842452474992352848246575325983693456503121955774052367497919549246742315136900757056630872129996690697436.93112146114244757306664156708427554437066171468 -> 62845684904949984705696493150651967386913006243911548104734995839098493484630273801514113261744259993381394873.86224292228489514613328313416855108874132342936 +precision: 258 +add_eq98 add_eq -997565036538917747114922627947784992637915753143515054590082206601.4515423420808541322e+919186 -> -1.9951300730778354942298452558955699852758315062870301091801644132029030846841617082644E+919252 +precision: 297 +add_eq99 add_eq -NaN3692225015753843658446838674575739549149866 -> -NaN3692225015753843658446838674575739549149866 +precision: 229 +compare_eq0 compare_eq -9007353935772116764312875432306874137572149203516326025449391516289574770569042168835349563719357068848819005785238103768955745133965649225157281302191405217212913946343583511293659606356822479556100 -> 0 +precision: 191 +compare_eq1 compare_eq +5916794372888113130055019620156129327439018422817 -> 0 +precision: 199 +compare_eq2 compare_eq -6385564075788557361489053622233363254132221134310928544266570524036736301587945295E-378058779 -> 0 +precision: 67 +compare_eq3 compare_eq -Inf -> 0 +precision: 138 +compare_eq4 compare_eq -731794.5301062241561263430594144186812202291658812531098345748702914099163010 -> 0 +precision: 64 +compare_eq5 compare_eq -74656378421372356611717350391123636755552143017681237816518 -> 0 +precision: 202 +compare_eq6 compare_eq Infinity -> 0 +precision: 166 +compare_eq7 compare_eq -3135268112676303401003012206988648493047143470525854534119158778.621736466496668e202408875 -> 0 +precision: 72 +compare_eq8 compare_eq -211103475906311804063460111467516.611650629842907514261205948039 -> 0 +precision: 226 +compare_eq9 compare_eq +247151100684288841247818405518420486991489238997113284827328194394728120895752620616393699921722802522238696968765129 -> 0 +precision: 213 +compare_eq10 compare_eq 72473614479866.541342177106008e203745652 -> 0 +precision: 81 +compare_eq11 compare_eq -9893686669365087842005e187770999 -> 0 +precision: 61 +compare_eq12 compare_eq +719798193254487550725262309403794826520972209797933659E-207056196 -> 0 +precision: 86 +compare_eq13 compare_eq -8834904932890140954738312548270317E+326893162 -> 0 +precision: 286 +compare_eq14 compare_eq +4732861923965992367477077756422269542642483872091716920679064371688208226350778614637935127074494636137933801927427678692345623266371997170679032064 -> 0 +precision: 167 +compare_eq15 compare_eq +Inf -> 0 +precision: 299 +compare_eq16 compare_eq +12591.4413976810777576488622 -> 0 +precision: 66 +compare_eq17 compare_eq 116741932974250715770498940508884581291e35597230 -> 0 +precision: 67 +compare_eq18 compare_eq -.990252744417428594382738034117697734761076395891 -> 0 +precision: 296 +compare_eq19 compare_eq -5681060144595797043633127.18524117463305393307681289721041904519730457 -> 0 +precision: 255 +compare_eq20 compare_eq +730304626397709830365997833099650354508726032571144630117923605481854245975456299775845771185393001434918550393807780230521935967322466355895162477917973348986037561856746666031151 -> 0 +precision: 211 +compare_eq21 compare_eq -4254933926287947935464416595245014214493488233384119601501584707345520122558187821633820293312294291107860230328393898898372276632 -> 0 +precision: 162 +compare_eq22 compare_eq -794147335845740783746721412911405606235374996808278547957651329296099323760787267455908892781443755539848741366173255083430990537758465959517213344645528019307 -> 0 +precision: 88 +compare_eq23 compare_eq -.91968073570857866355163324199881176276e-341310937 -> 0 +precision: 115 +compare_eq24 compare_eq -Inf -> 0 +precision: 140 +compare_eq25 compare_eq -1972133465063e-117370946 -> 0 +precision: 33 +compare_eq26 compare_eq -93944508708375045473e+123521832 -> 0 +precision: 98 +compare_eq27 compare_eq .785395940277344662788524612832 -> 0 +precision: 169 +compare_eq28 compare_eq 6893914955473388400778406487797306220247981693781278060 -> 0 +precision: 77 +compare_eq29 compare_eq -56898105733392710386080719824.733278705110711100843350259861546411700e135519815 -> 0 +precision: 2 +compare_eq30 compare_eq -46 -> 0 +precision: 208 +compare_eq31 compare_eq Infinity -> 0 +precision: 60 +compare_eq32 compare_eq +101E170147874 -> 0 +precision: 77 +compare_eq33 compare_eq -66258055451775755467691 -> 0 +precision: 69 +compare_eq34 compare_eq +1897535680623417547587049270013143133467911398584597438977961290554 -> 0 +precision: 201 +compare_eq35 compare_eq +Infinity -> 0 +precision: 81 +compare_eq36 compare_eq -2964. -> 0 +precision: 273 +compare_eq37 compare_eq -198974508394979024808079739951986165355645721532590954539888124910127985871393714979286224869911305505052371.45991079666713713678489912150347030550193749468732910306275099512733633348328775648975332365014 -> 0 +precision: 257 +compare_eq38 compare_eq -Inf -> 0 +precision: 217 +compare_eq39 compare_eq -2066391444308.668277764724131630012831233259119 -> 0 +precision: 39 +compare_eq40 compare_eq -8449260028672859015 -> 0 +precision: 117 +compare_eq41 compare_eq +7996192339752622879894203560570261377931132719630641168832842390103509632 -> 0 +precision: 246 +compare_eq42 compare_eq .621739602491313265130828220442314512048666506402357407931301794294424321070098142999551860110495517374132020686360491901268492799941091583144600365815 -> 0 +precision: 237 +compare_eq43 compare_eq -.6332735827544529163950445507505516703221686705762208884639055540485091879970450169072912989599355324655816810653778594544070895E86713243 -> 0 +precision: 257 +compare_eq44 compare_eq +.1277182288063531468560805784932256275452526473784679302678063160415585510873610306E+224019300 -> 0 +precision: 277 +compare_eq45 compare_eq 89178868201045237051962407667621610959409753235165133715944135920042759819399908871954728392764E-86991959 -> 0 +precision: 265 +compare_eq46 compare_eq +88324386722078668271579193759749782941431898032339143208589736362337433632757799609566350683510071551084177840033813915991941233662802262498578768975408899018494404671188603951211763363140019452409300874009545227.1965293920 -> 0 +precision: 126 +compare_eq47 compare_eq +7439319482112839387765.5161495604875859889324844362597311 -> 0 +precision: 229 +compare_eq48 compare_eq +1786.34818903696689288681914890190e+402589201 -> 0 +precision: 270 +compare_eq49 compare_eq +6920765670667989252208419493317093.4703792 -> 0 +precision: 228 +compare_eq50 compare_eq -418730244981491866838672967268977447561018816066706673443653360744583381585453539650868050155525126641116271455901853690267247104884357672914210921849923618900368186580461149681534e+127960255 -> 0 +precision: 171 +compare_eq51 compare_eq -.860031108648211040650227268088699123347461459509181370871160991605527837826222814417778917710675964122439961988391326866566710085406262326993281 -> 0 +precision: 12 +compare_eq52 compare_eq +312 -> 0 +precision: 289 +compare_eq53 compare_eq -57965161388903348743915079271873493452028466186269316289984350892722208589712921378172501460523645733920822603834667212669193536949921266749407010589444370.168837967967024237574639374901517823535355684209175099642543559722312791910474539475336258596 -> 0 +precision: 112 +compare_eq54 compare_eq -7636834335469345853726083094186228657150351657946659168 -> 0 +precision: 34 +compare_eq55 compare_eq -8490774049191 -> 0 +precision: 265 +compare_eq56 compare_eq +.2290660417697529884599773401290365250016788100209681992341111134875657561490049891 -> 0 +precision: 241 +compare_eq57 compare_eq 846426125581058816461248848698482507469272761120480801201134686535236949958561472015611522446267807686291882835969383458E-397419314 -> 0 +precision: 173 +compare_eq58 compare_eq -24826274437662289781 -> 0 +precision: 199 +compare_eq59 compare_eq 479278501724080635557584933192754760541093858843 -> 0 +precision: 300 +compare_eq60 compare_eq 936862575282440780126712802279886124221523377283079974758143265370.466300240626681434796438678 -> 0 +precision: 10 +compare_eq61 compare_eq +945 -> 0 +precision: 288 +compare_eq62 compare_eq -.145260377713219170355463634611793714594878041876034714155948650069869764430543570286554932697246690056716934633807198845325621241158009676371813189817039187404551192218420909160671293727773714298042649759903982658674247989447892746944118244345112761820780312094060635246227683 -> 0 +precision: 66 +compare_eq63 compare_eq 688405296607045181930448545412977012291569481336 -> 0 +precision: 74 +compare_eq64 compare_eq -237375047118729109400227640042325462522683 -> 0 +precision: 73 +compare_eq65 compare_eq -1912568279265251151469188620017960685182403827445381 -> 0 +precision: 12 +compare_eq66 compare_eq -1.4e+165940976 -> 0 +precision: 218 +compare_eq67 compare_eq +180770399264466643670636337655460136422461479935146367023634970315665002519713045524989630825063567363020323362001624610255654587936969903.4702868763940233805689072889388293140404858557468821871376054990851207938084e-62855166 -> 0 +precision: 158 +compare_eq68 compare_eq 43814162216963469838140237940804555863650417044001367159311129.5851618187237587980353426224277338514683035968957923818834572504473316133863394397070e-256639213 -> 0 +precision: 174 +compare_eq69 compare_eq 8228630788.863469510840782113437262545317700231410304998077667310667412677082755905260 -> 0 +precision: 20 +compare_eq70 compare_eq +13674294218 -> 0 +precision: 40 +compare_eq71 compare_eq -.9593579935840389625267202708174E167047834 -> 0 +precision: 85 +compare_eq72 compare_eq +49.130637018328607972310407605668923247953353912 -> 0 +precision: 110 +compare_eq73 compare_eq -34703055561639688623200472 -> 0 +precision: 104 +compare_eq74 compare_eq 6942423911248970195403525.350602635738 -> 0 +precision: 38 +compare_eq75 compare_eq +2995891e-350109900 -> 0 +precision: 6 +compare_eq76 compare_eq +41.514e-93272807 -> 0 +precision: 83 +compare_eq77 compare_eq 883986733650.665794483121877140316157432 -> 0 +precision: 78 +compare_eq78 compare_eq -.8531432400131245548709746450098421508618538527983099792859794024 -> 0 +precision: 3 +compare_eq79 compare_eq -Infinity -> 0 +precision: 281 +compare_eq80 compare_eq +.71427589545839183943272594085797004917353585532052004005311986996003650685761642549874403348788276151755046948424535426445077677264252404783621862 -> 0 +precision: 36 +compare_eq81 compare_eq +603829499360264303518393077530830400E-226494507 -> 0 +precision: 269 +compare_eq82 compare_eq -776175063291600101366895543999053897412353752444533765805847005790728111619705296477560833600391610579614526217307111556043927146337021099851673441404565920794215496790781984778088515352139335819552 -> 0 +precision: 51 +compare_eq83 compare_eq -17 -> 0 +precision: 265 +compare_eq84 compare_eq -518161597424055338969561061851e+119183938 -> 0 +precision: 8 +compare_eq85 compare_eq 77533103 -> 0 +precision: 41 +compare_eq86 compare_eq -Infinity -> 0 +precision: 288 +compare_eq87 compare_eq -.307735241395178289000380750144607402635680544024548717328034910349575240203536 -> 0 +precision: 14 +compare_eq88 compare_eq -9610128.2e126328502 -> 0 +precision: 26 +compare_eq89 compare_eq -25.5 -> 0 +precision: 287 +compare_eq90 compare_eq 9498912911528E423364418 -> 0 +precision: 113 +compare_eq91 compare_eq -9835834697125510303483901957471429469951199273017395166458433801704118589945935768710890412467603065163833 -> 0 +precision: 298 +compare_eq92 compare_eq +5989973200 -> 0 +precision: 21 +compare_eq93 compare_eq +855.55871 -> 0 +precision: 261 +compare_eq94 compare_eq -170154907914149531616787479918808412704670690785004101130413905778369523828316743207760324803815449646295770057821185763813291181572254116186249751 -> 0 +precision: 153 +compare_eq95 compare_eq 8457584552239694621071976525341210303074870891413068486860208541.7615546033117466805201385747294478 -> 0 +precision: 90 +compare_eq96 compare_eq -2389609473350169301064192444054 -> 0 +precision: 17 +compare_eq97 compare_eq +NaN -> NaN +precision: 151 +compare_eq98 compare_eq -8947511627083754886602209 -> 0 +precision: 130 +compare_eq99 compare_eq 976124138088614126470201135226780680.704702147394065847816730859457932432206409349567706054485514784856262724882464446069787 -> 0 +precision: 248 +comparesig_eq0 comparesig_eq +443218328141977116618499219869427792863703940883837500974693489910900558802508122820265027945576438583080053472499267789810322489682277548554477094690233317889310073639439589694465931676 -> 0 +precision: 255 +comparesig_eq1 comparesig_eq 37997421400698793468295234499258938258888893937595659697398091686412465480 -> 0 +precision: 103 +comparesig_eq2 comparesig_eq +Inf -> 0 +precision: 191 +comparesig_eq3 comparesig_eq -6933701919877978919150970419010899976433950357154499492837634590108537724381523643084717306147027867742153815638220191504998319490472095784410069242528741482 -> 0 +precision: 193 +comparesig_eq4 comparesig_eq -47812518464585119626726035403928385947656659998352074179212502021696385806273985217167217928648389886030152648993468188319199223483710363052017557 -> 0 +precision: 163 +comparesig_eq5 comparesig_eq 360337639872546936929007085256394475943155702027596131443312309878840379766218579145537526500698338603338714019025407380306e-418265056 -> 0 +precision: 242 +comparesig_eq6 comparesig_eq -31760299193180193086039340877196612051E-353127402 -> 0 +precision: 137 +comparesig_eq7 comparesig_eq -.998382178397181588724984523380125082139160955422944628402154086189654343 -> 0 +precision: 94 +comparesig_eq8 comparesig_eq -21521287105485335900058835677997929.685115 -> 0 +precision: 130 +comparesig_eq9 comparesig_eq -784068E248558867 -> 0 +precision: 35 +comparesig_eq10 comparesig_eq +51702787700946121114 -> 0 +precision: 137 +comparesig_eq11 comparesig_eq 4667014531958E-147495966 -> 0 +precision: 166 +comparesig_eq12 comparesig_eq +4760165972926658E381246741 -> 0 +precision: 119 +comparesig_eq13 comparesig_eq +5505737404560022093411498104262575867104894784446366690414229636274784147258688774440827920763 -> 0 +precision: 132 +comparesig_eq14 comparesig_eq -347807043852551101647101869412552583233298278825134385405040508165964901659202085513866758597221085826837780440667693198445 -> 0 +precision: 118 +comparesig_eq15 comparesig_eq -50642681 -> 0 +precision: 190 +comparesig_eq16 comparesig_eq -.94361683541474257700162793360802243112269273008329605231046550673638851756932412089551 -> 0 +precision: 232 +comparesig_eq17 comparesig_eq -252557444700430861780 -> 0 +precision: 89 +comparesig_eq18 comparesig_eq -4183946310068446304739.2285521213055446611619030277e-357595691 -> 0 +precision: 46 +comparesig_eq19 comparesig_eq -365136.924140586E-44399100 -> 0 +precision: 96 +comparesig_eq20 comparesig_eq -861426279194159791435914948351498849796524754107803000188924032541099623936859 -> 0 +precision: 231 +comparesig_eq21 comparesig_eq -Infinity -> 0 +precision: 34 +comparesig_eq22 comparesig_eq -18150478437875.E-281898512 -> 0 +precision: 227 +comparesig_eq23 comparesig_eq 57916107015060486447703111925486531310742653212070825099842127990315480932510789419377847269547151321271440862244938257019568953721526841840680184399775395579 -> 0 +precision: 204 +comparesig_eq24 comparesig_eq -182860817813518478024759693816327277831702667588452582010605829748826591672626251536E111616411 -> 0 +precision: 209 +comparesig_eq25 comparesig_eq -79511531912729216167521329108591865165893985791420024207.6552167446519439569057292654485977374938190502497132123700730185171927276352976878957843271050904682654 -> 0 +precision: 182 +comparesig_eq26 comparesig_eq +1269441806540666651697925608827109930 -> 0 +precision: 8 +comparesig_eq27 comparesig_eq -30. -> 0 +precision: 259 +comparesig_eq28 comparesig_eq +224851905702113858.35886883229993744933464854149639851744288954052052504348415853760382663928441048089622941688310835722566004980632091599264978892685180352267553802511339438517250598851386797430618480301600593962328367979899977 -> 0 +precision: 244 +comparesig_eq29 comparesig_eq -.143093784725095670283239974024223403475502540616850769748698331459416123974359162423020785322549107657527135425710818209687219690060596206609226856701577171841263673918699963154804763074987224764175721736349e-402448170 -> 0 +precision: 233 +comparesig_eq30 comparesig_eq +7962.2 -> 0 +precision: 64 +comparesig_eq31 comparesig_eq .345219 -> 0 +precision: 170 +comparesig_eq32 comparesig_eq +NaN -> NaN Invalid_operation +precision: 45 +comparesig_eq33 comparesig_eq +.6565938761315e227931936 -> 0 +precision: 208 +comparesig_eq34 comparesig_eq +.256549465694027632146005314147130212461745309999148219932655 -> 0 +precision: 263 +comparesig_eq35 comparesig_eq -243405782531174049750660374386612021870199513832409370489204978027636588778346722665138689567246206883577946196596 -> 0 +precision: 140 +comparesig_eq36 comparesig_eq +89 -> 0 +precision: 205 +comparesig_eq37 comparesig_eq +80221990337451797941151796155941669650422003663081570320565e+362981946 -> 0 +precision: 157 +comparesig_eq38 comparesig_eq -886.84405929870625327666400733 -> 0 +precision: 55 +comparesig_eq39 comparesig_eq 651055903500107359323E-129425639 -> 0 +precision: 31 +comparesig_eq40 comparesig_eq +5902.3494 -> 0 +precision: 283 +comparesig_eq41 comparesig_eq +3477271273664033393177320831550843067545772483039052858416451284409114092933143001654879327290678728649861697302720629482367E-36514271 -> 0 +precision: 94 +comparesig_eq42 comparesig_eq +26508299325881366146548994474824862480029.61803942978366096670484716835883415710535382125538727 -> 0 +precision: 67 +comparesig_eq43 comparesig_eq -520856914255828430040461625110456078136061468e+189012675 -> 0 +precision: 300 +comparesig_eq44 comparesig_eq -sNaN1719199864504192981369065046718141571733427655329591740479609134773 -> -NaN1719199864504192981369065046718141571733427655329591740479609134773 Invalid_operation +precision: 254 +comparesig_eq45 comparesig_eq 2669871175002759062327e40673202 -> 0 +precision: 255 +comparesig_eq46 comparesig_eq -750319257079568.4932947848244945128065344527137150220007538078979760184761195291229685807617013571494849406376202075283052581611592260170904089086693363050491590096051640E-276665520 -> 0 +precision: 97 +comparesig_eq47 comparesig_eq -Infinity -> 0 +precision: 277 +comparesig_eq48 comparesig_eq -1734650251013986509105600532769007935247090968914151018389034433138215984519308349073258761124514640635670794074633301133868412210488034440073780752109113864696474607025527475031294996743787010473067392708E158775841 -> 0 +precision: 73 +comparesig_eq49 comparesig_eq -.7501411520050394755732161438414587712441297E-91061421 -> 0 +precision: 174 +comparesig_eq50 comparesig_eq +1.5 -> 0 +precision: 107 +comparesig_eq51 comparesig_eq +.1626902790496728212382616245 -> 0 +precision: 206 +comparesig_eq52 comparesig_eq 103567908430272317023394484604560167490830779769562028191578492814130837349369628148 -> 0 +precision: 151 +comparesig_eq53 comparesig_eq -.306901421160199110759338123050230466990247409003649584967108608347728771906346487981474419593001482740810780495693E-355990929 -> 0 +precision: 133 +comparesig_eq54 comparesig_eq -66488371896601189243959190296625593063199862547 -> 0 +precision: 199 +comparesig_eq55 comparesig_eq -304907749247062928133882971570295578000957765414801583802 -> 0 +precision: 88 +comparesig_eq56 comparesig_eq .667134127807274140872 -> 0 +precision: 25 +comparesig_eq57 comparesig_eq -9785E-161261932 -> 0 +precision: 181 +comparesig_eq58 comparesig_eq -436465003290957681609262971267437650067550190657697683590e88881700 -> 0 +precision: 107 +comparesig_eq59 comparesig_eq sNaN438 -> NaN438 Invalid_operation +precision: 122 +comparesig_eq60 comparesig_eq 6805139245289086722722546114.31357051666639 -> 0 +precision: 24 +comparesig_eq61 comparesig_eq +3493.77E410980512 -> 0 +precision: 222 +comparesig_eq62 comparesig_eq +Infinity -> 0 +precision: 200 +comparesig_eq63 comparesig_eq -24070239476950525376458192588411127714052427247715961763332159094311632715690816062902913890792077975174203706352745765162055691844183496657401554817759382337732665161013248073021508 -> 0 +precision: 160 +comparesig_eq64 comparesig_eq +46199393368388981031556113233383197212396288810445815324696453947831093234885877661436732e-113516827 -> 0 +precision: 299 +comparesig_eq65 comparesig_eq -58078542E-124225520 -> 0 +precision: 38 +comparesig_eq66 comparesig_eq 23180251521379780072690958 -> 0 +precision: 180 +comparesig_eq67 comparesig_eq Inf -> 0 +precision: 173 +comparesig_eq68 comparesig_eq +Infinity -> 0 +precision: 236 +comparesig_eq69 comparesig_eq +48796858471830458601744841E343866752 -> 0 +precision: 152 +comparesig_eq70 comparesig_eq 9019750454498797492154956601651600014317388557535384118850700808998770938959 -> 0 +precision: 124 +comparesig_eq71 comparesig_eq -55355253203515762435293691965595753492244794078050.88038218212797322289001081235138416608 -> 0 +precision: 238 +comparesig_eq72 comparesig_eq +.174405081250299296686158122239013835458639588577324575008695620777917187791497809061971402E-191010293 -> 0 +precision: 12 +comparesig_eq73 comparesig_eq -94379E375088835 -> 0 +precision: 24 +comparesig_eq74 comparesig_eq -57275464382E-11669520 -> 0 +precision: 139 +comparesig_eq75 comparesig_eq -59362155200307923174899701631568702172987363782851967e-90376469 -> 0 +precision: 166 +comparesig_eq76 comparesig_eq -sNaN8022955350797271743521220661860068150004094534978599374117523550281156228863 -> -NaN8022955350797271743521220661860068150004094534978599374117523550281156228863 Invalid_operation +precision: 124 +comparesig_eq77 comparesig_eq -.79043627E368736732 -> 0 +precision: 148 +comparesig_eq78 comparesig_eq 72800120530298499018177574575616336173741182688081604999622875361466150782396787003937195 -> 0 +precision: 91 +comparesig_eq79 comparesig_eq -Inf -> 0 +precision: 205 +comparesig_eq80 comparesig_eq -8303662893166624819399739388821812215976959684873666755907439403057259144785438121 -> 0 +precision: 32 +comparesig_eq81 comparesig_eq 3122.654904272676529013962 -> 0 +precision: 137 +comparesig_eq82 comparesig_eq 530314963994043807989826223043725200083572862835089454046771724202946013583378593983874723309546949515330526 -> 0 +precision: 153 +comparesig_eq83 comparesig_eq +5251054043035114272589353544346869055 -> 0 +precision: 196 +comparesig_eq84 comparesig_eq 32907845717664604077678973990832042999133285502613380782541596162687171382272673758091010865741404165786048168265560811741946949627110114276920983513636935702270914992386941571648162875474393229 -> 0 +precision: 267 +comparesig_eq85 comparesig_eq -145477.36085741942368111299133553495166398813458525407671937406523482289386958918608618028201818180367731747981428205891103639921581098266001822509460098220477243360842780947119931643351266878494818464890877817504979308033410860491032 -> 0 +precision: 87 +comparesig_eq86 comparesig_eq -5300872926384109386495104074509939488361476830.58842994843249445415914568507 -> 0 +precision: 296 +comparesig_eq87 comparesig_eq -Infinity -> 0 +precision: 178 +comparesig_eq88 comparesig_eq -7147837014474e-165622920 -> 0 +precision: 146 +comparesig_eq89 comparesig_eq Inf -> 0 +precision: 190 +comparesig_eq90 comparesig_eq +568917471990264033148495754614160410115160.639994862860671e-377147670 -> 0 +precision: 153 +comparesig_eq91 comparesig_eq -Inf -> 0 +precision: 213 +comparesig_eq92 comparesig_eq 963141918525426785654180839756966764384838965304941870521624822134472348537526025036902323387848493593390039238047.1402879 -> 0 +precision: 204 +comparesig_eq93 comparesig_eq +309931186985392315382335507284494613278564708523419399468209419016658416070375696481 -> 0 +precision: 221 +comparesig_eq94 comparesig_eq -154483148338112844837500671040720359610849173958624132217177909015913440740227481602550034901336077278687502351788154995810376052369153755071413705671971918199359534907415169285808896840853941108708314056398524031e-10384050 -> 0 +precision: 70 +comparesig_eq95 comparesig_eq -841750032910036116233146806114682227725010102053515167 -> 0 +precision: 136 +comparesig_eq96 comparesig_eq +290316105781672314935590622.584881501203837876 -> 0 +precision: 40 +comparesig_eq97 comparesig_eq +.54750471332738278883325527266e-370156793 -> 0 +precision: 299 +comparesig_eq98 comparesig_eq -921945294154951074691990e+247382556 -> 0 +precision: 262 +comparesig_eq99 comparesig_eq 844260893664238275326964864428550816106089231301071144471479560384500194785910249144896316305120894479179697189371088409948850574975751581201843734334445699096 -> 0 +precision: 112 +comparetotal_eq0 comparetotal_eq +5246899448694934.76746583E7239466 -> 0 +precision: 79 +comparetotal_eq1 comparetotal_eq -461866196766787289755310460813711109452546567.23424500338922 -> 0 +precision: 40 +comparetotal_eq2 comparetotal_eq 40559967.8048E-198120324 -> 0 +precision: 266 +comparetotal_eq3 comparetotal_eq -9437982050732575696500348294673631751154677609 -> 0 +precision: 124 +comparetotal_eq4 comparetotal_eq -96811735681867.7984178276098534408383E127638675 -> 0 +precision: 75 +comparetotal_eq5 comparetotal_eq 391. -> 0 +precision: 33 +comparetotal_eq6 comparetotal_eq -9.43680350 -> 0 +precision: 294 +comparetotal_eq7 comparetotal_eq 27959604366359647700745733948049612690243207984915855045328511423008092151246906593884074672578372998798271317716359579245043771207423960210775051701414490278138417968439010305878244389012170592302216620518633267137274550542358977200 -> 0 +precision: 138 +comparetotal_eq8 comparetotal_eq -25528965775279494749526155563572623484078432378058720879126682388159906903511297E-244882723 -> 0 +precision: 244 +comparetotal_eq9 comparetotal_eq -9281850005665851235622347297669259701948183160824762561351343345512852597824887595865158304173994318791300854529231998277183746085679426640138406269E+328418863 -> 0 +precision: 278 +comparetotal_eq10 comparetotal_eq 2517236410289071215454366.91690707483733981740428621255157317707 -> 0 +precision: 141 +comparetotal_eq11 comparetotal_eq -75335785477146958137792573755062761314100934398145573120696144720210794533475576369435058E+40891440 -> 0 +precision: 230 +comparetotal_eq12 comparetotal_eq sNaN76354902994648853221883284 -> 0 +precision: 51 +comparetotal_eq13 comparetotal_eq Inf -> 0 +precision: 33 +comparetotal_eq14 comparetotal_eq -4435 -> 0 +precision: 171 +comparetotal_eq15 comparetotal_eq -125136902630654290263592590336273488708373234272833809704043198875429961901519716584164061228408050181599610778152E-245322156 -> 0 +precision: 189 +comparetotal_eq16 comparetotal_eq +6874353725896231282439388654524433172495557684552967996478859896127711650849984146e-150630391 -> 0 +precision: 253 +comparetotal_eq17 comparetotal_eq +1384678513247367538385942433269265625400190754875E-357438088 -> 0 +precision: 101 +comparetotal_eq18 comparetotal_eq +84859581870254002326819092610960254621188154597905194220312e60785947 -> 0 +precision: 161 +comparetotal_eq19 comparetotal_eq -308691504716542199325069259101332601402222081328057497879628665241073542811853839386107229334350606742707231 -> 0 +precision: 204 +comparetotal_eq20 comparetotal_eq 2323395251698126837624275500346909376803797839576402645628745425783507893301316824840857368994e-358974030 -> 0 +precision: 41 +comparetotal_eq21 comparetotal_eq -1539316683112366155205E-306141337 -> 0 +precision: 265 +comparetotal_eq22 comparetotal_eq +Inf -> 0 +precision: 240 +comparetotal_eq23 comparetotal_eq 65660431867198327895984813239366242355925566099.8249504093 -> 0 +precision: 239 +comparetotal_eq24 comparetotal_eq +NaN95426130324013836829372489285384 -> 0 +precision: 138 +comparetotal_eq25 comparetotal_eq +9226862933823272238525523121537169520021744190878478222402215922328906799625007808566045211083097759351857976 -> 0 +precision: 25 +comparetotal_eq26 comparetotal_eq -203976422855E-424643559 -> 0 +precision: 140 +comparetotal_eq27 comparetotal_eq +Inf -> 0 +precision: 230 +comparetotal_eq28 comparetotal_eq 1684507779913004167040538483691332177958320548101419006793272913153083751817973461035071305306495516690230362427305.860040986789016539749886886164782188826619883923253211514960650441865991095447517135053 -> 0 +precision: 34 +comparetotal_eq29 comparetotal_eq -8956225701919633184514 -> 0 +precision: 87 +comparetotal_eq30 comparetotal_eq -79712539275966426244908074 -> 0 +precision: 25 +comparetotal_eq31 comparetotal_eq -2293.6 -> 0 +precision: 162 +comparetotal_eq32 comparetotal_eq -766371632277150743394633971154707100109240657037620916916637308098741854350933973 -> 0 +precision: 193 +comparetotal_eq33 comparetotal_eq .49258617682794966239719251415318456021079673970955370324256964091194138913316036373 -> 0 +precision: 111 +comparetotal_eq34 comparetotal_eq +25420056938045759278713024822597632359908063 -> 0 +precision: 154 +comparetotal_eq35 comparetotal_eq -5840960840830984347784120310482278912119941937220265966441278135936362 -> 0 +precision: 278 +comparetotal_eq36 comparetotal_eq +.96639830484533114195010430496461447034849244108043088176734470614686243285830258209332 -> 0 +precision: 235 +comparetotal_eq37 comparetotal_eq 609078831558529032357231613361636659161231641302280958182155568939673961288731174121447130638911132410478298871891093352545636582955778 -> 0 +precision: 148 +comparetotal_eq38 comparetotal_eq -492431992367754773794292859191445.75707689810540 -> 0 +precision: 152 +comparetotal_eq39 comparetotal_eq 7561355909241527088878491188609477610745.56913866984929236571987563254893811919073173009 -> 0 +precision: 193 +comparetotal_eq40 comparetotal_eq -97493232450091634024533754846117282879608499337334168603594097362055418324023043571440921960766696878459536651882558781266859634290784442567507200076666682 -> 0 +precision: 66 +comparetotal_eq41 comparetotal_eq 6323256972587367812099554833376066222 -> 0 +precision: 212 +comparetotal_eq42 comparetotal_eq -sNaN926217394308182462513194222805142330965398870390251415736522419 -> 0 +precision: 104 +comparetotal_eq43 comparetotal_eq -2924066411578004754670460010376603422457809677564301378945714E+228725290 -> 0 +precision: 221 +comparetotal_eq44 comparetotal_eq -sNaN72278471691941012585765495930850666349054 -> 0 +precision: 168 +comparetotal_eq45 comparetotal_eq +.72938982485106232415414696665038492709364301452992140 -> 0 +precision: 277 +comparetotal_eq46 comparetotal_eq -22098704582652736945471192619729714687018074157376422989502879209389543641043472913691539953723696853389102482357982355964356173574539813401016366920958455291440803568106903771503864 -> 0 +precision: 137 +comparetotal_eq47 comparetotal_eq 13761698928987.3117534779405790 -> 0 +precision: 218 +comparetotal_eq48 comparetotal_eq 1825092551599698804080668795452734416657433282476615071466652089127279932.57161502563813684832853759287015545841978477072074303259312494513928328499217689010083339592916333185803789411 -> 0 +precision: 62 +comparetotal_eq49 comparetotal_eq -sNaN98062353772402443881044971742534150634093809711501114434449121409989773439185630340922455 -> 0 +precision: 24 +comparetotal_eq50 comparetotal_eq -247 -> 0 +precision: 236 +comparetotal_eq51 comparetotal_eq +Infinity -> 0 +precision: 94 +comparetotal_eq52 comparetotal_eq -8706612392446856160472.23971555226 -> 0 +precision: 238 +comparetotal_eq53 comparetotal_eq -Inf -> 0 +precision: 113 +comparetotal_eq54 comparetotal_eq +54551202290261088647145812168868414947482481970450923380422170040735316593692916176673460638260927128 -> 0 +precision: 210 +comparetotal_eq55 comparetotal_eq -23392464704555833073333845747785043899918881228044989416745 -> 0 +precision: 75 +comparetotal_eq56 comparetotal_eq 5199079612634732927128915818763947707905235863932304759051692352380 -> 0 +precision: 71 +comparetotal_eq57 comparetotal_eq -41658558395 -> 0 +precision: 184 +comparetotal_eq58 comparetotal_eq -4905451675849454718192225946712026065208620927977571081231926543837430234603335787807912513755676844e-132315104 -> 0 +precision: 16 +comparetotal_eq59 comparetotal_eq +12980935747451 -> 0 +precision: 222 +comparetotal_eq60 comparetotal_eq -904310269323972185453804687265334252461135435 -> 0 +precision: 171 +comparetotal_eq61 comparetotal_eq +.13265163777084895000705951208680477910509456697936405162894082154219383112099637343513689070459 -> 0 +precision: 228 +comparetotal_eq62 comparetotal_eq -4661337311843780919273456335702781557558524784620266146060070705730805584862376476303516282248214878433633764223010581705801814025705604093630080705239048291927029355334.31807733785261284880500458858695400723E+178120485 -> 0 +precision: 9 +comparetotal_eq63 comparetotal_eq +713 -> 0 +precision: 243 +comparetotal_eq64 comparetotal_eq 6851722859863430703579216465147621767254669001174906.5848239331451825404461044 -> 0 +precision: 259 +comparetotal_eq65 comparetotal_eq +Inf -> 0 +precision: 194 +comparetotal_eq66 comparetotal_eq +Infinity -> 0 +precision: 187 +comparetotal_eq67 comparetotal_eq +4513619 -> 0 +precision: 137 +comparetotal_eq68 comparetotal_eq -5106697075729303473511829 -> 0 +precision: 66 +comparetotal_eq69 comparetotal_eq 5697586627112889837597481858528E-119520701 -> 0 +precision: 218 +comparetotal_eq70 comparetotal_eq -8651463308652248892998532242397472315383840375227251616774121511 -> 0 +precision: 44 +comparetotal_eq71 comparetotal_eq -0.95e-346395845 -> 0 +precision: 181 +comparetotal_eq72 comparetotal_eq -5504806518340895447721421314834288625084006686420266280149683604363743847003188557150256775994512651031656977572639102247717731742591432037631633265543079086114097094244E-252316798 -> 0 +precision: 70 +comparetotal_eq73 comparetotal_eq +3297800735741806144724070844056308651989.8195189445361340170 -> 0 +precision: 10 +comparetotal_eq74 comparetotal_eq 679.48293e357807815 -> 0 +precision: 127 +comparetotal_eq75 comparetotal_eq 537293600434066560272731611207861123E-54528486 -> 0 +precision: 245 +comparetotal_eq76 comparetotal_eq .341128186 -> 0 +precision: 71 +comparetotal_eq77 comparetotal_eq -116376141.9 -> 0 +precision: 5 +comparetotal_eq78 comparetotal_eq -25450 -> 0 +precision: 114 +comparetotal_eq79 comparetotal_eq -6156275624792929643867440115549636403963333307553031343670612158451755789577444e35642861 -> 0 +precision: 183 +comparetotal_eq80 comparetotal_eq 1436806528596721094903626504703250133609839635221562040328384374527759306314808759113699479834004752000528142 -> 0 +precision: 181 +comparetotal_eq81 comparetotal_eq -21882842429873859342811289020455405947295807297433524273.5033688681369572612689959612895523592269217943993881461958038309740663992250165 -> 0 +precision: 16 +comparetotal_eq82 comparetotal_eq +9104497E+151807076 -> 0 +precision: 88 +comparetotal_eq83 comparetotal_eq +78007340379140382503222146584230561293.6112041572340247811438098 -> 0 +precision: 156 +comparetotal_eq84 comparetotal_eq +29027728861723744.987930411887223347 -> 0 +precision: 55 +comparetotal_eq85 comparetotal_eq +.96407480400037326 -> 0 +precision: 154 +comparetotal_eq86 comparetotal_eq +65803825741020559688830869906427484228979e-211972109 -> 0 +precision: 250 +comparetotal_eq87 comparetotal_eq -.641101115445444382735173970445115273523256615609198145148927922338445262727389076631144187678080873779711150802134879655034822629872274567149949318442373926116664816829103814531433035751336957E-89566219 -> 0 +precision: 174 +comparetotal_eq88 comparetotal_eq -6411257720241023569725249883220203650598911781178552350512 -> 0 +precision: 80 +comparetotal_eq89 comparetotal_eq 79664590522408459087457305685717875175295539479013.9839536e+78085169 -> 0 +precision: 193 +comparetotal_eq90 comparetotal_eq +6431716598993424357379670542672958642624896904007690657231917E-32301189 -> 0 +precision: 134 +comparetotal_eq91 comparetotal_eq -7166075910839705669531272023962865308475807 -> 0 +precision: 129 +comparetotal_eq92 comparetotal_eq -6189266627381367415e+143265950 -> 0 +precision: 33 +comparetotal_eq93 comparetotal_eq 877743875606520142232012637658 -> 0 +precision: 296 +comparetotal_eq94 comparetotal_eq 81e-276983863 -> 0 +precision: 294 +comparetotal_eq95 comparetotal_eq +37990227712894018190245008555216423186177188774589232370547312654192878952827434840555479696803907037593108819308685706534637859453591754877110147238939108347755331645878543383812287278522111658280153264936058968155798527779026989303225033371699490579432216 -> 0 +precision: 163 +comparetotal_eq96 comparetotal_eq 44032 -> 0 +precision: 8 +comparetotal_eq97 comparetotal_eq Infinity -> 0 +precision: 290 +comparetotal_eq98 comparetotal_eq 97731522466945259125738531538118925073980868195733645959420939515288449102211831007042885860705615508898582478034856E196236986 -> 0 +precision: 9 +comparetotal_eq99 comparetotal_eq 3745E-366098382 -> 0 +precision: 254 +comparetotmag_eq0 comparetotmag_eq .758599241688130692588376356255616760550215971262736680716244497795320979910 -> 0 +precision: 111 +comparetotmag_eq1 comparetotmag_eq -.9680035 -> 0 +precision: 280 +comparetotmag_eq2 comparetotmag_eq -2978664146700401661050144467205502091778945285794943.5248293726490459289168834361170650892056840210562147124621253082638290597E+7322343 -> 0 +precision: 295 +comparetotmag_eq3 comparetotmag_eq 373073810351083847308492490954096527470990852948834396384108768226709606406334550611804149162380581619848100884564003356 -> 0 +precision: 154 +comparetotmag_eq4 comparetotmag_eq -135085990223239252869521315004690787363062113045882520688592861094582362232.55964478264515146118847138432934464225278618354764781084094e92097362 -> 0 +precision: 243 +comparetotmag_eq5 comparetotmag_eq -1120585765691099973098517057771041784915627514634982800943025329535288084063510001452857743185000682366687360090711916144882751214203633045047994315 -> 0 +precision: 110 +comparetotmag_eq6 comparetotmag_eq -.20986013404104445 -> 0 +precision: 61 +comparetotmag_eq7 comparetotmag_eq -132623430907907261480242121846759045719458101160804991841698e+137555302 -> 0 +precision: 189 +comparetotmag_eq8 comparetotmag_eq -.648067853225656977027614789502827 -> 0 +precision: 269 +comparetotmag_eq9 comparetotmag_eq 9045859255918240474189386605826358421406783106936386724841465300830461793246494305642676288639156880459745974039110790497439518275879018825694328134297921548322228683153608598436165303878673586307015843876744458212064725189171187795112144991950513531319187108946E357466168 -> 0 +precision: 11 +comparetotmag_eq10 comparetotmag_eq Infinity -> 0 +precision: 87 +comparetotmag_eq11 comparetotmag_eq -.566395295580511589782317514717704373645202839050284415466945646386797218341354193980482 -> 0 +precision: 243 +comparetotmag_eq12 comparetotmag_eq -124668041670319474801622709957866055808699098173829793598656287723081972262818475975608150477147475922020664948964116111683568298751080978937176489654649930812285344 -> 0 +precision: 278 +comparetotmag_eq13 comparetotmag_eq +97028962788304318465566675904657057818764168452694328913600937301641.1959 -> 0 +precision: 212 +comparetotmag_eq14 comparetotmag_eq -sNaN -> 0 +precision: 56 +comparetotmag_eq15 comparetotmag_eq 4383.754031837823371188245102 -> 0 +precision: 79 +comparetotmag_eq16 comparetotmag_eq +234942328155740.248917344733058641280365579285605765248299037985196039831755 -> 0 +precision: 249 +comparetotmag_eq17 comparetotmag_eq +.401719198135011875197940475930593041290481963182726261321731761677653679534094866070618897346798586493963537889847022987903115935359554110352729E307502114 -> 0 +precision: 151 +comparetotmag_eq18 comparetotmag_eq 6921450187264584739745876147764680320341.4174560759053687563289470476219096442911606343671248e189923536 -> 0 +precision: 39 +comparetotmag_eq19 comparetotmag_eq 9002690516378.52168050266097 -> 0 +precision: 91 +comparetotmag_eq20 comparetotmag_eq .663496894776070882688311537371 -> 0 +precision: 95 +comparetotmag_eq21 comparetotmag_eq 560062470258092620667281428698450214 -> 0 +precision: 77 +comparetotmag_eq22 comparetotmag_eq -0.2440E+271150960 -> 0 +precision: 217 +comparetotmag_eq23 comparetotmag_eq 173780887620216.10378226384665941189349 -> 0 +precision: 267 +comparetotmag_eq24 comparetotmag_eq 78230449298101544670042493593344496314553350195042268729345261790243785081385101271583765737474227275159585323320773885662468667519818859252260707490033363050325242288980817360068966775725142286459487068404096780654625219633934135953723359797985546299 -> 0 +precision: 226 +comparetotmag_eq25 comparetotmag_eq -.8205874202182345629002759547579312641404716080698336228400981809432098568638844459806005249323 -> 0 +precision: 97 +comparetotmag_eq26 comparetotmag_eq -645255.672557972731110565424678563646186829759532083400809122074405092887321026499 -> 0 +precision: 194 +comparetotmag_eq27 comparetotmag_eq 3092470339262364953567614029395040731734262949366979977206728754128988018295876990492005938624037794831987754236880957081143 -> 0 +precision: 29 +comparetotmag_eq28 comparetotmag_eq 57.E+143179950 -> 0 +precision: 39 +comparetotmag_eq29 comparetotmag_eq .3052 -> 0 +precision: 231 +comparetotmag_eq30 comparetotmag_eq -11523034296905256789870364631805639650738.8569872996432563014933434893670023802189700019E+331657066 -> 0 +precision: 277 +comparetotmag_eq31 comparetotmag_eq -90515524775419567419279770518554407320709327912893406738600436246462958441943655812062367507691060750753609866999314036367777685660204967220930504662997721388277483671062 -> 0 +precision: 285 +comparetotmag_eq32 comparetotmag_eq 6179140642361415325690186156693793.738730648425831193666593780858158061297770583e-284043812 -> 0 +precision: 293 +comparetotmag_eq33 comparetotmag_eq -12172088235619596465522772857578918098776186867553912568305660067671552271962396974216764816085888606529901044151946652845028927008893668958641199542780135016710856979823739224132381477734142547930675222150548736 -> 0 +precision: 176 +comparetotmag_eq34 comparetotmag_eq +Infinity -> 0 +precision: 255 +comparetotmag_eq35 comparetotmag_eq -Inf -> 0 +precision: 15 +comparetotmag_eq36 comparetotmag_eq -4122e+358531764 -> 0 +precision: 160 +comparetotmag_eq37 comparetotmag_eq +99209836347562423364397936968123504985538596349406640871062 -> 0 +precision: 294 +comparetotmag_eq38 comparetotmag_eq -6274600242410175354765985193668908297288007401220476982196317284223594634095415822680987536077051315546711553877665479455778433609317032076173704844621654218043672370668379691155574270173678230.628837963455285227 -> 0 +precision: 239 +comparetotmag_eq39 comparetotmag_eq -sNaN -> 0 +precision: 62 +comparetotmag_eq40 comparetotmag_eq +371.481520 -> 0 +precision: 41 +comparetotmag_eq41 comparetotmag_eq +76e-119165385 -> 0 +precision: 180 +comparetotmag_eq42 comparetotmag_eq +77636783519329095134842179123187271903894703114026946027324920910818395121805022852402e331721542 -> 0 +precision: 8 +comparetotmag_eq43 comparetotmag_eq -Inf -> 0 +precision: 10 +comparetotmag_eq44 comparetotmag_eq -sNaN258004357732449581097733994906900393084904087680886609307961895378612654084553567 -> 0 +precision: 132 +comparetotmag_eq45 comparetotmag_eq +27527580013485996476119702192322738.661301391490391550658742128695647022830523479E137235779 -> 0 +precision: 48 +comparetotmag_eq46 comparetotmag_eq 82485470817836937096244056 -> 0 +precision: 255 +comparetotmag_eq47 comparetotmag_eq -.4545240480666806992206593718235512911624170660928306647649435395532399656843703851738354664868752615029E-209728468 -> 0 +precision: 240 +comparetotmag_eq48 comparetotmag_eq 1931816872.57165251265451007697949828156045975602078460361600105127665167004424334625775351530702643686935081344072634256952928801848111459899389758378667453219890182379063046413635251740610287617 -> 0 +precision: 159 +comparetotmag_eq49 comparetotmag_eq -Inf -> 0 +precision: 194 +comparetotmag_eq50 comparetotmag_eq -3975066.722711992887449936887029840444361475429401656203490909900304013389842275149581694513982747764579266207914742801 -> 0 +precision: 21 +comparetotmag_eq51 comparetotmag_eq -10079.E-207809009 -> 0 +precision: 229 +comparetotmag_eq52 comparetotmag_eq 10200569899324830050599093453054850477748636453922703395142654674574.849e143375381 -> 0 +precision: 222 +comparetotmag_eq53 comparetotmag_eq +553244289317323190960679433857384003867933584946750514180364343937580712510433597776046547013163399668331676417693173398882560589706077783551097015199004622707168774145783728724551878153041861993173657722 -> 0 +precision: 11 +comparetotmag_eq54 comparetotmag_eq -.17431971258 -> 0 +precision: 196 +comparetotmag_eq55 comparetotmag_eq +5255264846971 -> 0 +precision: 211 +comparetotmag_eq56 comparetotmag_eq -645069289478657195831941675695427668936803813710466 -> 0 +precision: 124 +comparetotmag_eq57 comparetotmag_eq -402162222052349632206088624702767314901350802444258898821.96629303682647 -> 0 +precision: 144 +comparetotmag_eq58 comparetotmag_eq -60288765642662458273692255627283073203.7589 -> 0 +precision: 218 +comparetotmag_eq59 comparetotmag_eq +82723898737736981834833812214896018781760838.67504946419842838453506428526339147317460943437394773674445517765276393459455764643507819387056060221525427923304763086016362161663023960903374034798210858401594801E+139529995 -> 0 +precision: 192 +comparetotmag_eq60 comparetotmag_eq -86658459138938909877666041011301431806896078516385 -> 0 +precision: 14 +comparetotmag_eq61 comparetotmag_eq -38106288821. -> 0 +precision: 245 +comparetotmag_eq62 comparetotmag_eq +251921844373822431667748489929316186367893026227940323994511933330531523485294794.890401065351 -> 0 +precision: 60 +comparetotmag_eq63 comparetotmag_eq 25972806562266801.434808181024e-246852717 -> 0 +precision: 243 +comparetotmag_eq64 comparetotmag_eq -887789849375969853218594838098953417293035613559996425627759335308382047656042193874699493820358889353945264082255272206427387287584432443435408670109261041116740162148654680647174010551977335499655092893643654299464954618202 -> 0 +precision: 121 +comparetotmag_eq65 comparetotmag_eq +1542568744044564799567118813327510841041722742225085261417404285874912547648939539346136 -> 0 +precision: 188 +comparetotmag_eq66 comparetotmag_eq +2698968361205775284700858624261137332628173048875236239217930582962826113306018075561808521467294700562915343125335211998362707946715632629182e-397410055 -> 0 +precision: 70 +comparetotmag_eq67 comparetotmag_eq -116482885017708937489473298172566.222073881734104 -> 0 +precision: 152 +comparetotmag_eq68 comparetotmag_eq +30157549153434595985025934176650081461639551880222E-200363402 -> 0 +precision: 114 +comparetotmag_eq69 comparetotmag_eq -94703923470495586024544728165808807896295365391534080267139373949697385466386898755185862208179639361 -> 0 +precision: 76 +comparetotmag_eq70 comparetotmag_eq Infinity -> 0 +precision: 236 +comparetotmag_eq71 comparetotmag_eq +20260230733108105702624386091366857242323388992.939868104137 -> 0 +precision: 300 +comparetotmag_eq72 comparetotmag_eq -29884613642739544930876448336720158271878961415329808384938325673396839119328027317691672466662261565502902330423154954685183482466003069228343340646813836994765410617220891620839763419568456798 -> 0 +precision: 11 +comparetotmag_eq73 comparetotmag_eq +.79738543011 -> 0 +precision: 112 +comparetotmag_eq74 comparetotmag_eq -Inf -> 0 +precision: 245 +comparetotmag_eq75 comparetotmag_eq +5036207952123906386743813264143578961327.29965706349386738762075535729651808105564177474998772894655500517621948426388931367E224881858 -> 0 +precision: 282 +comparetotmag_eq76 comparetotmag_eq +9627449955373209306095691574757611661964370672475811730059058948050316783506426.7381276120263080515110222168916770315414667219220262242525966031941148759660478319471372558971380576037890381615879816695316871292127124795919219363077e-397864912 -> 0 +precision: 143 +comparetotmag_eq77 comparetotmag_eq -.6953443904663710213 -> 0 +precision: 123 +comparetotmag_eq78 comparetotmag_eq -37742640128075951679066e-244117593 -> 0 +precision: 51 +comparetotmag_eq79 comparetotmag_eq .628523014878458151264084 -> 0 +precision: 171 +comparetotmag_eq80 comparetotmag_eq -.11732018595304957201079694501893772565399000970421406226421725880802203756891058447116150922185710404961048139280008455072605042037318585585840659582798142314478 -> 0 +precision: 230 +comparetotmag_eq81 comparetotmag_eq 1505317821001976798286184626182370244052490460561843852848163310003323468347667238484049104997867911445879495887183069218095179974316877 -> 0 +precision: 71 +comparetotmag_eq82 comparetotmag_eq -.99067885648086185095001805782590965268489428603 -> 0 +precision: 199 +comparetotmag_eq83 comparetotmag_eq -8235459159320233496599885276748996091576894642494073280432387500160680585053232162018151093354587459918164280242221560392920133687603361923E145796403 -> 0 +precision: 280 +comparetotmag_eq84 comparetotmag_eq -18231024313180592685558827417860220978702289145263555466246215110628004200818802355562317.9167736707 -> 0 +precision: 94 +comparetotmag_eq85 comparetotmag_eq 5206800267882191048709543045275136397521137708870288 -> 0 +precision: 46 +comparetotmag_eq86 comparetotmag_eq 586873.28881E-124168073 -> 0 +precision: 108 +comparetotmag_eq87 comparetotmag_eq -.69649504379645759716805001407779641488692098118 -> 0 +precision: 220 +comparetotmag_eq88 comparetotmag_eq -580702524779324576511137546759334311502406788153544114659867030842917830314008995139893078957550013081066060455206847069836701891605018375640628137728358952189994176639437239192969376357e+158185780 -> 0 +precision: 170 +comparetotmag_eq89 comparetotmag_eq 4460768346307719818845307199772996288378412192228806517486662537420364224325750546920164455500014306349435992396838.12958335871954019311031365693280558060 -> 0 +precision: 168 +comparetotmag_eq90 comparetotmag_eq -1176136089459685495679203412653362621650257933937974391276027633752443768086155521325395556304613 -> 0 +precision: 40 +comparetotmag_eq91 comparetotmag_eq 62386449357005012e116467876 -> 0 +precision: 43 +comparetotmag_eq92 comparetotmag_eq -606281907e-39276360 -> 0 +precision: 216 +comparetotmag_eq93 comparetotmag_eq +.487947173448970699477755573313092304386603418905545870716639 -> 0 +precision: 43 +comparetotmag_eq94 comparetotmag_eq +800573993765079033838236 -> 0 +precision: 167 +comparetotmag_eq95 comparetotmag_eq -0.85368756569 -> 0 +precision: 91 +comparetotmag_eq96 comparetotmag_eq -NaN -> 0 +precision: 160 +comparetotmag_eq97 comparetotmag_eq +283289819409.8615540 -> 0 +precision: 79 +comparetotmag_eq98 comparetotmag_eq +7761234803627628382889163604124630400932418210247392910118158865538312807006 -> 0 +precision: 255 +comparetotmag_eq99 comparetotmag_eq sNaN -> 0 +precision: 241 +copysign_eq0 copysign_eq +912849910816424783962776495925326137570904169012007696206741038734E-113244462 -> 9.12849910816424783962776495925326137570904169012007696206741038734E-113244397 +precision: 211 +copysign_eq1 copysign_eq -4172999471644727956817324170469907724355.64974450632070660595561325662300620125198931687808841912359413473051980813682954009458996607 -> -4172999471644727956817324170469907724355.64974450632070660595561325662300620125198931687808841912359413473051980813682954009458996607 +precision: 120 +copysign_eq2 copysign_eq -Inf -> -Infinity +precision: 160 +copysign_eq3 copysign_eq -4077199659268756237260256542619435665987629416188900477748234273613039111e-222850925 -> -4.077199659268756237260256542619435665987629416188900477748234273613039111E-222850853 +precision: 244 +copysign_eq4 copysign_eq -120887661871195892572007431690 -> -120887661871195892572007431690 +precision: 297 +copysign_eq5 copysign_eq -34594668308569067809106512607033738577.833475575387314530658554737788428753440579519182667729987481822439547834620969655008944421852347487992137992930068301492426960534568537729535790546911988465956223429 -> -34594668308569067809106512607033738577.833475575387314530658554737788428753440579519182667729987481822439547834620969655008944421852347487992137992930068301492426960534568537729535790546911988465956223429 +precision: 248 +copysign_eq6 copysign_eq .644884437890644703514857542573232 -> 0.644884437890644703514857542573232 +precision: 106 +copysign_eq7 copysign_eq -.8968331380651131451130741639350893328917278913249552498835203308406112 -> -0.8968331380651131451130741639350893328917278913249552498835203308406112 +precision: 58 +copysign_eq8 copysign_eq Infinity -> Infinity +precision: 172 +copysign_eq9 copysign_eq -Infinity -> -Infinity +precision: 26 +copysign_eq10 copysign_eq -69734643e-193062181 -> -6.9734643E-193062174 +precision: 176 +copysign_eq11 copysign_eq +.40005077964360844604790423067969883599249477124226248244752857 -> 0.40005077964360844604790423067969883599249477124226248244752857 +precision: 81 +copysign_eq12 copysign_eq 68818748766527632480393586306372081912414253184621655649755714658701849352 -> 68818748766527632480393586306372081912414253184621655649755714658701849352 +precision: 36 +copysign_eq13 copysign_eq -827760e-303008524 -> -8.27760E-303008519 +precision: 171 +copysign_eq14 copysign_eq -.51472673604698927879358673904608604855401014039879864011921786465262552249594966126266188054E-62866316 -> -5.1472673604698927879358673904608604855401014039879864011921786465262552249594966126266188054E-62866317 +precision: 7 +copysign_eq15 copysign_eq -92 -> -92 +precision: 207 +copysign_eq16 copysign_eq -.8257883235651203903073605796686406369304920526546040255424913084863918822560531714907335433690033483663577422127040032017983707615122654955329893032316030175034415469549126779260753998070316570188e296583593 -> -8.257883235651203903073605796686406369304920526546040255424913084863918822560531714907335433690033483663577422127040032017983707615122654955329893032316030175034415469549126779260753998070316570188E+296583592 +precision: 165 +copysign_eq17 copysign_eq +795127893760870758881277969219733505281559157132196683561219486975246756080873662536969619165268079260 -> 795127893760870758881277969219733505281559157132196683561219486975246756080873662536969619165268079260 +precision: 42 +copysign_eq18 copysign_eq +8664634899443E-295811181 -> 8.664634899443E-295811169 +precision: 187 +copysign_eq19 copysign_eq +.86633371454 -> 0.86633371454 +precision: 3 +copysign_eq20 copysign_eq -51e414021278 -> -5.1E+414021279 +precision: 291 +copysign_eq21 copysign_eq +.73640768910035155043175015975248409287189976354883215487722767318530316439212449319025870084934185124452773776935663078128296767277423761220923680539650499643919491041296020146887072088646993677464986658781992562673199278496827 -> 0.73640768910035155043175015975248409287189976354883215487722767318530316439212449319025870084934185124452773776935663078128296767277423761220923680539650499643919491041296020146887072088646993677464986658781992562673199278496827 +precision: 294 +copysign_eq22 copysign_eq +66238977336323175258405329887607.4688684375671138394635 -> 66238977336323175258405329887607.4688684375671138394635 +precision: 99 +copysign_eq23 copysign_eq -9706005388566098702237829851886105443850716583076063658128733656537 -> -9706005388566098702237829851886105443850716583076063658128733656537 +precision: 34 +copysign_eq24 copysign_eq -NaN26714072432846552083190711068194605835365212862074369044699 -> -NaN26714072432846552083190711068194605835365212862074369044699 +precision: 297 +copysign_eq25 copysign_eq +1444631177890437751833138978079891110807252417672006058137776916747013332945952745849086784157257786852691893615818837449759516899493328502014077171876302510090644020209814e+228663091 -> 1.444631177890437751833138978079891110807252417672006058137776916747013332945952745849086784157257786852691893615818837449759516899493328502014077171876302510090644020209814E+228663262 +precision: 224 +copysign_eq26 copysign_eq 8756872358197145011503076267370326415749027427967971765036825467368789266879765167669527374051191090871376644186283860953859026704162157186390216102E+152494906 -> 8.756872358197145011503076267370326415749027427967971765036825467368789266879765167669527374051191090871376644186283860953859026704162157186390216102E+152495053 +precision: 20 +copysign_eq27 copysign_eq -95409400172429589239 -> -95409400172429589239 +precision: 287 +copysign_eq28 copysign_eq 44451245 -> 44451245 +precision: 64 +copysign_eq29 copysign_eq 87069e-197024248 -> 8.7069E-197024244 +precision: 294 +copysign_eq30 copysign_eq -91490776988288844281004273227639649748559382214791464172820579465608440973797360268043545943193682557256877.153945352203031004983709628619311521172E+36138865 -> -9.1490776988288844281004273227639649748559382214791464172820579465608440973797360268043545943193682557256877153945352203031004983709628619311521172E+36138971 +precision: 245 +copysign_eq31 copysign_eq -61253345745790146082356378249682833220470116955093184.160402301507069626663735194111348050099498909534706088602221084182115292672163917920862048742169331177187156592 -> -61253345745790146082356378249682833220470116955093184.160402301507069626663735194111348050099498909534706088602221084182115292672163917920862048742169331177187156592 +precision: 259 +copysign_eq32 copysign_eq 7557015985852138820968760902376161045767694984326547795741385.154563135497546100E18448436 -> 7.557015985852138820968760902376161045767694984326547795741385154563135497546100E+18448496 +precision: 44 +copysign_eq33 copysign_eq 2446739636984983317815760152982626579251621E-22064059 -> 2.446739636984983317815760152982626579251621E-22064017 +precision: 276 +copysign_eq34 copysign_eq +783706030678546.5729957761 -> 783706030678546.5729957761 +precision: 289 +copysign_eq35 copysign_eq 6550322914927484174665863728756987541082673935650443257110929 -> 6550322914927484174665863728756987541082673935650443257110929 +precision: 118 +copysign_eq36 copysign_eq -8384469036271302020033 -> -8384469036271302020033 +precision: 38 +copysign_eq37 copysign_eq -.905596447938310724517484948798770440 -> -0.905596447938310724517484948798770440 +precision: 96 +copysign_eq38 copysign_eq -633835.9498591171618397620216367326120312804374133843662099053 -> -633835.9498591171618397620216367326120312804374133843662099053 +precision: 100 +copysign_eq39 copysign_eq -45316454094282713193793313663290917447362835651730640999493591285811411363675169215 -> -45316454094282713193793313663290917447362835651730640999493591285811411363675169215 +precision: 47 +copysign_eq40 copysign_eq -5934505716529203624590813773011140.5029189256879e271431908 -> -5.9345057165292036245908137730111405029189256879E+271431941 +precision: 8 +copysign_eq41 copysign_eq +4233 -> 4233 +precision: 179 +copysign_eq42 copysign_eq +Inf -> Infinity +precision: 235 +copysign_eq43 copysign_eq -.8026518628958656320480277762542718247488409258836562277671379 -> -0.8026518628958656320480277762542718247488409258836562277671379 +precision: 8 +copysign_eq44 copysign_eq -Infinity -> -Infinity +precision: 81 +copysign_eq45 copysign_eq -155435472394140381e-331492010 -> -1.55435472394140381E-331491993 +precision: 58 +copysign_eq46 copysign_eq -2742063025234706e-124677414 -> -2.742063025234706E-124677399 +precision: 194 +copysign_eq47 copysign_eq Infinity -> Infinity +precision: 151 +copysign_eq48 copysign_eq -3076.414 -> -3076.414 +precision: 215 +copysign_eq49 copysign_eq -54903986486304064466403075346468319729401566923918723287008306578450300853217224275074413326128851202685101625573573940.44583713644215717635201400150254847090444728107832437126677626214287502 -> -54903986486304064466403075346468319729401566923918723287008306578450300853217224275074413326128851202685101625573573940.44583713644215717635201400150254847090444728107832437126677626214287502 +precision: 288 +copysign_eq50 copysign_eq +Infinity -> Infinity +precision: 40 +copysign_eq51 copysign_eq -63746.6920325064618262220659 -> -63746.6920325064618262220659 +precision: 28 +copysign_eq52 copysign_eq +60037301417642617712E+314405176 -> 6.0037301417642617712E+314405195 +precision: 243 +copysign_eq53 copysign_eq 44954302072535212005008365198258111335643113581706145226221729418076278119523835612300431558733194.60281373107722805681248852122120697444252693825904755823908254120878753982599971139215856237207550137077117083801903577057675566233497981439 -> 44954302072535212005008365198258111335643113581706145226221729418076278119523835612300431558733194.60281373107722805681248852122120697444252693825904755823908254120878753982599971139215856237207550137077117083801903577057675566233497981439 +precision: 80 +copysign_eq54 copysign_eq -59745.2596022109163881688669 -> -59745.2596022109163881688669 +precision: 72 +copysign_eq55 copysign_eq -5175.20039136928065299637389738531970334746406318954626328421102145024 -> -5175.20039136928065299637389738531970334746406318954626328421102145024 +precision: 138 +copysign_eq56 copysign_eq -8164290077736576 -> -8164290077736576 +precision: 144 +copysign_eq57 copysign_eq -925975316863216059914809728928435878342747311186654918782217009964941855230984468623325162944745.7282929068452782252948e178069539 -> -9.259753168632160599148097289284358783427473111866549187822170099649418552309844686233251629447457282929068452782252948E+178069634 +precision: 88 +copysign_eq58 copysign_eq -3755496225268124403053131000917916553139.660 -> -3755496225268124403053131000917916553139.660 +precision: 45 +copysign_eq59 copysign_eq -.1843943837918771963208967506464645456446E-351312522 -> -1.843943837918771963208967506464645456446E-351312523 +precision: 256 +copysign_eq60 copysign_eq +38063018493737556668111060177144569509969844523795708405760584235465403415062925772738156618120096828741854095364675760983323933127274509971098442433472418E+112960435 -> 3.8063018493737556668111060177144569509969844523795708405760584235465403415062925772738156618120096828741854095364675760983323933127274509971098442433472418E+112960589 +precision: 82 +copysign_eq61 copysign_eq 2.10464 -> 2.10464 +precision: 171 +copysign_eq62 copysign_eq +.353648743094555897881114634720361997191466570127345406599783015 -> 0.353648743094555897881114634720361997191466570127345406599783015 +precision: 181 +copysign_eq63 copysign_eq .876123855498551736011864560563868572477936837830531671096196230903793876249501554965957862473800812364839412325508554600325017595570094E132935073 -> 8.76123855498551736011864560563868572477936837830531671096196230903793876249501554965957862473800812364839412325508554600325017595570094E+132935072 +precision: 5 +copysign_eq64 copysign_eq 47.896 -> 47.896 +precision: 57 +copysign_eq65 copysign_eq -NaN -> -NaN +precision: 245 +copysign_eq66 copysign_eq -8880641688431096098426751713709056972393539357471147813953561588595535300427501136851395528026584030844449281563643199883422269918992481002034949115028025958192726235989085104078572630350340627959960155056085.6351892273092682863e-313403941 -> -8.8806416884310960984267517137090569723935393574711478139535615885955353004275011368513955280265840308444492815636431998834222699189924810020349491150280259581927262359890851040785726303503406279599601550560856351892273092682863E-313403734 +precision: 289 +copysign_eq67 copysign_eq -6568252072712.434465979001 -> -6568252072712.434465979001 +precision: 28 +copysign_eq68 copysign_eq +264174 -> 264174 +precision: 239 +copysign_eq69 copysign_eq +.761355904532995600367657792932288441804234566256584874261263934566363378161675965 -> 0.761355904532995600367657792932288441804234566256584874261263934566363378161675965 +precision: 7 +copysign_eq70 copysign_eq +79 -> 79 +precision: 77 +copysign_eq71 copysign_eq 35796142963750491966821448715208186307325780428336899e+308821427 -> 3.5796142963750491966821448715208186307325780428336899E+308821479 +precision: 39 +copysign_eq72 copysign_eq -2.895 -> -2.895 +precision: 283 +copysign_eq73 copysign_eq Inf -> Infinity +precision: 206 +copysign_eq74 copysign_eq +21223726399.1862025101E-412571479 -> 2.12237263991862025101E-412571469 +precision: 272 +copysign_eq75 copysign_eq -14609896731410240465847146776510 -> -14609896731410240465847146776510 +precision: 70 +copysign_eq76 copysign_eq -909262394393264314832651149149512319844.98907157648321734664640604 -> -909262394393264314832651149149512319844.98907157648321734664640604 +precision: 108 +copysign_eq77 copysign_eq -9560885559796837570931059522730522635 -> -9560885559796837570931059522730522635 +precision: 80 +copysign_eq78 copysign_eq -63020099277467465011390.64 -> -63020099277467465011390.64 +precision: 85 +copysign_eq79 copysign_eq -74.51 -> -74.51 +precision: 160 +copysign_eq80 copysign_eq +970124494627917430165803986650936.93767717 -> 970124494627917430165803986650936.93767717 +precision: 258 +copysign_eq81 copysign_eq -67071158450214361034329987185418147961066306271075974531965006043987810791805423363365212685205640814030310537198311705119 -> -67071158450214361034329987185418147961066306271075974531965006043987810791805423363365212685205640814030310537198311705119 +precision: 12 +copysign_eq82 copysign_eq +6.9938E-269174750 -> 6.9938E-269174750 +precision: 20 +copysign_eq83 copysign_eq -739.4 -> -739.4 +precision: 263 +copysign_eq84 copysign_eq +80458928999489219593795861637209983647531900448E-285757632 -> 8.0458928999489219593795861637209983647531900448E-285757586 +precision: 252 +copysign_eq85 copysign_eq -.943146313695692482085431358850768490676790619479323125473369600983527313464567775159767199136799046416392453409767388138641759176155142355073397521065530361364279282707376381898914116491221347274439694234079703553404586824873174784027737864553E-249520272 -> -9.43146313695692482085431358850768490676790619479323125473369600983527313464567775159767199136799046416392453409767388138641759176155142355073397521065530361364279282707376381898914116491221347274439694234079703553404586824873174784027737864553E-249520273 +precision: 19 +copysign_eq86 copysign_eq 2581989035.14589421 -> 2581989035.14589421 +precision: 177 +copysign_eq87 copysign_eq 862110863918676915038913845144452992327358158529330002571726511830207810741719701085082372 -> 862110863918676915038913845144452992327358158529330002571726511830207810741719701085082372 +precision: 68 +copysign_eq88 copysign_eq +67558387757344553075202840915053.989850564148016169845932560039922371 -> 67558387757344553075202840915053.989850564148016169845932560039922371 +precision: 93 +copysign_eq89 copysign_eq -Inf -> -Infinity +precision: 78 +copysign_eq90 copysign_eq -NaN703219585659222470144078690320919791326760950751 -> -NaN703219585659222470144078690320919791326760950751 +precision: 154 +copysign_eq91 copysign_eq -.29452057074837704902232627615653162767335324872037 -> -0.29452057074837704902232627615653162767335324872037 +precision: 9 +copysign_eq92 copysign_eq -Infinity -> -Infinity +precision: 277 +copysign_eq93 copysign_eq -4346942020604226.7554599261567839779094124098257536258920625972951946463849271776713086 -> -4346942020604226.7554599261567839779094124098257536258920625972951946463849271776713086 +precision: 220 +copysign_eq94 copysign_eq .734759197189807569535777711189738297775385226367756552809155424103813447208285759123412438993939677605813235448392602103137976560723964823903240454 -> 0.734759197189807569535777711189738297775385226367756552809155424103813447208285759123412438993939677605813235448392602103137976560723964823903240454 +precision: 205 +copysign_eq95 copysign_eq -21588602070488075367780849611453796003902050727910781.50291200834737493945012277562858844628654049 -> -21588602070488075367780849611453796003902050727910781.50291200834737493945012277562858844628654049 +precision: 135 +copysign_eq96 copysign_eq -.1108621370656874460039116718332511971544303525855597496500788218945082036415e-393133591 -> -1.108621370656874460039116718332511971544303525855597496500788218945082036415E-393133592 +precision: 209 +copysign_eq97 copysign_eq -4192879427696548638281185597786601766594501050575758008859053447167394245205556438137052004020299359326549562277816404818778578146528497013072238419082115791548670681517743171393878948450.8E+355842331 -> -4.1928794276965486382811855977866017665945010505757580088590534471673942452055564381370520040202993593265495622778164048187785781465284970130722384190821157915486706815177431713938789484508E+355842517 +precision: 78 +copysign_eq98 copysign_eq -713457029083041e-73084822 -> -7.13457029083041E-73084808 +precision: 118 +copysign_eq99 copysign_eq -NaN73645398132195864554900320178027488320088359260627968 -> -NaN73645398132195864554900320178027488320088359260627968 +precision: 101 +divide_eq0 divide_eq -Infinity -> NaN Invalid_operation +precision: 245 +divide_eq1 divide_eq Inf -> NaN Invalid_operation +precision: 110 +divide_eq2 divide_eq -.1476808094725729904095250393485863450763071588976156608004151488204454583149499119086353485308969531e-190874140 -> 1 +precision: 252 +divide_eq3 divide_eq -720139078.7030741104805598019890857679520254017138520961247740866753962780770298439853312381187097077639434494159265440701085632001205589332889414225671314382822069 -> 1 +precision: 199 +divide_eq4 divide_eq -.11423548642039778502853331752699438267880556546060947088900423118459e+136020058 -> 1 +precision: 166 +divide_eq5 divide_eq -Inf -> NaN Invalid_operation +precision: 292 +divide_eq6 divide_eq +57566049327259003 -> 1 +precision: 251 +divide_eq7 divide_eq +9049630897567687826736795538426391297e+136212546 -> 1 +precision: 192 +divide_eq8 divide_eq -20855240434763808890488997795553145644765618694284843107013201034649712050079864080577203494538403684650909889345923214.67401532096608857894045837940385205173579226224086590632078120 -> 1 +precision: 298 +divide_eq9 divide_eq .37845592841851474968276142406962568088880599228852907860357259347451055126118792311 -> 1 +precision: 21 +divide_eq10 divide_eq +756589178925911 -> 1 +precision: 253 +divide_eq11 divide_eq +7616540366726289115759482592801393120310510772984495372247478374918334808998133936134691051600873016564865838467138722091889339721855392169064002992883960439547496411674481.6 -> 1 +precision: 152 +divide_eq12 divide_eq -132464569570673129946108463534952339491361707317524150518897310780087454591671438746372034616705624542012933 -> 1 +precision: 199 +divide_eq13 divide_eq +97295483E69909190 -> 1 +precision: 40 +divide_eq14 divide_eq +16125239727365 -> 1 +precision: 285 +divide_eq15 divide_eq -558912397953805315990901700479302738487872408100224141554032211770060719956670370528357559747385688199453070310642436380872070224846959709862988028030172431889225382997421018958990515641631009043170243901962980389765418921328936769632046245994333949554620532625631437368335 -> 1 +precision: 196 +divide_eq16 divide_eq -581760502091189143431438830346977643468801664263826568776486515235354179191847127022864144411030425924 -> 1 +precision: 171 +divide_eq17 divide_eq Inf -> NaN Invalid_operation +precision: 170 +divide_eq18 divide_eq -57102093068241152366346390834968936561555141453709797113707686008461567265330157104573628277415130 -> 1 +precision: 55 +divide_eq19 divide_eq Inf -> NaN Invalid_operation +precision: 164 +divide_eq20 divide_eq +4933541562001816173660814944425102570689578246623106270773884779497866838635610084037716084760670166505219125910520748434625908599105928077183742147 -> 1 +precision: 263 +divide_eq21 divide_eq 780978739001821784651187055095281139871139144514794451667397831088125667013225075092319109815638757980986767938413567745249111066203822578617871443e+172242403 -> 1 +precision: 24 +divide_eq22 divide_eq -669. -> 1 +precision: 139 +divide_eq23 divide_eq -929026873425924449762295114437344056295088895586400717575061122531902368317373.61379 -> 1 +precision: 28 +divide_eq24 divide_eq 32004438.936296670e-388597605 -> 1 +precision: 97 +divide_eq25 divide_eq +685192356940609723816549351427584811512414782271930939 -> 1 +precision: 15 +divide_eq26 divide_eq +24.4 -> 1 +precision: 264 +divide_eq27 divide_eq -76399839137E-312835605 -> 1 +precision: 166 +divide_eq28 divide_eq +286785230408511189389946035072752552272281497439131116949467362921468915707467195901118328632109569893657252024426064460.8 -> 1 +precision: 285 +divide_eq29 divide_eq -156241995206772934084790541418216073206584870776651480411244245887140889823336601575165267249785697487604122261756039 -> 1 +precision: 213 +divide_eq30 divide_eq -18835613161.85875029301502894096673156458933709200124152477782829434405710251917 -> 1 +precision: 208 +divide_eq31 divide_eq +329503882648611474548629054404411878016829780451326673892970516426794656022912026336043853586758662189289385178796276205400609e-24954863 -> 1 +precision: 68 +divide_eq32 divide_eq -642490193725470129122985393648821604455340877964136 -> 1 +precision: 119 +divide_eq33 divide_eq .1213548802720209817457722469194878972433909233797509 -> 1 +precision: 243 +divide_eq34 divide_eq 88390530580202114893633750458552868273412491465.9653514770700 -> 1 +precision: 12 +divide_eq35 divide_eq 1202980602 -> 1 +precision: 95 +divide_eq36 divide_eq -622432682603042167229028927214099123615e+146590683 -> 1 +precision: 234 +divide_eq37 divide_eq -623685917512840505914725819957208408206512955209119450474903177962467.583807976443798750174844935878748577333589070537241247780392426342246659540059980535170984627883840223725460416803667310116204649587839889122149720871 -> 1 +precision: 70 +divide_eq38 divide_eq +307778499491228339010454626807 -> 1 +precision: 24 +divide_eq39 divide_eq -337901622398684.912979 -> 1 +precision: 213 +divide_eq40 divide_eq 712917884.16171091010393155094288085619923697401198341672010183202041106677130168595980396078140846159780896802775036224934370341322361624E+293973671 -> 1 +precision: 294 +divide_eq41 divide_eq -.3274166911418925254250867444878322152615492228251384507549600134687882983374230329357978235008472416506241930093329341487797874986 -> 1 +precision: 48 +divide_eq42 divide_eq -8263521225725846856681077276094893285576261764 -> 1 +precision: 98 +divide_eq43 divide_eq -91057156340472810571826299969430.30620840013880692959175821E-174986185 -> 1 +precision: 23 +divide_eq44 divide_eq -2.e-411141805 -> 1 +precision: 269 +divide_eq45 divide_eq -845141104644763813738850543179104306995361345173618975906028394090238434137826994961014599912709940817914874809854538221832860989281789090938874879129894476815895991550922865065693207755622009091262775678759898 -> 1 +precision: 283 +divide_eq46 divide_eq -5970255057265614965706607283227776119878517813823118844571266884633952649951183994e-392072151 -> 1 +precision: 31 +divide_eq47 divide_eq -1477080315892761879414599E-346711596 -> 1 +precision: 121 +divide_eq48 divide_eq +86165608170213766602.94134869873594684357724094010230038522061903e-183189626 -> 1 +precision: 199 +divide_eq49 divide_eq -711145549607361830875332328381399788166622564159900.51874082473364669851276652848717E+342044570 -> 1 +precision: 294 +divide_eq50 divide_eq -64450169407069787262103392E76952379 -> 1 +precision: 287 +divide_eq51 divide_eq -90184055520871121698254013571145836444773758648611909 -> 1 +precision: 91 +divide_eq52 divide_eq +6603936296659210086718274400236401200188918056620726611241032.810056 -> 1 +precision: 109 +divide_eq53 divide_eq -8909511328776956796073380205763245742260036040182232805865312603009832060830535281798471351184237 -> 1 +precision: 13 +divide_eq54 divide_eq -56199499 -> 1 +precision: 144 +divide_eq55 divide_eq -267655574e-338719954 -> 1 +precision: 18 +divide_eq56 divide_eq 273837873296020.6e-405686955 -> 1 +precision: 201 +divide_eq57 divide_eq -56929515351505776318208129824525130348917134735034916419394700417605978810461536030019272932090671039700604275289853600484594104342438355523803882253313369404757230918341167057021843E407971284 -> 1 +precision: 192 +divide_eq58 divide_eq +13643852775841014921914835623339788973293544009829640956625028574220654641017020473004526206545e-128059292 -> 1 +precision: 234 +divide_eq59 divide_eq 58799228727009310372528109784658383378303035378522080974337590565283047704780E-192434611 -> 1 +precision: 286 +divide_eq60 divide_eq -166472392467877011168252287.71314609218861339244103788374161096476551943678752281727454808068261357535714773332203907202680750485159686496109690833436573258649837840230186318272253915612405029202994851701283208155988214057879124551751337704149435037248282354727029656271611485793059e-29946188 -> 1 +precision: 240 +divide_eq61 divide_eq -888279360979847835372608590812249939937380776052207856364486893324054001511384417846141562527664481222127963121518087254331437123223476884356595902748226934885912129900564029441423621784532048357586E260225656 -> 1 +precision: 180 +divide_eq62 divide_eq -62.7E-86593580 -> 1 +precision: 110 +divide_eq63 divide_eq -Infinity -> NaN Invalid_operation +precision: 217 +divide_eq64 divide_eq +70754612337129752247973555873491063051430174522261007741319032411562791790827763202539570787528083242885556878553538287488e-74868643 -> 1 +precision: 70 +divide_eq65 divide_eq 1101950788010535E-362477493 -> 1 +precision: 39 +divide_eq66 divide_eq +98308 -> 1 +precision: 62 +divide_eq67 divide_eq 31733412607673.128977400104734019098693401832113 -> 1 +precision: 45 +divide_eq68 divide_eq 7.10105853563856 -> 1 +precision: 207 +divide_eq69 divide_eq +675752852781401543055974814670904049316.8654094126562639791610710442e-145757722 -> 1 +precision: 241 +divide_eq70 divide_eq -4450487237728532937.933231 -> 1 +precision: 47 +divide_eq71 divide_eq -61411634909188873 -> 1 +precision: 100 +divide_eq72 divide_eq -626176102238052754 -> 1 +precision: 297 +divide_eq73 divide_eq -22247593796.5012386878556 -> 1 +precision: 50 +divide_eq74 divide_eq Infinity -> NaN Invalid_operation +precision: 188 +divide_eq75 divide_eq +Infinity -> NaN Invalid_operation +precision: 218 +divide_eq76 divide_eq .60790809857379948768881880713460478086089024585645948799639746721516532020406815043420 -> 1 +precision: 104 +divide_eq77 divide_eq -3254165926721719071401463323692639728745870336031849554799508573339804772298352700812.1222415863576 -> 1 +precision: 118 +divide_eq78 divide_eq -83586027649668501381211209989.44413637926882821730E-289951920 -> 1 +precision: 88 +divide_eq79 divide_eq -778570662317039247646 -> 1 +precision: 240 +divide_eq80 divide_eq 620326677397240.850653812628717127618781977887725260304574302740635134337953478311367 -> 1 +precision: 159 +divide_eq81 divide_eq 5551883711060673923753975456747036 -> 1 +precision: 85 +divide_eq82 divide_eq -16190268238164312872356E143566390 -> 1 +precision: 78 +divide_eq83 divide_eq 81154818347518765537255545758243358694575703847736449901270406 -> 1 +precision: 155 +divide_eq84 divide_eq 355337e+284096276 -> 1 +precision: 270 +divide_eq85 divide_eq 7776158154478 -> 1 +precision: 11 +divide_eq86 divide_eq +46.7501 -> 1 +precision: 72 +divide_eq87 divide_eq -53333221565567759554114159498175163529063463758998569160209746321107E-151636004 -> 1 +precision: 295 +divide_eq88 divide_eq +855.55590520063727890779471997433604933429094232004702426385204730260552951829031931901328048264311000526138587859537382229563852264035973356851333978007448964542800066405850229041474808134084696345 -> 1 +precision: 211 +divide_eq89 divide_eq 672745818294864853476261239748209013136324902029245074291428054800276.35383015557432509866443921 -> 1 +precision: 139 +divide_eq90 divide_eq Inf -> NaN Invalid_operation +precision: 182 +divide_eq91 divide_eq -4910043781384861625190274087609084183424764003136029037441096538943948e249027855 -> 1 +precision: 65 +divide_eq92 divide_eq -415916.87217038152248167615003069e-283790548 -> 1 +precision: 265 +divide_eq93 divide_eq +3485778597372958298.98380318471 -> 1 +precision: 112 +divide_eq94 divide_eq -8616887700305395591016141454363938602556599540120895444357409442326130 -> 1 +precision: 246 +divide_eq95 divide_eq +1982799473361129571751244021744791301677731717665778559164756048438636929326418202415376242630399459755098090613246847 -> 1 +precision: 242 +divide_eq96 divide_eq .473970053984103201091652943216177553884386460012308008589725012515469116148195995185557562847667970300402376038790875544508464804678193114512052980263341053940619 -> 1 +precision: 127 +divide_eq97 divide_eq -.240557624603898147566832979637761107201 -> 1 +precision: 15 +divide_eq98 divide_eq -3803013943816 -> 1 +precision: 191 +divide_eq99 divide_eq -8189 -> 1 +precision: 244 +divideint_eq0 divideint_eq -2908370616319578312063941557274194851663041095277377748986724480242388302053977204812657908848362009053864590869125163078562875951481531607893722343701113669128151095333657285531106914454e+70628990 -> 1 +precision: 146 +divideint_eq1 divideint_eq -1256574716053067901997983102369440625154437304394877782 -> 1 +precision: 48 +divideint_eq2 divideint_eq -.548918 -> 1 +precision: 155 +divideint_eq3 divideint_eq 32033489823530180352278187856323894032970304484771521282 -> 1 +precision: 12 +divideint_eq4 divideint_eq +247 -> 1 +precision: 290 +divideint_eq5 divideint_eq sNaN738420135455820970672439082041 -> NaN738420135455820970672439082041 Invalid_operation +precision: 154 +divideint_eq6 divideint_eq -.88564365385881011147819297802214956637652639618629 -> 1 +precision: 216 +divideint_eq7 divideint_eq -9884933188567325553.77519905302476176408714388097345911E78908392 -> 1 +precision: 205 +divideint_eq8 divideint_eq -5350396155712467491 -> 1 +precision: 234 +divideint_eq9 divideint_eq +6004358545820654718334648210758559991824860952390138598137690580139579473495934597594525805129685369437231986616808441371264778276324910307676711146650002546604936039388892971395984365602782E-199272347 -> 1 +precision: 82 +divideint_eq10 divideint_eq -443736763339300096531.99077517853669822 -> 1 +precision: 87 +divideint_eq11 divideint_eq Infinity -> NaN Invalid_operation +precision: 52 +divideint_eq12 divideint_eq +370695164030916.81799222 -> 1 +precision: 237 +divideint_eq13 divideint_eq NaN8481 -> NaN8481 +precision: 222 +divideint_eq14 divideint_eq 82238825985885512360657.2193113351280794952782825424364332055449866184869603877069771701448761430244616977832957549588845178699507856839E160927102 -> 1 +precision: 184 +divideint_eq15 divideint_eq -1202185937853107090293318245928017185131634933099973941340860888519320536829854521269204353763041931948598706911101644704568386327501811436624630721279906422089114399737446E-285606062 -> 1 +precision: 212 +divideint_eq16 divideint_eq -8999 -> 1 +precision: 132 +divideint_eq17 divideint_eq -13264787870372981492769808151945677174137786452679797229576746419058916024e157878286 -> 1 +precision: 2 +divideint_eq18 divideint_eq 3.6 -> 1 +precision: 60 +divideint_eq19 divideint_eq -1258030159714393.5880857539836422313 -> 1 +precision: 176 +divideint_eq20 divideint_eq 52842529310334863950155288548647656600941538583676136431851411817224865117107058305426027141486412102503702646996254719559538864045123297309580612856661100544955 -> 1 +precision: 169 +divideint_eq21 divideint_eq -597098254464732797344863769410517742685082451098117201998335217751815839395991669907927666850 -> 1 +precision: 21 +divideint_eq22 divideint_eq -.955 -> 1 +precision: 221 +divideint_eq23 divideint_eq -Infinity -> NaN Invalid_operation +precision: 8 +divideint_eq24 divideint_eq +NaN -> NaN +precision: 35 +divideint_eq25 divideint_eq -504981104763665254793727130766237 -> 1 +precision: 188 +divideint_eq26 divideint_eq +928252263160018659536867470102178541255281990402081126496025623238266017805407059555810456186962650736373263418301045526946196313651944537240367412459730411665e-314943780 -> 1 +precision: 135 +divideint_eq27 divideint_eq -sNaN57618544980879995812520729112652122135666362935014001 -> -NaN57618544980879995812520729112652122135666362935014001 Invalid_operation +precision: 55 +divideint_eq28 divideint_eq -49.e-243945635 -> 1 +precision: 24 +divideint_eq29 divideint_eq 543948.1 -> 1 +precision: 35 +divideint_eq30 divideint_eq -68144748254307118885948690E-323697561 -> 1 +precision: 224 +divideint_eq31 divideint_eq sNaN -> NaN Invalid_operation +precision: 276 +divideint_eq32 divideint_eq -8700868367695844338608077858640024559476621310905162076.243575 -> 1 +precision: 100 +divideint_eq33 divideint_eq -273776598077639196306582616387076661209470441299194130996003e-380514960 -> 1 +precision: 72 +divideint_eq34 divideint_eq -806694729211834.97e+204513402 -> 1 +precision: 237 +divideint_eq35 divideint_eq 976018181126506514567133304986460821711165181527654155891264929380451247300975330881111222125949477347065225571806643998108168622938882 -> 1 +precision: 198 +divideint_eq36 divideint_eq -3351153694033693759143552550759684667114200537887889741171670355062477664768135976 -> 1 +precision: 238 +divideint_eq37 divideint_eq -3811106476587934406189323754079849409380066844337492094738040348142839403251075078530745298644255385345345658193608088868567091795633769296358758713994618933453150 -> 1 +precision: 115 +divideint_eq38 divideint_eq -Inf -> NaN Invalid_operation +precision: 143 +divideint_eq39 divideint_eq 752360514372561842392306793359076119859331657991649031514096188375489213269728895855175 -> 1 +precision: 23 +divideint_eq40 divideint_eq -65826272684087e-189901812 -> 1 +precision: 154 +divideint_eq41 divideint_eq -Inf -> NaN Invalid_operation +precision: 145 +divideint_eq42 divideint_eq 9346756156957516795187377095629312073.68927595314817464361343166122628317396293984682878750749652397464184586575e+179318302 -> 1 +precision: 58 +divideint_eq43 divideint_eq -973420415713792696322214 -> 1 +precision: 189 +divideint_eq44 divideint_eq +47114247859996370684107328823566468584346444259104557331421540571100826509821427029368337493105070748869227331098707021690114584178883249327040053324543807385e+197976057 -> 1 +precision: 220 +divideint_eq45 divideint_eq 41629229434806566772235264186616210626738601961827509191888976253174197349572153258105167005453982350268197650983486410981435964014763197868093451880600821296275337419 -> 1 +precision: 203 +divideint_eq46 divideint_eq +580558304844.3971143541089941118037763511616825368650185111033112445359667375539943802771118327409918494034519551505664614756280251364425538993191916175432 -> 1 +precision: 18 +divideint_eq47 divideint_eq -366827704880521e401217436 -> 1 +precision: 97 +divideint_eq48 divideint_eq 88969.849992380750633496e-138384568 -> 1 +precision: 49 +divideint_eq49 divideint_eq -445632069169299394.997270791006185987654891276617 -> 1 +precision: 47 +divideint_eq50 divideint_eq -357177784109492555223519860538873611 -> 1 +precision: 178 +divideint_eq51 divideint_eq -48130418374141952724895846775742663246225122130321759930546932.18959 -> 1 +precision: 206 +divideint_eq52 divideint_eq +83680520978925049.525750755001819649412145135139113066968813355339220784940918687346191750285652758560968743324817575795007386787930804589e-348572820 -> 1 +precision: 43 +divideint_eq53 divideint_eq -49546005227034532863459820331039E-111851760 -> 1 +precision: 87 +divideint_eq54 divideint_eq -.409020013460156742400503188502042913565621425625241744231110494489182996035732 -> 1 +precision: 178 +divideint_eq55 divideint_eq -sNaN -> -NaN Invalid_operation +precision: 51 +divideint_eq56 divideint_eq 167739739308336337299604868E-167615854 -> 1 +precision: 220 +divideint_eq57 divideint_eq -5300924390991611325843577898308932510583029979720544901227984758608363165247154935394674245504898222957637889493955194995842619467356519270 -> 1 +precision: 52 +divideint_eq58 divideint_eq -42651184065238845325304233737813712812 -> 1 +precision: 160 +divideint_eq59 divideint_eq +Inf -> NaN Invalid_operation +precision: 296 +divideint_eq60 divideint_eq +95430223596390508793159877962590069515961834544.6494147401442188720362424000640936757021492011291255745625035788820000915581847243524343038266669934538108614005420466638827705495042289164326067136339396157449e-407784882 -> 1 +precision: 255 +divideint_eq61 divideint_eq -121410613239230278911368994469581498390989145061325120418293384741884952420202154199990781814331376978964064149553438076434112399733295955837885246553638214847379464843337620114E273623794 -> 1 +precision: 275 +divideint_eq62 divideint_eq -187563482316330537787159E-112385481 -> 1 +precision: 110 +divideint_eq63 divideint_eq +21515317087206151725444363496466671364497643357513607420052655.821902302251545278495192674529458969113592533 -> 1 +precision: 213 +divideint_eq64 divideint_eq -1886987509176720549221042721476020002574865555172260813975013733194E+24574208 -> 1 +precision: 189 +divideint_eq65 divideint_eq +28687311737550585944.4177e-33505340 -> 1 +precision: 236 +divideint_eq66 divideint_eq +5006675062343712217596493479021890779566957551625846964589963890609148614541390157258076880316846645663302760804622389184180006899273308957713918674683004665350029 -> 1 +precision: 126 +divideint_eq67 divideint_eq +6815719732515474416961007346323602899979093543072955946681395720331.125314412873076067000567297869 -> 1 +precision: 21 +divideint_eq68 divideint_eq -.792 -> 1 +precision: 281 +divideint_eq69 divideint_eq -.8383348825282366989534716394521356066079031392274329051537498369e182940300 -> 1 +precision: 177 +divideint_eq70 divideint_eq -533418438307368782835414547018323522458181065714916485951533133837656607133903494697352e+216617247 -> 1 +precision: 276 +divideint_eq71 divideint_eq -837478756121790407162.36186256535813229581475852017787150119955838740997259230e-214314979 -> 1 +precision: 80 +divideint_eq72 divideint_eq -51095903532848.94133284549122562773070 -> 1 +precision: 209 +divideint_eq73 divideint_eq -3.3015189510722583289122955034E398579675 -> 1 +precision: 153 +divideint_eq74 divideint_eq -35742507729436918675061614674503020 -> 1 +precision: 28 +divideint_eq75 divideint_eq 56.32623636404638934 -> 1 +precision: 35 +divideint_eq76 divideint_eq +Infinity -> NaN Invalid_operation +