lua-users home
lua-l archive

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

Luiz Henrique de Figueiredo wrote:
See for a sample
implementation with pointers to whatever is missing.

The implementation of floor works incorrectly for negative x.
The following seems to work OK:

double floor(double x)
  double y;
  if (x >= 0) return (double)(int)x;
  y = (double)(int)(x-1);
  return x - y == 1 ? x : y;