* Computes the largest integer value not greater than the float one * * This method is faster than using (int32_t)std::floor(fp). * * I measured it to be approximately twice as fast: * float: ~18.4ns instead of ~39.6ns on an AMD APU), * double: ~20.6ns instead of ~36.6ns on an AMD APU), * Reference: http://www.codeproject.com/Tips/700780/Fast-floor-ceiling-functions * * @param[in] fp
| 44 | * @return largest integer value not greater than fp |
| 45 | */ |
| 46 | static inline int32_t fastfloor(float fp) { |
| 47 | int32_t i = static_cast<int32_t>(fp); |
| 48 | return (fp < i) ? (i - 1) : (i); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Permutation table. This is just a random jumble of all numbers 0-255. |