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