From 7f28435331b338ea3546070c41bbde91ec1ec9bd Mon Sep 17 00:00:00 2001 From: John Maddock Date: Mon, 14 Jan 2008 17:28:52 +0000 Subject: [PATCH] Added initial rounding function docs. [SVN r42769] --- doc/sf_and_dist/math.qbk | 1 + doc/sf_and_dist/rounding_func.qbk | 74 +++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 doc/sf_and_dist/rounding_func.qbk diff --git a/doc/sf_and_dist/math.qbk b/doc/sf_and_dist/math.qbk index 7fde5857b..0392998f8 100644 --- a/doc/sf_and_dist/math.qbk +++ b/doc/sf_and_dist/math.qbk @@ -361,6 +361,7 @@ for these distributions. [include powers.qbk] [include sinc.qbk] [include inv_hyper.qbk] +[include rounding_func.qbk] [include fpclassify.qbk] [endsect] [/section:special Special Functions] diff --git a/doc/sf_and_dist/rounding_func.qbk b/doc/sf_and_dist/rounding_func.qbk new file mode 100644 index 000000000..9286c16ef --- /dev/null +++ b/doc/sf_and_dist/rounding_func.qbk @@ -0,0 +1,74 @@ + +[section:rounding Rounding Truncation and Integer Conversion] + +[section:round Rounding Functions] + + template + T round(const T& v); + + template + int iround(const T& v); + + template + long lround(const T& v); + + template + long long llround(const T& v); + +These functions return the closest integer to the argument /v/. + +Halfway cases are rounded away from zero, regardless of the current rounding +direction. + +[endsect] + +[section:trunc Truncation Functions] + + template + T trunc(const T& v); + + template + int itrunc(const T& v); + + template + long ltrunc(const T& v); + + template + long long lltrunc(const T& v); + +The trunc functions round their argument to the integer value, +nearest to but no larger in magnitude than the argument. + +For example `itrunc(3.7)` would return `3` and `ltrunc(-4.6)` +would return `-4`. + +[endsect] + +[section:modf Integer and Fractional Part Splitting (modf)] + + template + T modf(const T& v, T* ipart); + + template + T modf(const T& v, int* ipart); + + template + T modf(const T& v, long* ipart); + + template + T modf(const T& v, long long* ipart); + +The `modf` functions store the integer part of /v/ in `*ipart` +and return the fractional part of /v/. + +[endsect] + + +[endsect] [/section:rounding Rounding Truncation and Integer Conversion] + +[/ + Copyright 2006 John Maddock and Paul A. Bristow. + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt). +]