ยปCore Development>Code coverage>Modules/_decimal/tests/randdec.py

Python code coverage for Modules/_decimal/tests/randdec.py

#countcontent
1n/a#
2n/a# Copyright (c) 2008-2012 Stefan Krah. All rights reserved.
3n/a#
4n/a# Redistribution and use in source and binary forms, with or without
5n/a# modification, are permitted provided that the following conditions
6n/a# are met:
7n/a#
8n/a# 1. Redistributions of source code must retain the above copyright
9n/a# notice, this list of conditions and the following disclaimer.
10n/a#
11n/a# 2. Redistributions in binary form must reproduce the above copyright
12n/a# notice, this list of conditions and the following disclaimer in the
13n/a# documentation and/or other materials provided with the distribution.
14n/a#
15n/a# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
16n/a# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17n/a# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18n/a# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19n/a# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20n/a# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21n/a# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22n/a# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23n/a# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24n/a# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25n/a# SUCH DAMAGE.
26n/a#
27n/a
28n/a
29n/a# Generate test cases for deccheck.py.
30n/a
31n/a
32n/a#
33n/a# Grammar from http://speleotrove.com/decimal/daconvs.html
34n/a#
35n/a# sign ::= '+' | '-'
36n/a# digit ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' |
37n/a# '8' | '9'
38n/a# indicator ::= 'e' | 'E'
39n/a# digits ::= digit [digit]...
40n/a# decimal-part ::= digits '.' [digits] | ['.'] digits
41n/a# exponent-part ::= indicator [sign] digits
42n/a# infinity ::= 'Infinity' | 'Inf'
43n/a# nan ::= 'NaN' [digits] | 'sNaN' [digits]
44n/a# numeric-value ::= decimal-part [exponent-part] | infinity
45n/a# numeric-string ::= [sign] numeric-value | [sign] nan
46n/a#
47n/a
48n/a
49n/afrom random import randrange, sample
50n/afrom fractions import Fraction
51n/afrom randfloat import un_randfloat, bin_randfloat, tern_randfloat
52n/a
53n/a
54n/adef sign():
55n/a if randrange(2):
56n/a if randrange(2): return '+'
57n/a return ''
58n/a return '-'
59n/a
60n/adef indicator():
61n/a return "eE"[randrange(2)]
62n/a
63n/adef digits(maxprec):
64n/a if maxprec == 0: return ''
65n/a return str(randrange(10**maxprec))
66n/a
67n/adef dot():
68n/a if randrange(2): return '.'
69n/a return ''
70n/a
71n/adef decimal_part(maxprec):
72n/a if randrange(100) > 60: # integers
73n/a return digits(maxprec)
74n/a if randrange(2):
75n/a intlen = randrange(1, maxprec+1)
76n/a fraclen = maxprec-intlen
77n/a intpart = digits(intlen)
78n/a fracpart = digits(fraclen)
79n/a return ''.join((intpart, '.', fracpart))
80n/a else:
81n/a return ''.join((dot(), digits(maxprec)))
82n/a
83n/adef expdigits(maxexp):
84n/a return str(randrange(maxexp))
85n/a
86n/adef exponent_part(maxexp):
87n/a return ''.join((indicator(), sign(), expdigits(maxexp)))
88n/a
89n/adef infinity():
90n/a if randrange(2): return 'Infinity'
91n/a return 'Inf'
92n/a
93n/adef nan():
94n/a d = ''
95n/a if randrange(2):
96n/a d = digits(randrange(99))
97n/a if randrange(2):
98n/a return ''.join(('NaN', d))
99n/a else:
100n/a return ''.join(('sNaN', d))
101n/a
102n/adef numeric_value(maxprec, maxexp):
103n/a if randrange(100) > 90:
104n/a return infinity()
105n/a exp_part = ''
106n/a if randrange(100) > 60:
107n/a exp_part = exponent_part(maxexp)
108n/a return ''.join((decimal_part(maxprec), exp_part))
109n/a
110n/adef numeric_string(maxprec, maxexp):
111n/a if randrange(100) > 95:
112n/a return ''.join((sign(), nan()))
113n/a else:
114n/a return ''.join((sign(), numeric_value(maxprec, maxexp)))
115n/a
116n/adef randdec(maxprec, maxexp):
117n/a return numeric_string(maxprec, maxexp)
118n/a
119n/adef rand_adjexp(maxprec, maxadjexp):
120n/a d = digits(maxprec)
121n/a maxexp = maxadjexp-len(d)+1
122n/a if maxexp == 0: maxexp = 1
123n/a exp = str(randrange(maxexp-2*(abs(maxexp)), maxexp))
124n/a return ''.join((sign(), d, 'E', exp))
125n/a
126n/a
127n/adef ndigits(n):
128n/a if n < 1: return 0
129n/a return randrange(10**(n-1), 10**n)
130n/a
131n/adef randtuple(maxprec, maxexp):
132n/a n = randrange(100)
133n/a sign = randrange(2)
134n/a coeff = ndigits(maxprec)
135n/a if n >= 95:
136n/a coeff = ()
137n/a exp = 'F'
138n/a elif n >= 85:
139n/a coeff = tuple(map(int, str(ndigits(maxprec))))
140n/a exp = "nN"[randrange(2)]
141n/a else:
142n/a coeff = tuple(map(int, str(ndigits(maxprec))))
143n/a exp = randrange(-maxexp, maxexp)
144n/a return (sign, coeff, exp)
145n/a
146n/adef from_triple(sign, coeff, exp):
147n/a return ''.join((str(sign*coeff), indicator(), str(exp)))
148n/a
149n/a
150n/a# Close to 10**n
151n/adef un_close_to_pow10(prec, maxexp, itr=None):
152n/a if itr is None:
153n/a lst = range(prec+30)
154n/a else:
155n/a lst = sample(range(prec+30), itr)
156n/a nines = [10**n - 1 for n in lst]
157n/a pow10 = [10**n for n in lst]
158n/a for coeff in nines:
159n/a yield coeff
160n/a yield -coeff
161n/a yield from_triple(1, coeff, randrange(2*maxexp))
162n/a yield from_triple(-1, coeff, randrange(2*maxexp))
163n/a for coeff in pow10:
164n/a yield coeff
165n/a yield -coeff
166n/a
167n/a# Close to 10**n
168n/adef bin_close_to_pow10(prec, maxexp, itr=None):
169n/a if itr is None:
170n/a lst = range(prec+30)
171n/a else:
172n/a lst = sample(range(prec+30), itr)
173n/a nines = [10**n - 1 for n in lst]
174n/a pow10 = [10**n for n in lst]
175n/a for coeff in nines:
176n/a yield coeff, 1
177n/a yield -coeff, -1
178n/a yield 1, coeff
179n/a yield -1, -coeff
180n/a yield from_triple(1, coeff, randrange(2*maxexp)), 1
181n/a yield from_triple(-1, coeff, randrange(2*maxexp)), -1
182n/a yield 1, from_triple(1, coeff, -randrange(2*maxexp))
183n/a yield -1, from_triple(-1, coeff, -randrange(2*maxexp))
184n/a for coeff in pow10:
185n/a yield coeff, -1
186n/a yield -coeff, 1
187n/a yield 1, -coeff
188n/a yield -coeff, 1
189n/a
190n/a# Close to 1:
191n/adef close_to_one_greater(prec, emax, emin):
192n/a rprec = 10**prec
193n/a return ''.join(("1.", '0'*randrange(prec),
194n/a str(randrange(rprec))))
195n/a
196n/adef close_to_one_less(prec, emax, emin):
197n/a rprec = 10**prec
198n/a return ''.join(("0.9", '9'*randrange(prec),
199n/a str(randrange(rprec))))
200n/a
201n/a# Close to 0:
202n/adef close_to_zero_greater(prec, emax, emin):
203n/a rprec = 10**prec
204n/a return ''.join(("0.", '0'*randrange(prec),
205n/a str(randrange(rprec))))
206n/a
207n/adef close_to_zero_less(prec, emax, emin):
208n/a rprec = 10**prec
209n/a return ''.join(("-0.", '0'*randrange(prec),
210n/a str(randrange(rprec))))
211n/a
212n/a# Close to emax:
213n/adef close_to_emax_less(prec, emax, emin):
214n/a rprec = 10**prec
215n/a return ''.join(("9.", '9'*randrange(prec),
216n/a str(randrange(rprec)), "E", str(emax)))
217n/a
218n/adef close_to_emax_greater(prec, emax, emin):
219n/a rprec = 10**prec
220n/a return ''.join(("1.", '0'*randrange(prec),
221n/a str(randrange(rprec)), "E", str(emax+1)))
222n/a
223n/a# Close to emin:
224n/adef close_to_emin_greater(prec, emax, emin):
225n/a rprec = 10**prec
226n/a return ''.join(("1.", '0'*randrange(prec),
227n/a str(randrange(rprec)), "E", str(emin)))
228n/a
229n/adef close_to_emin_less(prec, emax, emin):
230n/a rprec = 10**prec
231n/a return ''.join(("9.", '9'*randrange(prec),
232n/a str(randrange(rprec)), "E", str(emin-1)))
233n/a
234n/a# Close to etiny:
235n/adef close_to_etiny_greater(prec, emax, emin):
236n/a rprec = 10**prec
237n/a etiny = emin - (prec - 1)
238n/a return ''.join(("1.", '0'*randrange(prec),
239n/a str(randrange(rprec)), "E", str(etiny)))
240n/a
241n/adef close_to_etiny_less(prec, emax, emin):
242n/a rprec = 10**prec
243n/a etiny = emin - (prec - 1)
244n/a return ''.join(("9.", '9'*randrange(prec),
245n/a str(randrange(rprec)), "E", str(etiny-1)))
246n/a
247n/a
248n/adef close_to_min_etiny_greater(prec, max_prec, min_emin):
249n/a rprec = 10**prec
250n/a etiny = min_emin - (max_prec - 1)
251n/a return ''.join(("1.", '0'*randrange(prec),
252n/a str(randrange(rprec)), "E", str(etiny)))
253n/a
254n/adef close_to_min_etiny_less(prec, max_prec, min_emin):
255n/a rprec = 10**prec
256n/a etiny = min_emin - (max_prec - 1)
257n/a return ''.join(("9.", '9'*randrange(prec),
258n/a str(randrange(rprec)), "E", str(etiny-1)))
259n/a
260n/a
261n/aclose_funcs = [
262n/a close_to_one_greater, close_to_one_less, close_to_zero_greater,
263n/a close_to_zero_less, close_to_emax_less, close_to_emax_greater,
264n/a close_to_emin_greater, close_to_emin_less, close_to_etiny_greater,
265n/a close_to_etiny_less, close_to_min_etiny_greater, close_to_min_etiny_less
266n/a]
267n/a
268n/a
269n/adef un_close_numbers(prec, emax, emin, itr=None):
270n/a if itr is None:
271n/a itr = 1000
272n/a for _ in range(itr):
273n/a for func in close_funcs:
274n/a yield func(prec, emax, emin)
275n/a
276n/adef bin_close_numbers(prec, emax, emin, itr=None):
277n/a if itr is None:
278n/a itr = 1000
279n/a for _ in range(itr):
280n/a for func1 in close_funcs:
281n/a for func2 in close_funcs:
282n/a yield func1(prec, emax, emin), func2(prec, emax, emin)
283n/a for func in close_funcs:
284n/a yield randdec(prec, emax), func(prec, emax, emin)
285n/a yield func(prec, emax, emin), randdec(prec, emax)
286n/a
287n/adef tern_close_numbers(prec, emax, emin, itr):
288n/a if itr is None:
289n/a itr = 1000
290n/a for _ in range(itr):
291n/a for func1 in close_funcs:
292n/a for func2 in close_funcs:
293n/a for func3 in close_funcs:
294n/a yield (func1(prec, emax, emin), func2(prec, emax, emin),
295n/a func3(prec, emax, emin))
296n/a for func in close_funcs:
297n/a yield (randdec(prec, emax), func(prec, emax, emin),
298n/a func(prec, emax, emin))
299n/a yield (func(prec, emax, emin), randdec(prec, emax),
300n/a func(prec, emax, emin))
301n/a yield (func(prec, emax, emin), func(prec, emax, emin),
302n/a randdec(prec, emax))
303n/a for func in close_funcs:
304n/a yield (randdec(prec, emax), randdec(prec, emax),
305n/a func(prec, emax, emin))
306n/a yield (randdec(prec, emax), func(prec, emax, emin),
307n/a randdec(prec, emax))
308n/a yield (func(prec, emax, emin), randdec(prec, emax),
309n/a randdec(prec, emax))
310n/a
311n/a
312n/a# If itr == None, test all digit lengths up to prec + 30
313n/adef un_incr_digits(prec, maxexp, itr):
314n/a if itr is None:
315n/a lst = range(prec+30)
316n/a else:
317n/a lst = sample(range(prec+30), itr)
318n/a for m in lst:
319n/a yield from_triple(1, ndigits(m), 0)
320n/a yield from_triple(-1, ndigits(m), 0)
321n/a yield from_triple(1, ndigits(m), randrange(maxexp))
322n/a yield from_triple(-1, ndigits(m), randrange(maxexp))
323n/a
324n/a# If itr == None, test all digit lengths up to prec + 30
325n/a# Also output decimals im tuple form.
326n/adef un_incr_digits_tuple(prec, maxexp, itr):
327n/a if itr is None:
328n/a lst = range(prec+30)
329n/a else:
330n/a lst = sample(range(prec+30), itr)
331n/a for m in lst:
332n/a yield from_triple(1, ndigits(m), 0)
333n/a yield from_triple(-1, ndigits(m), 0)
334n/a yield from_triple(1, ndigits(m), randrange(maxexp))
335n/a yield from_triple(-1, ndigits(m), randrange(maxexp))
336n/a # test from tuple
337n/a yield (0, tuple(map(int, str(ndigits(m)))), 0)
338n/a yield (1, tuple(map(int, str(ndigits(m)))), 0)
339n/a yield (0, tuple(map(int, str(ndigits(m)))), randrange(maxexp))
340n/a yield (1, tuple(map(int, str(ndigits(m)))), randrange(maxexp))
341n/a
342n/a# If itr == None, test all combinations of digit lengths up to prec + 30
343n/adef bin_incr_digits(prec, maxexp, itr):
344n/a if itr is None:
345n/a lst1 = range(prec+30)
346n/a lst2 = range(prec+30)
347n/a else:
348n/a lst1 = sample(range(prec+30), itr)
349n/a lst2 = sample(range(prec+30), itr)
350n/a for m in lst1:
351n/a x = from_triple(1, ndigits(m), 0)
352n/a yield x, x
353n/a x = from_triple(-1, ndigits(m), 0)
354n/a yield x, x
355n/a x = from_triple(1, ndigits(m), randrange(maxexp))
356n/a yield x, x
357n/a x = from_triple(-1, ndigits(m), randrange(maxexp))
358n/a yield x, x
359n/a for m in lst1:
360n/a for n in lst2:
361n/a x = from_triple(1, ndigits(m), 0)
362n/a y = from_triple(1, ndigits(n), 0)
363n/a yield x, y
364n/a x = from_triple(-1, ndigits(m), 0)
365n/a y = from_triple(1, ndigits(n), 0)
366n/a yield x, y
367n/a x = from_triple(1, ndigits(m), 0)
368n/a y = from_triple(-1, ndigits(n), 0)
369n/a yield x, y
370n/a x = from_triple(-1, ndigits(m), 0)
371n/a y = from_triple(-1, ndigits(n), 0)
372n/a yield x, y
373n/a x = from_triple(1, ndigits(m), randrange(maxexp))
374n/a y = from_triple(1, ndigits(n), randrange(maxexp))
375n/a yield x, y
376n/a x = from_triple(-1, ndigits(m), randrange(maxexp))
377n/a y = from_triple(1, ndigits(n), randrange(maxexp))
378n/a yield x, y
379n/a x = from_triple(1, ndigits(m), randrange(maxexp))
380n/a y = from_triple(-1, ndigits(n), randrange(maxexp))
381n/a yield x, y
382n/a x = from_triple(-1, ndigits(m), randrange(maxexp))
383n/a y = from_triple(-1, ndigits(n), randrange(maxexp))
384n/a yield x, y
385n/a
386n/a
387n/adef randsign():
388n/a return (1, -1)[randrange(2)]
389n/a
390n/a# If itr == None, test all combinations of digit lengths up to prec + 30
391n/adef tern_incr_digits(prec, maxexp, itr):
392n/a if itr is None:
393n/a lst1 = range(prec+30)
394n/a lst2 = range(prec+30)
395n/a lst3 = range(prec+30)
396n/a else:
397n/a lst1 = sample(range(prec+30), itr)
398n/a lst2 = sample(range(prec+30), itr)
399n/a lst3 = sample(range(prec+30), itr)
400n/a for m in lst1:
401n/a for n in lst2:
402n/a for p in lst3:
403n/a x = from_triple(randsign(), ndigits(m), 0)
404n/a y = from_triple(randsign(), ndigits(n), 0)
405n/a z = from_triple(randsign(), ndigits(p), 0)
406n/a yield x, y, z
407n/a
408n/a
409n/a# Tests for the 'logical' functions
410n/adef bindigits(prec):
411n/a z = 0
412n/a for i in range(prec):
413n/a z += randrange(2) * 10**i
414n/a return z
415n/a
416n/adef logical_un_incr_digits(prec, itr):
417n/a if itr is None:
418n/a lst = range(prec+30)
419n/a else:
420n/a lst = sample(range(prec+30), itr)
421n/a for m in lst:
422n/a yield from_triple(1, bindigits(m), 0)
423n/a
424n/adef logical_bin_incr_digits(prec, itr):
425n/a if itr is None:
426n/a lst1 = range(prec+30)
427n/a lst2 = range(prec+30)
428n/a else:
429n/a lst1 = sample(range(prec+30), itr)
430n/a lst2 = sample(range(prec+30), itr)
431n/a for m in lst1:
432n/a x = from_triple(1, bindigits(m), 0)
433n/a yield x, x
434n/a for m in lst1:
435n/a for n in lst2:
436n/a x = from_triple(1, bindigits(m), 0)
437n/a y = from_triple(1, bindigits(n), 0)
438n/a yield x, y
439n/a
440n/a
441n/adef randint():
442n/a p = randrange(1, 100)
443n/a return ndigits(p) * (1,-1)[randrange(2)]
444n/a
445n/adef randfloat():
446n/a p = randrange(1, 100)
447n/a s = numeric_value(p, 383)
448n/a try:
449n/a f = float(numeric_value(p, 383))
450n/a except ValueError:
451n/a f = 0.0
452n/a return f
453n/a
454n/adef randcomplex():
455n/a real = randfloat()
456n/a if randrange(100) > 30:
457n/a imag = 0.0
458n/a else:
459n/a imag = randfloat()
460n/a return complex(real, imag)
461n/a
462n/adef randfraction():
463n/a num = randint()
464n/a denom = randint()
465n/a if denom == 0:
466n/a denom = 1
467n/a return Fraction(num, denom)
468n/a
469n/anumber_funcs = [randint, randfloat, randcomplex, randfraction]
470n/a
471n/adef un_random_mixed_op(itr=None):
472n/a if itr is None:
473n/a itr = 1000
474n/a for _ in range(itr):
475n/a for func in number_funcs:
476n/a yield func()
477n/a # Test garbage input
478n/a for x in (['x'], ('y',), {'z'}, {1:'z'}):
479n/a yield x
480n/a
481n/adef bin_random_mixed_op(prec, emax, emin, itr=None):
482n/a if itr is None:
483n/a itr = 1000
484n/a for _ in range(itr):
485n/a for func in number_funcs:
486n/a yield randdec(prec, emax), func()
487n/a yield func(), randdec(prec, emax)
488n/a for number in number_funcs:
489n/a for dec in close_funcs:
490n/a yield dec(prec, emax, emin), number()
491n/a # Test garbage input
492n/a for x in (['x'], ('y',), {'z'}, {1:'z'}):
493n/a for y in (['x'], ('y',), {'z'}, {1:'z'}):
494n/a yield x, y
495n/a
496n/adef tern_random_mixed_op(prec, emax, emin, itr):
497n/a if itr is None:
498n/a itr = 1000
499n/a for _ in range(itr):
500n/a for func in number_funcs:
501n/a yield randdec(prec, emax), randdec(prec, emax), func()
502n/a yield randdec(prec, emax), func(), func()
503n/a yield func(), func(), func()
504n/a # Test garbage input
505n/a for x in (['x'], ('y',), {'z'}, {1:'z'}):
506n/a for y in (['x'], ('y',), {'z'}, {1:'z'}):
507n/a for z in (['x'], ('y',), {'z'}, {1:'z'}):
508n/a yield x, y, z
509n/a
510n/adef all_unary(prec, exp_range, itr):
511n/a for a in un_close_to_pow10(prec, exp_range, itr):
512n/a yield (a,)
513n/a for a in un_close_numbers(prec, exp_range, -exp_range, itr):
514n/a yield (a,)
515n/a for a in un_incr_digits_tuple(prec, exp_range, itr):
516n/a yield (a,)
517n/a for a in un_randfloat():
518n/a yield (a,)
519n/a for a in un_random_mixed_op(itr):
520n/a yield (a,)
521n/a for a in logical_un_incr_digits(prec, itr):
522n/a yield (a,)
523n/a for _ in range(100):
524n/a yield (randdec(prec, exp_range),)
525n/a for _ in range(100):
526n/a yield (randtuple(prec, exp_range),)
527n/a
528n/adef unary_optarg(prec, exp_range, itr):
529n/a for _ in range(100):
530n/a yield randdec(prec, exp_range), None
531n/a yield randdec(prec, exp_range), None, None
532n/a
533n/adef all_binary(prec, exp_range, itr):
534n/a for a, b in bin_close_to_pow10(prec, exp_range, itr):
535n/a yield a, b
536n/a for a, b in bin_close_numbers(prec, exp_range, -exp_range, itr):
537n/a yield a, b
538n/a for a, b in bin_incr_digits(prec, exp_range, itr):
539n/a yield a, b
540n/a for a, b in bin_randfloat():
541n/a yield a, b
542n/a for a, b in bin_random_mixed_op(prec, exp_range, -exp_range, itr):
543n/a yield a, b
544n/a for a, b in logical_bin_incr_digits(prec, itr):
545n/a yield a, b
546n/a for _ in range(100):
547n/a yield randdec(prec, exp_range), randdec(prec, exp_range)
548n/a
549n/adef binary_optarg(prec, exp_range, itr):
550n/a for _ in range(100):
551n/a yield randdec(prec, exp_range), randdec(prec, exp_range), None
552n/a yield randdec(prec, exp_range), randdec(prec, exp_range), None, None
553n/a
554n/adef all_ternary(prec, exp_range, itr):
555n/a for a, b, c in tern_close_numbers(prec, exp_range, -exp_range, itr):
556n/a yield a, b, c
557n/a for a, b, c in tern_incr_digits(prec, exp_range, itr):
558n/a yield a, b, c
559n/a for a, b, c in tern_randfloat():
560n/a yield a, b, c
561n/a for a, b, c in tern_random_mixed_op(prec, exp_range, -exp_range, itr):
562n/a yield a, b, c
563n/a for _ in range(100):
564n/a a = randdec(prec, 2*exp_range)
565n/a b = randdec(prec, 2*exp_range)
566n/a c = randdec(prec, 2*exp_range)
567n/a yield a, b, c
568n/a
569n/adef ternary_optarg(prec, exp_range, itr):
570n/a for _ in range(100):
571n/a a = randdec(prec, 2*exp_range)
572n/a b = randdec(prec, 2*exp_range)
573n/a c = randdec(prec, 2*exp_range)
574n/a yield a, b, c, None
575n/a yield a, b, c, None, None