Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Displaying Mixed Numbers

  • To: mathgroup at
  • Subject: [mg25144] Re: Displaying Mixed Numbers
  • From: paulh at (P.J. Hinton)
  • Date: Sun, 10 Sep 2000 21:25:39 -0400 (EDT)
  • Organization: "Wolfram Research, Inc."
  • References: <8pfdta$>
  • Sender: owner-wri-mathgroup at

In article <8pfdta$cuu at>,
 Jim Graber <jgraber at> writes:

> While working with my third grader, I discovered the need
> to make 5/3 display and print as 1 2/3 so she can check her
> homework.
> I couldn't find a way to do this easily, so I wrote the following which
> does the job.  Is there an easier or better way?
> Thanks.  Jim Graber
> Mix1[x_] := { Quotient[Numerator[x], Denominator[x]],
>     Mod[Numerator[x], Denominator[x]]/Denominator[x]}
> Mix[x_] := Print[Mix1[x][[1]], Mix1[x][[2]]];

You may want to try adding a special formatting rule for Rational[]
when the numerator is greater than the denominator.


Format[Rational[num_Integer, den_Integer], StandardForm] := 
        ToString[Quotient[num, den]],
        FractionBox[ToString[Mod[num, den]], ToString[den]]
  ] /; num > den


P.J. Hinton
User Interface Programmer                         paulh at
Wolfram Research, Inc.
Disclaimer: Opinions expressed herein are those of the author alone.

  • Prev by Date: Re: NonlinearRegression
  • Next by Date: Re: Faulty feature of Factor?
  • Previous by thread: Re: Displaying Mixed Numbers
  • Next by thread: RE: Displaying Mixed Numbers