xref: /netbsd/lib/libm/man/nextafter.3 (revision 903ded23)
1*903ded23Smgorny.\" $NetBSD: nextafter.3,v 1.8 2019/05/02 15:08:35 mgorny Exp $
2d55ba54aSjruoho.\"
3d55ba54aSjruoho.\" Copyright (c) 2011 Jukka Ruohonen <jruohonen@iki.fi>
4d55ba54aSjruoho.\" All rights reserved.
5d55ba54aSjruoho.\"
6d55ba54aSjruoho.\" Redistribution and use in source and binary forms, with or without
7d55ba54aSjruoho.\" modification, are permitted provided that the following conditions
8d55ba54aSjruoho.\" are met:
9d55ba54aSjruoho.\" 1. Redistributions of source code must retain the above copyright
10d55ba54aSjruoho.\"    notice, this list of conditions and the following disclaimer.
11d55ba54aSjruoho.\" 2. Redistributions in binary form must reproduce the above copyright
12d55ba54aSjruoho.\"    notice, this list of conditions and the following disclaimer in the
13d55ba54aSjruoho.\"    documentation and/or other materials provided with the distribution.
14d55ba54aSjruoho.\"
15d55ba54aSjruoho.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16d55ba54aSjruoho.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17d55ba54aSjruoho.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18d55ba54aSjruoho.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19d55ba54aSjruoho.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20d55ba54aSjruoho.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21d55ba54aSjruoho.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22d55ba54aSjruoho.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23d55ba54aSjruoho.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24d55ba54aSjruoho.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25d55ba54aSjruoho.\" POSSIBILITY OF SUCH DAMAGE.
26d55ba54aSjruoho.\"
2723ffb1d5She.Dd September 13, 2015
28d55ba54aSjruoho.Dt NEXTAFTER 3
29d55ba54aSjruoho.Os
30d55ba54aSjruoho.Sh NAME
31d55ba54aSjruoho.Nm nextafter ,
32d55ba54aSjruoho.Nm nextafterf ,
33d55ba54aSjruoho.Nm nextafterl ,
3423ffb1d5She.Nm nexttoward ,
355d46b39dSkamil.Nm nexttowardf ,
365d46b39dSkamil.Nm nexttowardl
37d55ba54aSjruoho.Nd next representable floating-point number
38d55ba54aSjruoho.Sh LIBRARY
39d55ba54aSjruoho.Lb libm
40d55ba54aSjruoho.Sh SYNOPSIS
41d55ba54aSjruoho.In math.h
42d55ba54aSjruoho.Ft double
43d55ba54aSjruoho.Fn nextafter "double x" "double y"
44d55ba54aSjruoho.Ft float
45d55ba54aSjruoho.Fn nextafterf "float x" "float y"
46d55ba54aSjruoho.Ft long double
47d55ba54aSjruoho.Fn nextafterl "long double x" "long double y"
48d55ba54aSjruoho.Ft double
49d55ba54aSjruoho.Fn nexttoward "double x" "long double y"
5023ffb1d5She.Ft float
5123ffb1d5She.Fn nexttowardf "float x" "long double y"
525d46b39dSkamil.Ft long double
535d46b39dSkamil.Fn nexttowardl "long double x" "long double y"
54d55ba54aSjruoho.Sh DESCRIPTION
55d55ba54aSjruohoThe
56d55ba54aSjruoho.Fn nextafter ,
57d55ba54aSjruoho.Fn nextafterf ,
58d55ba54aSjruohoand
59d55ba54aSjruoho.Fn nextafterl
60d55ba54aSjruohofunctions return the next machine representable number from
61d55ba54aSjruoho.Fa x
62d55ba54aSjruohoin direction of
63d55ba54aSjruoho.Fa y .
64d55ba54aSjruohoIn other words, if
65d55ba54aSjruoho.Fa y
66d55ba54aSjruohois less than
67d55ba54aSjruoho.Fa x ,
68d55ba54aSjruohothe functions return the largest representable floating-point number less than
69d55ba54aSjruoho.Fa x .
70d55ba54aSjruohoWhen
71d55ba54aSjruoho.Fa x
72d55ba54aSjruohoequals
73d55ba54aSjruoho.Fa y ,
74d55ba54aSjruohothe value of
75d55ba54aSjruoho.Fa y
76d55ba54aSjruohois returned.
77d55ba54aSjruohoThe three functions differ only in the type of the return value and
78d55ba54aSjruoho.Fa x .
79d55ba54aSjruoho.Pp
80d55ba54aSjruohoThe
81*903ded23Smgorny.Fn nexttoward
825d46b39dSkamiland
83*903ded23Smgorny.Fn nexttowardf
8423ffb1d5Shefunctions are equivalent to the
85d55ba54aSjruoho.Fn nextafter
86d55ba54aSjruohofamily of functions with two exceptions:
87d55ba54aSjruoho.Bl -enum -offset indent
88d55ba54aSjruoho.It
89d55ba54aSjruohoThe second parameter has a type
90d55ba54aSjruoho.Vt long double .
91d55ba54aSjruoho.It
92d55ba54aSjruohoThe return value is
93d55ba54aSjruoho.Fa y
94d55ba54aSjruohoconverted to the type of the function, provided that
95d55ba54aSjruoho.Fa x
96d55ba54aSjruohoequals
97d55ba54aSjruoho.Fa y .
98cf7740e9Schristos.El
99*903ded23Smgorny.Pp
100*903ded23Smgorny.Fn nexttowardl
101*903ded23Smgornyis equivalent to
102*903ded23Smgorny.Fn nextafterl .
103d55ba54aSjruoho.Sh RETURN VALUES
104d55ba54aSjruohoUpon successful completion, the described functions return
105d55ba54aSjruohothe next representable floating-point value as described above.
106d55ba54aSjruohoIf
107d55ba54aSjruoho.Fa x
108d55ba54aSjruohois finite but an overflow would occur,
109d55ba54aSjruohoa range error follows and the functions return
110290b9139Swiz.Dv \*(PmHUGE_VAL ,
111290b9139Swiz.Dv \*(PmHUGE_VALF ,
112d55ba54aSjruohoor
113290b9139Swiz.Dv \*(PmHUGE_VALL
114d55ba54aSjruohowith the same sign as
115d55ba54aSjruoho.Fa x .
116d55ba54aSjruohoWhen either
117d55ba54aSjruoho.Fa x
118d55ba54aSjruohoor
119d55ba54aSjruoho.Fa y
120d55ba54aSjruohois \*(Na, a \*(Na is returned.
121d55ba54aSjruohoWhen
122d55ba54aSjruoho.Fa x
123d55ba54aSjruohois not
124d55ba54aSjruoho.Fa y
125d55ba54aSjruohobut the function value is subnormal, zero, or underflows,
126d55ba54aSjruohoa range error occurs, and either 0.0 or the correct function
127d55ba54aSjruohovalue (if representable) is returned.
128d55ba54aSjruoho.Sh SEE ALSO
129d55ba54aSjruoho.Xr math 3
130d55ba54aSjruoho.Sh STANDARDS
131d55ba54aSjruohoThe described functions conform to
132d55ba54aSjruoho.St -isoC-99 .
133