Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #12609 > unrolled thread
| Started by | Gregory Lypny <gregory.lypny@videotron.ca> |
|---|---|
| First post | 2012-12-04 09:10 +0000 |
| Last post | 2012-12-04 09:10 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Creating a Function to Display Numbers in Percent Format Gregory Lypny <gregory.lypny@videotron.ca> - 2012-12-04 09:10 +0000
| From | Gregory Lypny <gregory.lypny@videotron.ca> |
|---|---|
| Date | 2012-12-04 09:10 +0000 |
| Subject | Re: Creating a Function to Display Numbers in Percent Format |
| Message-ID | <k9keli$693$1@smc.vnet.net> |
Thanks Bob,
Good suggestion using Row because it allows for easier extraction of the actual number. My original fix used StringForm. Although, it is still not clear to me why appending a percent sign cannot be done through the second elements of each of the two lists in NumberSigns -> {{"-", "%"}, {"", "%"}}.
Gregory
On Sun, Dec 2, 2012, at 12:53 PM, Bob Hanlon <hanlonr357@gmail.com> wrote:
> Clear[percent]
>
> percent[x_, numDec : _Integer?NonNegative : 1] :=
> Row[{
> PaddedForm[100 x, {500, numDec},
> NumberPoint -> If[numDec == 0, "", "."],
> DigitBlock -> {3, Infinity},.
> ExponentStep -> Infinity,
> NumberPadding -> {"", "0"}],
> "%"}]
>
>
> Table[percent[.0237, n], {n, 0, 6}]
>
> {2%, 2.4%, 2.37%, 2.370%, 2.3700%, 2.37000%, 2.370000%}
>
>
> Bob Hanlon
>
>
> On Sun, Dec 2, 2012 at 4:57 AM, Gregory Lypny
> <gregory.lypny@videotron.ca> wrote:
>> Hello everyone,
>>
>> I've written a function to display numbers in percent format.
>>
>> percent[x_, numDec_: 1] :=
>> PaddedForm[100 x, {500, numDec}, NumberPoint -> If[numDec == 0, "", "."],
>> DigitBlock -> {3, Infinity}, ExponentStep -> Infinity,
>> NumberSigns -> {{"-", "%"}, {"", "%"}}, NumberPadding -> {"", "0"}];
>>
>> The problem with it is that the padding on the right appears after the percent sign so that percent[.0237, 6] returns 2.37%0000. What am I doing wrong?
>>
>> Regards,
>>
>> Gregory
>>
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web