From 3101f40f7634b0262f1e936dc3df06ab89aacd15 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Mon, 9 Aug 2004 23:32:14 +0000 Subject: [PATCH] (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. --- libguile/deprecated.c | 18 +++++++++++++++++- libguile/deprecated.h | 6 ++++++ libguile/numbers.c | 23 +++++++++-------------- libguile/numbers.h | 4 ++-- 4 files changed, 34 insertions(+), 17 deletions(-) diff --git a/libguile/deprecated.c b/libguile/deprecated.c index 18173bfc7..846dc7cc2 100644 --- a/libguile/deprecated.c +++ b/libguile/deprecated.c @@ -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 () { diff --git a/libguile/deprecated.h b/libguile/deprecated.h index e91f22a8f..f9f500e6f 100644 --- a/libguile/deprecated.h +++ b/libguile/deprecated.h @@ -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 diff --git a/libguile/numbers.c b/libguile/numbers.c index 3e8e5e630..c0e7d58dc 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -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)); diff --git a/libguile/numbers.h b/libguile/numbers.h index dc1f4c2b8..4e39a2cc1 100644 --- a/libguile/numbers.h +++ b/libguile/numbers.h @@ -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); -- 2.20.1