in reply to Re: Re: Eliminating Trailing Zeros
in thread Eliminating Trailing Zeros
now if could just condense those two regexes into one ... but sometimes, brute force is better than cleverness.$n = reverse scalar sprintf("%2.4f",$n); $n =~ s/^0+//g; $n = reverse scalar $n; $n =~ s/\.$//g;
UPDATE: aha!
that was easier than i thought ... unless i missed something [And i did ... glad i retested, because i had forgotten to espace the dot .. bad jeffa. Also, the scalar keywords are not necessary].$n = reverse scalar sprintf("%2.4f",$n); $n =~ s/^0+\.?//g; $n = reverse scalar $n;
And jmcnamara++ ... that's the best solution posted (IMHO) since you already are using sprintf.
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (jeffa) 3Re: Eliminating Trailing Zeros
by pemungkah (Priest) on Jul 17, 2003 at 20:06 UTC | |
by dragonchild (Archbishop) on Jul 17, 2003 at 20:14 UTC |