1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-11 22:31:12 +02:00

(scm_round, scm_truncate): Renamed to scm_c_round and scm_c_truncate;

deprecated versions installed in deprecated.h and deprecated.c.
Changed all uses.
This commit is contained in:
Marius Vollmer 2004-08-09 23:32:14 +00:00
parent 565b4a6f31
commit 3101f40f76
4 changed files with 34 additions and 17 deletions

View file

@ -2,7 +2,7 @@
deprecate something, move it here when that is feasible.
*/
/* Copyright (C) 2003 Free Software Foundation, Inc.
/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -1129,6 +1129,22 @@ SCM_INUM (SCM obj)
return scm_to_intmax (obj);
}
double
scm_truncate (double x)
{
scm_c_issue_deprecation_warning
("scm_truncate is deprecated. Use scm_c_truncate instead.");
return scm_c_truncate (x);
}
double
scm_round (double x)
{
scm_c_issue_deprecation_warning
("scm_round is deprecated. Use scm_c_round instead.");
return scm_c_round (x);
}
void
scm_i_init_deprecated ()
{

View file

@ -382,6 +382,12 @@ SCM_API scm_t_signed_bits SCM_INUM (SCM obj);
} while (0)
/* Deprecated because the names belong to what is now
scm_truncate_number and scm_round_number.
*/
SCM_API double scm_truncate (double x);
SCM_API double scm_round (double x);
void scm_i_init_deprecated (void);
#endif

View file

@ -4895,13 +4895,8 @@ SCM_GPROC1 (s_atanh, "$atanh", scm_tc7_dsubr, (SCM (*)()) atanh, g_atanh);
*/
/* XXX - eventually, we should remove this definition of scm_round and
rename scm_round_number to scm_round. Likewise for scm_truncate
and scm_truncate_number.
*/
double
scm_truncate (double x)
scm_c_truncate (double x)
{
#if HAVE_TRUNC
return trunc (x);
@ -4912,10 +4907,10 @@ scm_truncate (double x)
#endif
}
/* scm_round is done using floor(x+0.5) to round to nearest and with
half-way case (ie. when x is an integer plus 0.5) going upwards. Then
half-way cases are identified and adjusted down if the round-upwards
didn't give the desired even integer.
/* scm_c_round is done using floor(x+0.5) to round to nearest and with
half-way case (ie. when x is an integer plus 0.5) going upwards.
Then half-way cases are identified and adjusted down if the
round-upwards didn't give the desired even integer.
"plus_half == result" identifies a half-way case. If plus_half, which is
x + 0.5, is an integer then x must be an integer plus 0.5.
@ -4939,7 +4934,7 @@ scm_truncate (double x)
an 0.5 to be represented, and hence added without a bad rounding. */
double
scm_round (double x)
scm_c_round (double x)
{
double plus_half, result;
@ -4948,7 +4943,7 @@ scm_round (double x)
plus_half = x + 0.5;
result = floor (plus_half);
/* Adjust so that the scm_round is towards even. */
/* Adjust so that the rounding is towards even. */
return ((plus_half == result && plus_half / 2 != floor (plus_half / 2))
? result - 1
: result);
@ -4978,7 +4973,7 @@ SCM_DEFINE (scm_round_number, "round", 1, 0, 0,
if (SCM_I_INUMP (x) || SCM_BIGP (x))
return x;
else if (SCM_REALP (x))
return scm_from_double (scm_round (SCM_REAL_VALUE (x)));
return scm_from_double (scm_c_round (SCM_REAL_VALUE (x)));
else
{
/* OPTIMIZE-ME: Fraction case could be done more efficiently by a
@ -4986,7 +4981,7 @@ SCM_DEFINE (scm_round_number, "round", 1, 0, 0,
the rounding should go. */
SCM plus_half = scm_sum (x, exactly_one_half);
SCM result = scm_floor (plus_half);
/* Adjust so that the scm_round is towards even. */
/* Adjust so that the rounding is towards even. */
if (scm_is_true (scm_num_eq_p (plus_half, result))
&& scm_is_true (scm_odd_p (result)))
return scm_difference (result, SCM_I_MAKINUM (1));

View file

@ -241,8 +241,8 @@ SCM_API SCM scm_ceiling (SCM x);
SCM_API double scm_asinh (double x);
SCM_API double scm_acosh (double x);
SCM_API double scm_atanh (double x);
SCM_API double scm_truncate (double x);
SCM_API double scm_round (double x);
SCM_API double scm_c_truncate (double x);
SCM_API double scm_c_round (double x);
SCM_API SCM scm_truncate_number (SCM x);
SCM_API SCM scm_round_number (SCM x);
SCM_API SCM scm_sys_expt (SCM z1, SCM z2);