It also fails for a lot of numbers between the ones you tested (e.g. 0.112 should return 1 but returns 0, 0.23 should return 2 but returns 1, etc).
The fix is simple: Replace 8 with 9 :)
Of course, that assumes the input is in range [0..1), but that seems a sure thing.
In reply to Re^2: sub as mathematical function
by ikegami
in thread sub as mathematical function
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |