in reply to sub as mathematical function
Update:sub quant{ # 14 characters, but I am bad at this, I'm sure it can get shorter int((shift)*8) }
sub quant{ int((shift)*8) } for ( 1 .. 9 ) { print "$_ => ", quant( ($_/9) - 0.0001 ), "\n"; }
What do we learn? Test all cases :-)1 => 0 2 => 1 3 => 2 4 => 3 5 => 4 6 => 5 7 => 6 8 => 7 9 => 7 // BOOM!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: sub as mathematical function
by ikegami (Patriarch) on Sep 04, 2019 at 16:29 UTC |