in reply to Some simple math and absolute values
Hi,
I am not a math expert nor an algorithm expert nor a golfer, Perl or otherwise, but maybe something like this?
my $price = ($wt || 1) * 10; $price = 10 * $price/abs($price) if abs($price) < 10;
Output:
perl blrg.pl 2.3 Price: 23 Next Weight: .3 Price: 10 Next Weight: 0 Price: 10 Next Weight: -.3 Price: -10 Next Weight: -2.3 Price: -23 Next Weight:
Hope this helps!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Some simple math and absolute values
by sidmuchrock (Novice) on May 23, 2020 at 14:40 UTC |