mirror of
https://github.com/vale981/arb
synced 2025-03-05 09:21:38 -05:00
add arf_equal_ui, arf_equal_d (fixes #381)
This commit is contained in:
parent
43d25447e8
commit
5d8822781e
5 changed files with 27 additions and 7 deletions
3
arf.h
3
arf.h
|
@ -610,8 +610,9 @@ int arf_get_mpfr(mpfr_t x, const arf_t y, mpfr_rnd_t rnd);
|
|||
void arf_set_mpfr(arf_t x, const mpfr_t y);
|
||||
|
||||
int arf_equal(const arf_t x, const arf_t y);
|
||||
|
||||
int arf_equal_si(const arf_t x, slong y);
|
||||
int arf_equal_ui(const arf_t x, ulong y);
|
||||
int arf_equal_d(const arf_t x, double y);
|
||||
|
||||
ARF_INLINE void
|
||||
arf_min(arf_t z, const arf_t a, const arf_t b)
|
||||
|
|
16
arf/equal.c
16
arf/equal.c
|
@ -48,3 +48,19 @@ arf_equal_si(const arf_t x, slong y)
|
|||
return arf_equal(x, t); /* no need to free */
|
||||
}
|
||||
|
||||
int
|
||||
arf_equal_ui(const arf_t x, ulong y)
|
||||
{
|
||||
arf_t t;
|
||||
arf_init_set_ui(t, y);
|
||||
return arf_equal(x, t); /* no need to free */
|
||||
}
|
||||
|
||||
int
|
||||
arf_equal_d(const arf_t x, double y)
|
||||
{
|
||||
arf_t t;
|
||||
arf_init(t);
|
||||
arf_set_d(t, y);
|
||||
return arf_equal(x, t); /* no need to free */
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ int main()
|
|||
mpfr_set_d(m, x, MPFR_RNDN);
|
||||
arf_set_mpfr(z, m);
|
||||
|
||||
if (!arf_equal(y, z))
|
||||
if (!arf_equal(y, z) || !arf_equal_d(y, x))
|
||||
{
|
||||
flint_printf("FAIL:\n\n");
|
||||
flint_printf("x = %.17g\n\n", x);
|
||||
|
|
|
@ -61,7 +61,7 @@ int main()
|
|||
|
||||
ret2 = arf_set_round_ui(y, t, prec, rnd);
|
||||
|
||||
if (!arf_equal(x, y) || (ret1 != ret2))
|
||||
if (!arf_equal(x, y) || (ret1 != ret2) || (ret2 == 0 && !arf_equal_ui(y, t)))
|
||||
{
|
||||
flint_printf("FAIL\n\n");
|
||||
flint_printf("prec = %wd", prec); flint_printf("\n\n");
|
||||
|
@ -81,4 +81,3 @@ int main()
|
|||
flint_printf("PASS\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -323,11 +323,15 @@ Comparisons and bounds
|
|||
-------------------------------------------------------------------------------
|
||||
|
||||
.. function:: int arf_equal(const arf_t x, const arf_t y)
|
||||
int arf_equal_si(const arf_t x, slong y)
|
||||
int arf_equal_ui(const arf_t x, ulong y)
|
||||
int arf_equal_d(const arf_t x, double y)
|
||||
|
||||
.. function:: int arf_equal_si(const arf_t x, slong y)
|
||||
Returns nonzero iff *x* and *y* are exactly equal. NaN is not
|
||||
treated specially, i.e. NaN compares as equal to itself.
|
||||
|
||||
Returns nonzero iff *x* and *y* are exactly equal. This function does
|
||||
not treat NaN specially, i.e. NaN compares as equal to itself.
|
||||
For comparison with a *double*, the values -0 and +0 are
|
||||
both treated as zero, and all NaN values are treated as identical.
|
||||
|
||||
.. function:: int arf_cmp(const arf_t x, const arf_t y)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue