From fb2f55ca044c4ba606d89974810fdcf609d8c57a Mon Sep 17 00:00:00 2001 From: "Paul A. Bristow" Date: Tue, 24 Jul 2012 11:32:17 +0000 Subject: [PATCH] Added Warning and tip about using nextafter etc. [SVN r79721] --- doc/sf_and_dist/float_next.qbk | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/sf_and_dist/float_next.qbk b/doc/sf_and_dist/float_next.qbk index 5c3d16db0..4276d9ce3 100644 --- a/doc/sf_and_dist/float_next.qbk +++ b/doc/sf_and_dist/float_next.qbk @@ -49,6 +49,12 @@ Returns the next representable value after /x/ in the direction of /y/. If a __domain_error. If there is no such value in the direction of /y/ then returns an __overflow_error. +[warning The template parameter FTP must be a floating-point type. +An integer type, for example, will produce an unhelpful error message.] + +[tip Nearly always, you just want the next or prior representable value, +so instead use `float_next` or `float_prior` below.] + [h4 Examples - nextafter] The two representations using a 32-bit float either side of unity are: @@ -88,7 +94,7 @@ returns an __overflow_error. Has the same effect as - nextafter(val, std::numeric_limits::max()); + nextafter(val, (std::numeric_limits::max)()); [endsect] [/section:float_next Finding the Next Greater Representable Value (float_prior)] @@ -117,7 +123,7 @@ returns an __overflow_error. Has the same effect as - nextafter(val, -std::numeric_limits::max()); // Note most negative value -max. + nextafter(val, -(std::numeric_limits::max)()); // Note most negative value -max. [endsect] [/section:float_prior Finding the Next Smaller Representable Value (float_prior)]