From: SMiranda on
There's an easy way of formating percentage numbers form reporting
purposes...
I mean... 0.05263 --> 5.26%

Thanks !

From: Murray Eisenberg on
You may be treading on dangerous ground here, since the percent sign %
in Mathematica refers to the preceding Output! So do be aware that with
some things you might do to include % in output, the result should be
regarded as just a display format and not as something you want to feed
into subsequent evaluations.

So here goes. Assuming you don't want to do your own conversion from
decimal fraction into percentage, I looked up "percent" in the
Documentation Center and found it in the Units package. Thus:

Needs["Units`"]

Convert[0.05263, Percent]
5.263 Percent

And then for the actual form you want, the most direct way is:

percentage = Convert[0.05263, Percent] /. Percent -> "%"
5.263 %

Notice that this output includes a space before the percent sign. That's
not just an accident, because there's actually a product there, as is
revealed by:

FullForm[percentage]
Times[5.263`,"%"]

And this means you CAN use this kind of percent representation in
further evaluation -- although I'd be cautious as to how far to go. For
example:

twice = 2 * percentage
10.526 %

To go back to decimals, you have to be careful, because at this point
the percent sign is being carried as just a text character. So you need
first to change that text character into the symbol Percent:

Convert[twice /. "%" -> Percent, Real]
0.10526


On 7/17/2010 8:16 AM, SMiranda wrote:
> There's an easy way of formating percentage numbers form reporting
> purposes...
> I mean... 0.05263 --> 5.26%
>
> Thanks !
>

--
Murray Eisenberg murray(a)math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305

From: Bill Rowe on
On 7/17/10 at 8:16 AM, sebastian.mirandadiaz(a)gmail.com (SMiranda)
wrote:

>There's an easy way of formating percentage numbers form reporting
>purposes... I mean... 0.05263 --> 5.26%

Here is one way

In[6]:= ToString[NumberForm[0.05263 100, 3]] <> "%"

Out[6]= 5.26%

Note, this will not display all values to an accuracy of 0.01%
since it only retains 3 significant digits. Another method would be:

In[7]:= ToString[Round[0.05263 100, .01]] <> "%"

Out[7]= 5.26%

which will display all values to an accuracy of 0.01%.


From: Christoph Lhotka on
PercentageForm[x_ /; 0 <= x <= 1] :=
StringReplace[ToString[IntegerPart[10000 x]/100.] <> "%",
".%" -> ".00%"]

best regards...

On 17/07/2010 14:16, SMiranda wrote:
> There's an easy way of formating percentage numbers form reporting
> purposes...
> I mean... 0.05263 --> 5.26%
>
> Thanks !
>
>


From: SMiranda on

Thank you all !!

I think this is now more complicated as I have to decide which
solution I'll implement... :-)

regards


On 18 jul, 07:05, "Christoph Lhotka" <lho...(a)axp.mat.uniroma2.it>
wrote:
> PercentageForm[x_ /; 0 <= x <= 1] :=
> StringReplace[ToString[IntegerPart[10000 x]/100.] <> "%",
> ".%" -> ".00%"]
>
> best regards...
>
> On 17/07/2010 14:16, SMiranda wrote:
>
>
>
> > There's an easy way of formating percentage numbers form reporting
> > purposes...
> > I mean... 0.05263 --> 5.26%
>
> > Thanks !