Split the nextafter(3) family of functions to their own page and properly

document these.
This commit is contained in:
jruoho 2011-04-12 07:29:50 +00:00
parent 8ee666bc1f
commit 9305ee0c33
3 changed files with 157 additions and 37 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.104 2011/02/06 00:44:09 christos Exp $
# $NetBSD: Makefile,v 1.105 2011/04/12 07:29:50 jruoho Exp $
#
# @(#)Makefile 5.1beta 93/09/24
#
@ -203,7 +203,7 @@ COPTS.s_tanh.c+= -O0
MAN+= acos.3 acosh.3 asin.3 asinh.3 atan.3 atan2.3 atanh.3 ceil.3 \
cos.3 cosh.3 erf.3 exp.3 fabs.3 floor.3 fmod.3 frexp.3 hypot.3 ieee.3 \
ieee_test.3 isinff.3 j0.3 ldexp.3 lgamma.3 lrint.3 \
math.3 modf.3 rint.3 round.3 sin.3 sinh.3 \
math.3 modf.3 nextafter.3 rint.3 round.3 sin.3 sinh.3 \
sqrt.3 tan.3 tanh.3 trunc.3 fmax.3 fdim.3
# fenv.h interface
@ -244,8 +244,6 @@ MLINKS+=hypot.3 hypotf.3
MLINKS+=ieee.3 copysign.3 ieee.3 copysignf.3 ieee.3 copysignl.3 \
ieee.3 finite.3 ieee.3 finitef.3 \
ieee.3 ilogb.3 ieee.3 ilogbf.3 \
ieee.3 nextafter.3 ieee.3 nextafterf.3 ieee.3 nextafterl.3 \
ieee.3 nexttoward.3 \
ieee.3 remainder.3 ieee.3 remainderf.3 \
ieee.3 remquo.3 ieee.3 remquof.3 \
ieee.3 scalbn.3 ieee.3 scalbnf.3
@ -258,6 +256,9 @@ MLINKS+=j0.3 j0f.3 j0.3 j1.3 j0.3 j1f.3 j0.3 jn.3 j0.3 jnf.3 \
MLINKS+=lgamma.3 lgammaf.3 lgamma.3 lgamma_r.3 lgamma.3 lgammaf_r.3 \
lgamma.3 gamma.3 lgamma.3 gammaf.3 lgamma.3 gamma_r.3 \
lgamma.3 gammaf_r.3
MLINKS+=nextafter.3 nextafterf.3 \
nextafter.3 nextafterl.3 \
nextafter.3 nexttoward.3
MLINKS+=lrint.3 lrintf.3 lrint.3 llrint.3 lrint.3 llrintf.3
MLINKS+=rint.3 rintf.3
MLINKS+=sin.3 sinf.3

View File

