[cfp-interest 3938] nexttoward()

Damian McGuckin damianm at esi.com.au
Thu May 14 20:58:35 PDT 2026


Hubert's email says:

The description of nexttoward has:

 	The nexttoward functions are equivalent to the nextafter functions
 	except that the second parameter has type long double or
 	_Decimal128 and the functions return the numerical value resulting
 	from converting y to the return type of the function if x equals y

and the description of nextafter has:

 	The nextafter functions determine the next representable value, in
 	the return type of the function, after x in the direction of y,
 	where x and y are first converted to the return type of the
 	function. The nextafter functions return the numerical value of y
 	if x equals y.

Hubert suggests:

 	The nexttoward wording establishes that its second parameter has a
 	different type than that of nextafter, but it does not establish
 	that the second parameter is not "first converted to the return
 	type of the function".
and
 	Perhaps the description of nextafter should say "where each of x
 	and y is first converted to the type of the respective parameter"?

The problem is the wording of nextafter is Hubert hints at. The problem is 
thatr Hubert is thinking that x and y are arguments. They are parameters 
so they already have the return type of the function so there is no need 
of any conversion.. The is not the first time, as we saw in the April 
meeting, that there is confusion between arguments and parameters.

I would argue that the words

 	where x and y are first converted to the return type of the
 	function.

are superfluous and can be deleted.  That conversion never occurs.

And if one has a macro definition of nextafter(), then surely it is the 
responsibility of the implementation of the macro to ensure that this 
macro emulates what happens across a function call and converts any 
argument to the type of the equivalent parameter without words to spell 
that out somehow needing to appear in 7.12.12.3.

Or, we could take a radical approach:

Given that the IEEE 754 1985 functional of nextafter() was replaced 2 
decades ago in IEEE 754 2008 and 2019 with the pair of routines nextup() 
and nextdown(), and that nexttoward() is purely a feature of ISO/IEC 
60559, can it be deprecated.

Is there a mechanism for this sort of thing?

Thanks - Damian


More information about the cfp-interest mailing list