Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this output:

(323909701210368 Sqrt[3] t^(56/3))/(11 Gamma[2/3] Gamma[59/3]) + (
 23266815064996478976000 t^(71/3))/(Gamma[2/3] Gamma[74/3])

I want to have numbers just with 3 digits. For example:

(323 Sqrt[3] t^(56/3))/(11 Gamma[2/3] Gamma[59/3]) + (
 232 t^(71/3))/(Gamma[2/3] Gamma[74/3])

Any suggestion?

share|improve this question
up vote 8 down vote accepted

A truly weird question! I cant imagine why you would want to do that but here goes..

f[i_] := FromDigits[IntegerDigits[i][[;; 3]]];
((323909701210368 Sqrt[3] t^(56/3))/(11 Gamma[2/3] Gamma[
       59/3]) + (23266815064996478976000 t^(71/3))/(Gamma[2/3] Gamma[
       74/3])) /. 
 {Rational[x_Integer /; x > 1000, y_] :> f[x]/y, x_Integer /; x > 1000 :> f[x]}

(323*Sqrt[3]*t^(56/3))/(11*Gamma[2/3]*Gamma[59/3]) + (232*t^(71/3))/(Gamma[2/3]*Gamma[74/3])

share|improve this answer
maybe x>999 instead of x>1000? – AccidentalFourierTransform Mar 29 at 17:12
Many many thanks. – user37694 Mar 29 at 20:32

This goes and modifies the displayed box form. Please note that this is not meant to be used as input to other computations, just for display - so it's similar to MatrixForm in that sense.


ShortIntegerForm[expr_] := 
 ToBoxes@expr /. 
   n_String /; 
     StringMatchQ[n, Repeated[DigitCharacter, {4, \[Infinity]}]] :> 
    Tooltip[StringJoin[StringTake[n, 3], 
      "\[InvisibleSpace]\[Ellipsis]"], ToExpression@n] // DisplayForm

Now you can apply this form to your expression:

(323909701210368 Sqrt[3] t^(56/3))/(11 Gamma[2/3] Gamma[
      59/3]) + (23266815064996478976000 t^(71/3))/(Gamma[2/3] Gamma[
      74/3]) // ShortIntegerForm

enter image description here

As an added bonus, Tooltip shows the full value if you take your mouse pointer over the short form.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.