lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> lmathx [1] fails compilation under Cygwin:

Thanks for the report.
 
> +#ifdef HAVE_NEXTTOWARD
>  static int Lnexttoward(lua_State *L)
>  {
>    lua_pushnumber(L,nexttoward(A(1),A(2)));
>    return 1;
>  }
> +#endif

A simpler patch (with less #if) is this:
 
>  static int Lnexttoward(lua_State *L)
>  {
> +#ifdef HAVE_NEXTTOWARD
>    lua_pushnumber(L,nexttoward(A(1),A(2)));
>    return 1;
> +#else
> +  return 0;
> +#endif
>  }

Or even this:
	#define nexttoward	nextafter

> BTW, it's not clear to me when nexttoward is useful over nextafter.
> Moreover, nexttoward has a signature using "long double", but lmathx
> treats double and long double both as a lua_Number.

You have a point. I hadn't notice that "The nexttoward() functions do
the same as the nextafter() functions, except that they have a long
double second argument." as the man page says.

nexttoward should have been named nextafterll or something like that...

I just wrote a binding based on all functions listed in
	http://www.dinkumware.com/manuals/default.aspx?manual=compleat&page=math.htm

and that page does not contain the man page remark.

I wonder whether there are other functions that cater only for long doubles.

Anyway, I think I'll just remove nexttoward from lmathx if no one minds.
--lhf