Wolfram Research

Function Repository Resource:

MixedNumberForm

Source Notebook

Represent an improper fraction in mixed form

Contributed by: Igor Bakshee

ResourceFunction["MixedNumberForm"][expr]

prints all improper fractions in expr as mixed numbers.

Details and Options

ResourceFunction["MixedNumberForm"] acts as a wrapper, which affects printing, but not evaluation.
Typeset numbers in ResourceFunction["MixedNumberForm"][p/q] can be used directly for input to the Wolfram Language.

Examples

Basic Examples

Represent an improper fraction as a mixed number:

In[1]:=
ResourceFunction["MixedNumberForm"][3/2]
Out[1]=
In[2]:=
ResourceFunction["MixedNumberForm"][10/3]
Out[2]=

Scope


Print all improper fractions in expressions as mixed numbers:

In[3]:=
(f[3/2] + g[7/5]) // ResourceFunction["MixedNumberForm"]
Out[3]=

Applications

Print a cooking recipe:

In[4]:=
StringForm["Add `` spoons of sugar.", ResourceFunction["MixedNumberForm"][3/2]]
Out[4]=

Properties and Relations

The MixedNumberForm wrapper disappears on evaluation:

In[5]:=
ResourceFunction["MixedNumberForm"][3/2]
Out[5]=
In[6]:=
%
Out[6]=

Expressions in MixedNumberForm allow copying and pasting in input cells:

In[7]:=
1 + 1 
If[ToExpression["1"] >= 0, "+", "-"] 1/2
Out[7]=

Expressions in MixedNumberForm can be edited:

In[8]:=
{1 
If[ToExpression["1"] >= 0, "+", "-"] 1/2, 2 
If[ToExpression["2"] >= 0, "+", "-"] 1/2, 1 
If[ToExpression["1"] >= 0, "+", "-"] 5/2, 1 
If[ToExpression["1"] >= 0, "+", "-"] 1/4}
Out[8]=

Resource History

Source Metadata

Related Resources

License Information