PercentForm
PercentForm[expr]
prints with numbers in expr given as percentages.
PercentForm[expr,n]
prints with approximate real numbers in expr given as percentages to n-digit precision.
Details and Options
- PercentForm[x,{n,f}] displays with approximate real numbers having n digits, with f digits to the right of the decimal point.
- PercentForm works on integers as well as approximate real numbers.
- The following options can be given:
-
DefaultPrintPrecision 4 default print digits for machine numbers DigitBlock Infinity number of digits between breaks NumberPadding {"",""} strings to use for left and right padding NumberPoint Automatic decimal point string NumberSeparator {",", " "} string to insert at breaks between blocks SignPadding {False,True} whether to pad inside the number sign and percent sign - The typeset form of PercentForm[expr] is interpreted the same as expr when used in input. »
- When an input evaluates to PercentForm[expr], PercentForm does not appear in the output. »
Examples
open allclose allScope (3)
Numbers of any size and sign can be shown in percent form:
PercentForm works on integers:
PercentForm does not work on rational or complex numbers:
Options (8)
DefaultPrintPrecision (1)
NumberPadding (2)
NumberPoint (1)
SignPadding (2)
The default pads before signs:
Pad between signs and numbers instead:
PercentForm by default pads before the - and % signs:
Properties & Relations (4)
PercentForm never uses scientific form:
Quantity can be used to work with percentages:
Represent that number using PercentForm:
The typeset form of PercentForm[expr] is interpreted the same as expr when used in input:
Copy the output and paste it into an input cell. The 50% is interpreted as 0.5:
When an input evaluates to PercentForm[expr], PercentForm does not appear in the output:
Out is assigned the value 0.5, not PercentForm[0.5]:
Possible Issues (2)
Placeholder zeros may be needed if the requested precision is small:
Even when an output omits PercentForm from the top level, it is not stripped from subexpressions:
The output does not have PercentForm in it:
However, the variable e does have PercentForm in it, which may affect subsequent evaluations:
The product is not evaluated due to the intervening PercentForm:
Assign variables first and then apply PercentForm to the result to maintain computability:
Text
Wolfram Research (2019), PercentForm, Wolfram Language function, https://reference.wolfram.com/language/ref/PercentForm.html.
CMS
Wolfram Language. 2019. "PercentForm." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/PercentForm.html.
APA
Wolfram Language. (2019). PercentForm. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PercentForm.html