| 221 | } |
| 222 | |
| 223 | static inline npy_int64 |
| 224 | rational_floor(rational x) { |
| 225 | /* Always round down */ |
| 226 | if (x.n>=0) { |
| 227 | return x.n/d(x); |
| 228 | } |
| 229 | /* |
| 230 | * This can be done without casting up to 64 bits, but it requires |
| 231 | * working out all the sign cases |
| 232 | */ |
| 233 | return -((-(npy_int64)x.n+d(x)-1)/d(x)); |
| 234 | } |
| 235 | |
| 236 | static inline npy_int64 |
| 237 | rational_ceil(rational x) { |
no test coverage detected