John Darrington <[EMAIL PROTECTED]> writes:

> On Sat, Nov 25, 2006 at 05:40:08PM -0500, Jason Stover wrote:
>      BSD's math.h has no 'trunc', but both GNU and BSD have
>      'floor' in math.h, so to fix this error on BSD:
>      
>      src/language/stats/chisquare.c:78: undefined reference to `trunc'
>      
>      could we use floor instead?
>
> trunc and floor do different things if the argument is negative.
>
> According to the user documentation, "Non-integer values are
> truncated before classification". I interpret this to mean "towards
> zero".
> I suppose the most portable way is to cast to int and back again, but
> it's not very nice.

I'd suggest checking for trunc with Autoconf, then providing an
implementation based on floor if it doesn't exist, i.e. something
like this:

#ifndef HAVE_TRUNC
double
trunc (double d)
{
  return d >= 0.0 ? floor (d) : -floor (-d);
}
#endif

I do something like this for the "round" function.
-- 
"Mon peu de succès près des femmes est toujours venu de les trop aimer."
--Jean-Jacques Rousseau


_______________________________________________
pspp-dev mailing list
pspp-dev@gnu.org
http://lists.gnu.org/mailman/listinfo/pspp-dev

Reply via email to