Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correct endpoints when index is before the epoch
The endpoints C code casts the double index to long, which truncates it toward zero. This behavior is desired when the index is positive, because it moves the endpoint *back* in time. But when the index is negative, truncating toward zero moves the endpoint *forward* in time. This is also an issue if the index value is stored as integer, since the C99 specification states that integer division truncates toward zero. If the first index value is less than zero, branch into a special case to handle pre-epoch index values. This avoids performance degradation if all index values are after the epoch. If the index value is less than zero, simply add 1 to offset the truncation toward zero. We also need to furthre adjust the potential endpoint value if the index is exactly equal to zero. Fixes #144.
- Loading branch information