You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
543 B

25 years ago
2006-04-25 Bruno Haible <bruno@clisp.org> Richard B. Kreckel <kreckel@ginac.de> Make it theoretically possible to use bignums and long-floats with more than 2^32 significant digits or bits. * doc/cln.tex (logcount): Change return type to uintC. (struct cl_byte): Change elements to uintC. (integer_length, ord2, power2p): Change return type to uintC. (scale_float): Change argument type to sintC. (float_digits, float_precision): Change return type to uintC. * examples/atan_recip.cc: Use uintC instead of uintL where appropriate. * examples/atanh_recip.cc: Likewise. * include/cln/GV.h: Likewise. * include/cln/GV_complex.h: Likewise. * include/cln/GV_integer.h: Likewise. * include/cln/GV_modinteger.h: Likewise. * include/cln/GV_number.h: Likewise. * include/cln/GV_rational.h: Likewise. * include/cln/GV_real.h: Likewise. * include/cln/SV.h: Likewise. * include/cln/SV_complex.h: Likewise. * include/cln/SV_integer.h: Likewise. * include/cln/SV_number.h: Likewise. * include/cln/SV_rational.h: Likewise. * include/cln/SV_real.h: Likewise. * include/cln/SV_ringelt.h: Likewise. * include/cln/dfloat.h: Likewise. * include/cln/ffloat.h: Likewise. * include/cln/float.h: Likewise. * include/cln/integer.h: Likewise. * include/cln/lfloat.h: Likewise. * include/cln/modinteger.h: Likewise. * include/cln/sfloat.h: Likewise. * src/base/cl_low.h (integerlengthC): New macro. * src/base/digitseq/cl_2DS_div.cc: Use uintC instead of uintL where appropriate. * src/base/digitseq/cl_2DS_recip.cc: Likewise. * src/base/digitseq/cl_DS.h: Likewise. * src/base/digitseq/cl_DS_mul.c: Likewise. * src/base/digitseq/cl_DS_mul_fftc.h: Likewise. * src/base/digitseq/cl_DS_mul_fftcs.h: Likewise. * src/base/digitseq/cl_DS_mul_fftm.h: Likewise. * src/base/digitseq/cl_DS_mul_fftp.h: Likewise. * src/base/digitseq/cl_DS_mul_fftp3.h: Likewise. * src/base/digitseq/cl_DS_mul_fftp3m.h: Likewise. * src/base/digitseq/cl_DS_mul_fftr.h: Likewise. * src/base/digitseq/cl_DS_mul_kara.h: Likewise. * src/base/digitseq/cl_DS_mul_nuss.h: Likewise. * src/base/digitseq/cl_DS_recip.cc: Likewise. * src/base/digitseq/cl_DS_recipsqrt.cc: Likewise. * src/base/digitseq/cl_DS_sqrt.cc: Likewise. * src/base/digitseq/cl_DS_trandom.cc: Likewise. * src/complex/input/cl_N_read.cc: Likewise. * src/complex/transcendental/cl_C_asinh_aux.cc: Likewise. * src/complex/transcendental/cl_C_expt_C.cc: Likewise. * src/float/cl_F.h: Likewise. * src/float/conv/cl_F_from_F_f.cc: Likewise. * src/float/conv/cl_F_from_I_f.cc: Likewise. * src/float/conv/cl_F_from_RA_f.cc: Likewise. * src/float/dfloat/conv/cl_I_to_double.cc: Likewise. * src/float/dfloat/conv/cl_RA_to_double.cc: Likewise. * src/float/dfloat/elem/cl_DF_from_I.cc: Likewise. * src/float/dfloat/elem/cl_DF_from_RA.cc: Likewise. * src/float/dfloat/elem/cl_DF_scale.cc: Likewise. * src/float/dfloat/misc/cl_DF_digits.cc: Likewise. * src/float/dfloat/misc/cl_DF_precision.cc: Likewise. * src/float/elem/cl_F_scale.cc: Likewise. * src/float/ffloat/conv/cl_I_to_float.cc: Likewise. * src/float/ffloat/conv/cl_RA_to_float.cc: Likewise. * src/float/ffloat/elem/cl_FF_from_I.cc: Likewise. * src/float/ffloat/elem/cl_FF_from_RA.cc: Likewise. * src/float/ffloat/elem/cl_FF_scale.cc: Likewise. * src/float/ffloat/misc/cl_FF_digits.cc: Likewise. * src/float/ffloat/misc/cl_FF_precision.cc: Likewise. * src/float/input/cl_F_read.cc: Likewise. * src/float/lfloat/algebraic/cl_LF_sqrt.cc: Likewise. * src/float/lfloat/elem/cl_LF_1plus.cc: Likewise. * src/float/lfloat/elem/cl_LF_I_div.cc: Likewise. * src/float/lfloat/elem/cl_LF_I_mul.cc: Likewise. * src/float/lfloat/elem/cl_LF_div.cc: Likewise. * src/float/lfloat/elem/cl_LF_from_I.cc: Likewise. * src/float/lfloat/elem/cl_LF_from_RA.cc: Likewise. * src/float/lfloat/elem/cl_LF_fround.cc: Likewise. * src/float/lfloat/elem/cl_LF_ftrunc.cc: Likewise. * src/float/lfloat/elem/cl_LF_futrunc.cc: Likewise. * src/float/lfloat/elem/cl_LF_scale.cc: Likewise. * src/float/lfloat/elem/cl_LF_to_I.cc: Likewise. * src/float/lfloat/misc/cl_LF_digits.cc: Likewise. * src/float/lfloat/misc/cl_LF_idecode.cc: Likewise. * src/float/lfloat/misc/cl_LF_leninc.cc: Likewise. * src/float/lfloat/misc/cl_LF_lenincx.cc: Likewise. * src/float/lfloat/misc/cl_LF_precision.cc: Likewise. * src/float/lfloat/misc/cl_LF_shortenrel.cc: Likewise. * src/float/lfloat/misc/cl_LF_shortenwith.cc: Likewise. * src/float/misc/cl_F_digits.cc: Likewise. * src/float/misc/cl_F_epsneg.cc: Likewise. * src/float/misc/cl_F_epspos.cc: Likewise. * src/float/misc/cl_F_leastneg.cc: Likewise. * src/float/misc/cl_F_leastpos.cc: Likewise. * src/float/misc/cl_F_mostneg.cc: Likewise. * src/float/misc/cl_F_mostpos.cc: Likewise. * src/float/misc/cl_F_precision.cc: Likewise. * src/float/misc/cl_F_rational.cc: Likewise. * src/float/misc/cl_F_shortenrel.cc: Likewise. * src/float/output/cl_F_dprint.cc: Likewise. * src/float/random/cl_F_random.cc: Likewise. * src/float/sfloat/elem/cl_SF_from_I.cc: Likewise. * src/float/sfloat/elem/cl_SF_from_RA.cc: Likewise. * src/float/sfloat/elem/cl_SF_scale.cc: Likewise. * src/float/sfloat/misc/cl_SF_digits.cc: Likewise. * src/float/sfloat/misc/cl_SF_precision.cc: Likewise. * src/float/transcendental/cl_F_atanhx.cc: Likewise. * src/float/transcendental/cl_F_atanx.cc: Likewise. * src/float/transcendental/cl_F_catalanconst_f.cc: Likewise. * src/float/transcendental/cl_F_cos.cc: Likewise. * src/float/transcendental/cl_F_cosh.cc: Likewise. * src/float/transcendental/cl_F_coshsinh.cc: Likewise. * src/float/transcendental/cl_F_cossin.cc: Likewise. * src/float/transcendental/cl_F_eulerconst_f.cc: Likewise. * src/float/transcendental/cl_F_exp1_f.cc: Likewise. * src/float/transcendental/cl_F_expx.cc: Likewise. * src/float/transcendental/cl_F_ln10_f.cc: Likewise. * src/float/transcendental/cl_F_ln2_f.cc: Likewise. * src/float/transcendental/cl_F_lnx.cc: Likewise. * src/float/transcendental/cl_F_pi_f.cc: Likewise. * src/float/transcendental/cl_F_sin.cc: Likewise. * src/float/transcendental/cl_F_sinh.cc: Likewise. * src/float/transcendental/cl_F_sinhx.cc: Likewise. * src/float/transcendental/cl_F_sinx.cc: Likewise. * src/float/transcendental/cl_F_tran.h: Likewise. * src/float/transcendental/cl_F_zeta_int_f.cc: Likewise. * src/float/transcendental/cl_LF_atan_recip.cc: Likewise. * src/float/transcendental/cl_LF_atanh_recip.cc: Likewise. * src/float/transcendental/cl_LF_catalanconst.cc: Likewise. * src/float/transcendental/cl_LF_coshsinh_aux.cc: Likewise. * src/float/transcendental/cl_LF_cossin_aux.cc: Likewise. * src/float/transcendental/cl_LF_eulerconst.cc: Likewise. * src/float/transcendental/cl_LF_exp1.cc: Likewise. * src/float/transcendental/cl_LF_exp_aux.cc: Likewise. * src/float/transcendental/cl_LF_pi.cc: Likewise. * src/float/transcendental/cl_LF_ratseries.cc: Likewise. * src/float/transcendental/cl_LF_ratseries_.cc: Likewise. * src/float/transcendental/cl_LF_ratseries_a.cc: Likewise. * src/float/transcendental/cl_LF_ratseries_ab.cc: Likewise. * src/float/transcendental/cl_LF_ratseries_b.cc: Likewise. * src/float/transcendental/cl_LF_ratseries_p.cc: Likewise. * src/float/transcendental/cl_LF_ratseries_pa.cc: Likewise. * src/float/transcendental/cl_LF_ratseries_pab.cc: Likewise. * src/float/transcendental/cl_LF_ratseries_pb.cc: Likewise. * src/float/transcendental/cl_LF_ratseries_pq.cc: Likewise. * src/float/transcendental/cl_LF_ratseries_pqa.cc: Likewise. * src/float/transcendental/cl_LF_ratseries_pqab.cc: Likewise. * src/float/transcendental/cl_LF_ratseries_pqb.cc: Likewise. * src/float/transcendental/cl_LF_ratseries_q.cc: Likewise. * src/float/transcendental/cl_LF_ratseries_qa.cc: Likewise. * src/float/transcendental/cl_LF_ratseries_qab.cc: Likewise. * src/float/transcendental/cl_LF_ratseries_qb.cc: Likewise. * src/float/transcendental/cl_LF_ratseries_stream_pq.cc: Likewise. * src/float/transcendental/cl_LF_ratseries_stream_pqa.cc: Likewise. * src/float/transcendental/cl_LF_ratseries_stream_pqab.cc: Likewise. * src/float/transcendental/cl_LF_ratseries_stream_pqb.cc: Likewise. * src/float/transcendental/cl_LF_ratsumseries_pqcd.cc: Likewise. * src/float/transcendental/cl_LF_ratsumseries_pqcd_aux.cc: Likewise. * src/float/transcendental/cl_LF_ratsumseries_pqd.cc: Likewise. * src/float/transcendental/cl_LF_ratsumseries_pqd_aux.cc: Likewise. * src/float/transcendental/cl_LF_tran.h: Likewise. * src/float/transcendental/cl_LF_zeta3.cc: Likewise. * src/float/transcendental/cl_LF_zeta_int.cc: Likewise. * src/integer/algebraic/cl_I_rootp_I.cc: Likewise. * src/integer/algebraic/cl_I_rootp_aux.cc: Likewise. * src/integer/bitwise/cl_I_ash.cc: Likewise. * src/integer/bitwise/cl_I_ash_I.cc: Likewise. * src/integer/bitwise/cl_I_byte.h: Likewise. * src/integer/bitwise/cl_I_fullbyte.cc: Likewise. * src/integer/bitwise/cl_I_ilength.cc: Likewise. * src/integer/bitwise/cl_I_ldb.cc: Likewise. * src/integer/bitwise/cl_I_ldbtest.cc: Likewise. * src/integer/bitwise/cl_I_ldbx.cc: Likewise. * src/integer/bitwise/cl_I_ldbxtest.cc: Likewise. * src/integer/bitwise/cl_I_logbitp.cc: Likewise. * src/integer/bitwise/cl_I_logbitp_I.cc: Likewise. * src/integer/bitwise/cl_I_logcount.cc: Likewise. * src/integer/bitwise/cl_I_mkf.cc: Likewise. * src/integer/bitwise/cl_I_mkfx.cc: Likewise. * src/integer/cl_I.h: Likewise. * src/integer/conv/cl_I_to_digits.cc: Likewise. * src/integer/conv/cl_I_digits_need.cc: Likewise. * src/integer/conv/cl_I_from_digits.cc: Likewise. * src/integer/gcd/cl_I_gcd.cc: Likewise. * src/integer/gcd/cl_I_xgcd.cc: Likewise. * src/integer/misc/cl_I_eqhashcode.cc: Likewise. * src/integer/misc/cl_I_ord2.cc: Likewise. * src/integer/misc/cl_I_power2p.cc: Likewise. * src/integer/output/cl_I_cached_power.h (cached_power_table): allow for 40 elements. * src/integer/output/cl_I_decstring.cc: Use uintC instead of uintL where appropriate. * src/integer/output/cl_I_print.cc: Likewise. * src/integer/output/cl_I_print_string.cc: Likewise. * src/modinteger/cl_MI.cc: Likewise. * src/modinteger/cl_MI_lshift.cc: Likewise. * src/modinteger/cl_MI_montgom.h: Likewise. * src/modinteger/cl_MI_pow2.h: Likewise. * src/modinteger/cl_MI_pow2m1.h: Likewise. * src/modinteger/cl_MI_pow2p1.h: Likewise. * src/modinteger/cl_MI_rshift.cc: Likewise. * src/modinteger/cl_MI_std.h: Likewise. * src/numtheory/cl_IF_millerrabin.cc: Likewise. * src/numtheory/cl_nt_isprobprime.cc: Likewise. * src/numtheory/cl_nt_sqrtmodp.cc: Likewise. * src/polynomial/elem/cl_UP_GF2.h: Likewise. * src/real/conv/cl_F_from_R_f.cc: Likewise. * src/real/format-output/cl_fmt_floatstring.cc: Likewise. * src/real/input/cl_R_read.cc: Likewise. * src/vector/cl_GV_I.cc: Likewise. * src/vector/cl_GV_I_copy.cc: Likewise. * src/vector/cl_GV_number.cc: Likewise. * src/vector/cl_GV_number_copy.cc: Likewise. * src/vector/cl_SV_copy.cc: Likewise. * src/vector/cl_SV_number.cc: Likewise. * src/vector/cl_SV_ringelt.cc: Likewise. * tests/main.cc: Likewise. * tests/test_I_ilength.cc: Likewise. * tests/test_I_ord2.cc: Likewise.
19 years ago
25 years ago
  1. #include "test_I.h"
  2. int test_I_integer_length (int iterations)
  3. {
  4. int error = 0;
  5. int i;
  6. // Check against ash.
  7. for (i = iterations; i > 0; i--) {
  8. cl_I a = testrandom_I();
  9. uintC l = integer_length(a);
  10. if (a >= 0) {
  11. int b = 0;
  12. if (a < ash(1,l)) {
  13. if (a == 0)
  14. b = (l == 0);
  15. else
  16. b = (l > 0 && a >= ash(1,l-1));
  17. }
  18. ASSERT1(b, a);
  19. } else {
  20. int b = 0;
  21. if (a >= ash(-1,l)) {
  22. if (a == -1)
  23. b = (l == 0);
  24. else
  25. b = (l > 0 && a < ash(-1,l-1));
  26. }
  27. ASSERT1(b, a);
  28. }
  29. }
  30. return error;
  31. }