2016-04-26 17:20:05 +02:00
|
|
|
/*
|
2013-09-19 11:50:01 +01:00
|
|
|
Copyright (C) 2013 Fredrik Johansson
|
|
|
|
|
2016-04-26 17:20:05 +02:00
|
|
|
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/>.
|
|
|
|
*/
|
2013-09-19 11:50:01 +01:00
|
|
|
|
|
|
|
#include "fmpr.h"
|
|
|
|
|
2015-11-10 13:41:43 +00:00
|
|
|
slong
|
2013-09-19 11:50:01 +01:00
|
|
|
fmpr_abs_bound_lt_2exp_si(const fmpr_t x)
|
|
|
|
{
|
|
|
|
if (fmpr_is_special(x))
|
|
|
|
{
|
|
|
|
if (fmpr_is_zero(x))
|
|
|
|
return -FMPR_PREC_EXACT;
|
|
|
|
else
|
|
|
|
return FMPR_PREC_EXACT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-11-05 18:03:08 +00:00
|
|
|
slong res;
|
2013-09-19 11:50:01 +01:00
|
|
|
fmpz_t t;
|
|
|
|
fmpz_init(t);
|
|
|
|
fmpr_abs_bound_lt_2exp_fmpz(t, x);
|
|
|
|
|
|
|
|
if (fmpz_fits_si(t))
|
|
|
|
res = fmpz_get_si(t);
|
|
|
|
else
|
|
|
|
res = fmpz_sgn(t) < 0 ? -FMPR_PREC_EXACT : FMPR_PREC_EXACT;
|
|
|
|
|
|
|
|
fmpz_clear(t);
|
|
|
|
|
|
|
|
if (res < -FMPR_PREC_EXACT)
|
|
|
|
res = -FMPR_PREC_EXACT;
|
|
|
|
if (res > FMPR_PREC_EXACT)
|
|
|
|
res = FMPR_PREC_EXACT;
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|