@ -26,9 +26,9 @@
.\" SUCH DAMAGE.
.\"
.\" from: @(#)ieee.3 6.4 (Berkeley) 5/6/91
.\" $NetBSD: ieee.3,v 1.22 2011/02/06 00:44:10 christos Exp $
.\" $NetBSD: ieee.3,v 1.23 2011/04/12 07:29:50 jruoho Exp $
.\"
.Dd February 25, 1994
.Dd April 12, 2011
.Dt IEEE 3
.Os
.Sh NAME
@ -39,10 +39,6 @@
.Nm finitef ,
.Nm ilogb ,
.Nm ilogbf ,
.Nm nextafter ,
.Nm nextafterf ,
.Nm nextafterl ,
.Nm nexttoward ,
.Nm remainder ,
.Nm remainderf ,
.Nm scalbn ,
@ -67,14 +63,6 @@
.Ft int
.Fn ilogbf "float x"
.Ft double
.Fn nextafter "double x" "double y"
.Ft float
.Fn nextafterf "float x" "float y"
.Ft long double
.Fn nextafterl "long double x" "long double y"
.Ft double
.Fn nexttoward "double x" "long double y"
.Ft double
.Fn remainder "double x" "double y"
.Ft float
.Fn remainderf "float x" "float y"
@ -122,24 +110,6 @@ and
returns
.Dv INT_MIN .
.Pp
.Fn nextafter
returns the next machine representable number from
.Fa x
in direction
.Fa y .
.Pp
.Fn nexttoward
is equivalent to
.Fn nextafter ,
except that the second parameter has type
.Ft long double
and the function returns
.Dv y
converted to the type of the function if
.Dv x
equals
.Dv y .
.Pp
.Fn remainder
returns the remainder
.Fa r
@ -199,7 +169,8 @@ returns
.Fa x Ns \(**(2** Ns Fa n )
computed by exponent manipulation.
.Sh SEE ALSO
.Xr math 3
.Xr math 3 ,
.Xr nextafter 3
.Sh STANDARDS
.St -ieee754
.Sh HISTORY

148
lib/libm/man/nextafter.3 Normal file
View File

@ -0,0 +1,148 @@
.\" $NetBSD: nextafter.3,v 1.1 2011/04/12 07:29:50 jruoho Exp $
.\"
.\" Copyright (c) 2011 Jukka Ruohonen <jruohonen@iki.fi>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd April 12, 2011
.Dt NEXTAFTER 3
.Os
.Sh NAME
.Nm nextafter ,
.Nm nextafterf ,
.Nm nextafterl ,
.Nm nexttoward
.\"
.\" XXX: Not yet implemented.
.\"
.\" .Nm nexttowardf ,
.\" .Nm nexttowardl
.\"
.Nd next representable floating-point number
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn nextafter "double x" "double y"
.Ft float
.Fn nextafterf "float x" "float y"
.Ft long double
.Fn nextafterl "long double x" "long double y"
.Ft double
.Fn nexttoward "double x" "long double y"
.Sh DESCRIPTION
The
.Fn nextafter ,
.Fn nextafterf ,
and
.Fn nextafterl
functions return the next machine representable number from
.Fa x
in direction of
.Fa y .
In other words, if
.Fa y
is less than
.Fa x ,
the functions return the largest representable floating-point number less than
.Fa x .
When
.Fa x
equals
.Fa y ,
the value of
.Fa y
is returned.
The three functions differ only in the type of the return value and
.Fa x .
.Pp
The
.Fn nexttoward
function is equivalent to the
.Fn nextafter
family of functions with two exceptions:
.Bl -enum -offset indent
.It
The second parameter has a type
.Vt long double .
.It
The return value is
.Fa y
converted to the type of the function, provided that
.Fa x
equals
.Fa y .
.Sh RETURN VALUES
Upon successful completion, the described functions return
the next representable floating-point value as described above.
If
.Fa x
is finite but an overflow would occur,
a range error follows and the functions return
.Dv \*(Pm\* HUGE_VAL ,
.Dv \*(Pm\* HUGE_VALF ,
or
.Dv \*(Pm\* HUGE_VALL
with the same sign as
.Fa x .
When either
.Fa x
or
.Fa y
is \*(Na, a \*(Na is returned.
When
.Fa x
is not
.Fa y
but the function value is subnormal, zero, or underflows,
a range error occurs, and either 0.0 or the correct function
value (if representable) is returned.
.Sh SEE ALSO
.Xr ieee 3 ,
.Xr math 3
.Sh STANDARDS
The described functions conform to
.St -isoC-99 .
.\"
.\" XXX: Verify this.
.\"
.\" The
.\" .Fn nextafter
.\" function is also recommended by
.\" .St -ieee754
.\"
.\" .Sh HISTORY
.\"
.\" XXX: Fill this.
.\" These functions first appeared in
.\" .Bx 4.3 .
.Sh BUGS
Currently the
.Vt float
and
.Vt long double
variants of
.Fn nexttoward
are not supported in
.Nx .