| 300 | // Integer division, like the "/" operator but always rounds result down. |
| 301 | |
| 302 | long Dvd(long x, long y) |
| 303 | { |
| 304 | long z; |
| 305 | |
| 306 | if (y == 0) |
| 307 | return x; |
| 308 | z = x / y; |
| 309 | if (((x >= 0) == (y >= 0)) || x-z*y == 0) |
| 310 | return z; |
| 311 | return z - 1; |
| 312 | } |
| 313 | |
| 314 | |
| 315 | // Lookup a string within a table (case insensitively) returning the index |