Find the largest float f such as `f * 10**scale <= val`
(val, scale)
| 2319 | |
| 2320 | |
| 2321 | def largest_scaled_float_not_above(val, scale): |
| 2322 | """ |
| 2323 | Find the largest float f such as `f * 10**scale <= val` |
| 2324 | """ |
| 2325 | assert val >= 0 |
| 2326 | assert scale >= 0 |
| 2327 | float_val = float(val) / 10**scale |
| 2328 | if float_val * 10**scale > val: |
| 2329 | # Take the float just below... it *should* satisfy |
| 2330 | float_val = np.nextafter(float_val, 0.0) |
| 2331 | if float_val * 10**scale > val: |
| 2332 | float_val = np.nextafter(float_val, 0.0) |
| 2333 | assert float_val * 10**scale <= val |
| 2334 | return float_val |
| 2335 | |
| 2336 | |
| 2337 | def scaled_float(int_val, scale): |
no outgoing calls
no test coverage detected