in reply to sub as mathematical function
> input: float 0 to 1 inclusive
It's int(9*$v)
Corrected off by one
Corrected correction ;)
The edge case 1=9/9 needs special treatment. Are you sure 8 is the maximum?
If yes max(8,int(9*$v))
max needs to be imported. (POSIX?)
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: sub as mathematical function
by Anonymous Monk on Sep 04, 2019 at 12:29 UTC | |
by LanX (Saint) on Sep 04, 2019 at 13:08 UTC | |
by davido (Cardinal) on Sep 04, 2019 at 18:12 UTC | |
by LanX (Saint) on Sep 04, 2019 at 21:15 UTC | |
by rsFalse (Chaplain) on Sep 04, 2019 at 17:06 UTC |