Skip to content

Commit

Permalink
Fixed Update |arc| and |t_tot| after |do_arc_test| has just returned …
Browse files Browse the repository at this point in the history
…|t|in mp_get_arc_time. Fixed a bug in n_arg for double and binary mode, where -0.0 was different form 0.0.

git-svn-id: svn://tug.org/texlive/trunk/Build/source@71144 c570f23f-e606-0410-a88d-b1316a301751
  • Loading branch information
luigiScarso committed May 1, 2024
1 parent 78b7f4b commit dc13968
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 9 deletions.
9 changes: 9 additions & 0 deletions texk/web2c/mplibdir/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
2024-05-01 Luigi Scarso <luigi.scarso@gmail.com>
* Fixed Update |arc| and |t_tot| after |do_arc_test| has just returned |t|
in mp_get_arc_time

2024-03-18 Luigi Scarso <luigi.scarso@gmail.com>
* Fixed a bug in n_arg for double and binary mode,
where -0.0 was different form 0.0.
Work in progress for the interval mode.

2024-02-16 Luigi Scarso <luigi.scarso@gmail.com>
* Updated manual. MetaPost 2.1

Expand Down
14 changes: 10 additions & 4 deletions texk/web2c/mplibdir/mp.w
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ undergoes any modifications, so that it will be clear which version of
@^extensions to \MP@>
@^system dependencies@>

@d default_banner "This is MetaPost, Version 2.10" /* printed when \MP\ starts */
@d default_banner "This is MetaPost, Version 2.11" /* printed when \MP\ starts */
@d true 1
@d false 0

@<Metapost version header@>=
#define metapost_version "2.10"
#define metapost_version "2.11"

@ The external library header for \MP\ is |mplib.h|. It contains a
few typedefs and the header defintions for the externally used
Expand Down Expand Up @@ -10353,14 +10353,20 @@ if (number_positive(arc)) {
new_number (v1);

set_number_from_substraction (d1, arc0, arc); /* d1 = arc0 - arc */
set_number_from_div (n1, arc, d1); /* n1 = (arc / d1) */
if (number_greater (d1,arc)) {
set_number_to_zero(n1); /* n1 = 0 */
} else {
set_number_from_div (n1, arc, d1); /* n1 = (arc / d1) */
floor_scaled(n1);
}
number_clone (n, n1);
set_number_from_mul (n1, n1, d1); /* n1 = (n1 * d1) */
number_substract (arc, n1); /* arc = arc - n1 */

number_clone (d1, inf_t); /* reuse d1 */
number_clone (v1, n); /* v1 = n */
number_add (v1, epsilon_t); /* v1 = n1+1 */

set_number_from_int(v1, number_to_int(v1)+1); /* v1 = n1+1 */
set_number_from_div (d1, d1, v1); /* |d1 = EL_GORDO / v1| */
if (number_greater (t_tot, d1)) {
mp->arith_error = true;
Expand Down
6 changes: 4 additions & 2 deletions texk/web2c/mplibdir/mpmathbinary.w
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ static double precision_bits_to_digits (mpfr_prec_t i);

@d mpfr_negative_p(a) (mpfr_sgn((a))<0)
@d mpfr_positive_p(a) (mpfr_sgn((a))>0)
@d checkZero(dec) if (mpfr_zero_p(dec) && mpfr_negative_p(dec)) {
@d checkZero(dec) if (mpfr_zero_p(dec)) {
mpfr_set_zero(dec,1);
}

Expand Down Expand Up @@ -1677,7 +1677,9 @@ void mp_init_randoms (MP mp, int seed) {

@ @c
void mp_binary_number_modulo (mp_number *a, mp_number b) {
mpfr_remainder (a->data.num, a->data.num, b.data.num, ROUNDING);
/* mpfr_remainder (a->data.num, a->data.num, b.data.num, ROUNDING);*/
/* This is consistent with scaled mode */
mpfr_fmod (a->data.num, a->data.num, b.data.num, ROUNDING);
}

@ To consume a random integer for the uniform generator, the program below will say `|next_unif_random|'.
Expand Down
5 changes: 5 additions & 0 deletions texk/web2c/mplibdir/mpmathdouble.w
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,11 @@ void mp_double_n_arg (MP mp, mp_number *ret, mp_number x_orig, mp_number y_orig)
@<Handle undefined arg@>;
} else {
ret->type = mp_angle_type;
/* Consistency with the other numbersystems */
if (x_orig.data.dval == -0.0)
x_orig.data.dval = 0.0;
if (y_orig.data.dval == -0.0)
y_orig.data.dval = 0.0;
ret->data.dval = atan2 (y_orig.data.dval, x_orig.data.dval) * (180.0 / PI) * angle_multiplier;
if (ret->data.dval == -0.0)
ret->data.dval = 0.0;
Expand Down
8 changes: 5 additions & 3 deletions texk/web2c/mplibdir/mpmathinterval.w
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,9 @@ static int mpfi_remainder_1 (mpfi_t r, mpfi_t x, mpfr_t m) {
mpfr_inits2(precision_bits, d, abs_m, rem_a, rem_b, zero, one, abs_m_1,(mpfr_ptr) 0);
mpfr_sub(d, b, a, MPFR_RNDN);
mpfr_abs(abs_m, m, MPFR_RNDN);
mpfr_remainder(rem_a, a, m, MPFR_RNDN); mpfr_remainder(rem_b, b, m, MPFR_RNDN);
/*mpfr_remainder(rem_a, a, m, MPFR_RNDN); mpfr_remainder(rem_b, b, m, MPFR_RNDN); */
/* This is consistent with scaled mode */
mpfr_fmod(rem_a, a, m, MPFR_RNDN); mpfr_fmod(rem_b, b, m, MPFR_RNDN);
if (mpfr_less_p(d,abs_m) && mpfr_lessequal_p(rem_a,rem_b)) {
/*return [a % m, b % m] */
ret_val= mpfi_interv_fr(r, rem_a, rem_b);
Expand Down Expand Up @@ -1879,8 +1881,8 @@ void mp_interval_n_arg (MP mp, mp_number *ret, mp_number x_orig, mp_number y_ori
ret->type = mp_angle_type;
mpfi_set_si(oneeighty_angle, 180 * angle_multiplier);
mpfi_div(oneeighty_angle, oneeighty_angle, PI_mpfi_t);
checkZero((mpfi_ptr)y_orig.data.num);
checkZero((mpfi_ptr)x_orig.data.num);
/*checkZero((mpfi_ptr)y_orig.data.num);*/
/*checkZero((mpfi_ptr)x_orig.data.num);*/
mpfi_atan2(atan2val, y_orig.data.num, x_orig.data.num);
mpfi_mul(ret->data.num, atan2val, oneeighty_angle);
checkZero((mpfi_ptr)ret->data.num);
Expand Down

0 comments on commit dc13968

Please sign in to comment.