arb/arf/abs_bound_lt_2exp_si.c

43 lines
986 B
C
Raw Normal View History

/*
2014-04-27 00:32:37 +02:00
Copyright (C) 2014 Fredrik Johansson
This file is part of Arb.
Arb is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License (LGPL) as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version. See <http://www.gnu.org/licenses/>.
*/
2014-04-27 00:32:37 +02:00
#include "arf.h"
2015-11-10 13:41:43 +00:00
slong
2014-04-27 00:32:37 +02:00
arf_abs_bound_lt_2exp_si(const arf_t x)
{
2015-11-05 18:00:39 +00:00
slong res;
2014-04-27 00:32:37 +02:00
if (arf_is_special(x))
{
if (arf_is_zero(x))
return -ARF_PREC_EXACT;
else
return ARF_PREC_EXACT;
}
if (!COEFF_IS_MPZ(ARF_EXP(x)))
return ARF_EXP(x);
if (fmpz_fits_si(ARF_EXPREF(x)))
res = fmpz_get_si(ARF_EXPREF(x));
else
res = fmpz_sgn(ARF_EXPREF(x)) < 0 ? -ARF_PREC_EXACT : ARF_PREC_EXACT;
if (res < -ARF_PREC_EXACT)
res = -ARF_PREC_EXACT;
if (res > ARF_PREC_EXACT)
res = ARF_PREC_EXACT;
return res;
}