You spotted the bug, but not the solution. You can't "scale" 0 to 1, you have to offset it. To handle that you would need to add another test to the code and adjust $min in the $min == $max special case:
$min -= 1 if $min == $max;
You can however offset anything to 0, so the bug fix has that result.
In reply to Re^2: Normalise numbers
by GrandFather
in thread Normalise numbers
by GrandFather
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |