Skip to content

Commit

Permalink
requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bksaiki committed Sep 8, 2024
1 parent 6cebfac commit 4f5540e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/mlmpfr.ml
Original file line number Diff line number Diff line change
Expand Up @@ -758,8 +758,8 @@ let get_formatted_str ?(rnd = To_Nearest) ?(base = 10) ?(size = 0) ?(ktz = true)
Printf.sprintf "%s%s%s%c%+03d"
(if neg then String.sub mantissa 0 2 else Char.escaped mantissa.[0])
(if
(neg && String.length mantissa == 2)
|| (neg == false && String.length mantissa == 1)
(neg && String.length mantissa == 2)
|| (neg == false && String.length mantissa == 1)
then ""
else ".")
(String.sub mantissa
Expand Down
10 changes: 5 additions & 5 deletions src/mlmpfr_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ CAMLprim value
caml_mpfr_sgn (value op)
{
CAMLparam1 (op);
CAMLreturn (val_sign( mpfr_sgn (MPFR_val2 (op))));
CAMLreturn (val_sign (mpfr_sgn (MPFR_val2 (op))));
}

CAMLprim value
Expand Down Expand Up @@ -1282,14 +1282,14 @@ caml_mpfr_lgamma (value rnd, value prec, value op)
ter = mpfr_lgamma (MPFR_val (rop), &signp, MPFR_val2 (op), rnd_val_opt (rnd));

// sign is undefined when rop is NaN, -Inf, or a negative integer
if ( mpfr_nan_p (MPFR_val2 (op)) ||
( mpfr_sgn (MPFR_val2 (op)) < 0 && (mpfr_inf_p (MPFR_val2 (op)) || mpfr_integer_p (MPFR_val2 (op))) ))
if (mpfr_nan_p (MPFR_val2 (op))
|| (mpfr_sgn (MPFR_val2 (op)) < 0
&& (mpfr_inf_p (MPFR_val2 (op)) || mpfr_integer_p (MPFR_val2 (op)))))
signp = 0;

tval = val_ter (ter);
sval = val_some (tval);
CAMLreturn (
caml_tuple2 (mpfr_float (rop, sval), val_sign (signp)));
CAMLreturn (caml_tuple2 (mpfr_float (rop, sval), val_sign (signp)));
}

CAMLprim value
Expand Down
3 changes: 1 addition & 2 deletions testsuite/initializationfunctions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ let _ =
printf "%s\n" (rounding_to_string x);
printf "%d\n" (M.get_prec x);
(* Should not raise Precision_range exception *)
let _ = M.make_zero ~prec:M.mpfr_prec_min M.Positive in
();
let _ = M.make_zero ~prec:M.mpfr_prec_min M.Positive in ();
Gc.full_major ()
(* garbage collector full major *)
2 changes: 1 addition & 1 deletion testsuite/miscellaneousfunctions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let all op1 op2 exp =
printf "%s\n" (M.get_formatted_str (M.max op1 op2));
printf "%d\n" (M.get_exp op1);
printf "%d\n" (M.get_exp (M.set_exp op1 exp));
printf "%s\n" (if M.signbit op1 then "Positive" else "Negative");
printf "%s\n" (if M.signbit op1 then "Negative" else "Positive");
printf "%s\n" (M.get_formatted_str (M.copysign op1 op2));
printf "%s\n" (M.get_version ())

Expand Down

0 comments on commit 4f5540e

Please sign in to comment.