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 would like to display numbers like 9.0001 and 10.0001 in the fixed-width form of xx.xxxx. This seems like a perfect job for:

NumberForm[#, {6, 4}, NumberPadding -> {"0", "0"}] & /@ {9.0001, 10.0001}

But this returns {009.0001, 010.0001}, which has one extra leading zero.

Reducing the number of digits doesn't fix this.

NumberForm[#, {5, 4}, NumberPadding -> {"0", "0"}] & /@ {9.0001, 10.0001}


Why is at least one copy of the left NumberPadding always being added, even when this makes the total number of digits exceed n, the desired total number of digits?

share|improve this question
@MikeHoneychurch, thanks for the reminder. While your answer contains a good solution to the problem, m_goldberg's answers the exact question. – ArgentoSapiens May 20 '14 at 11:48
up vote 1 down vote accepted

I think Mathematica is padding one extra position on the left to preserve space for a possible minus sign.

NumberForm[#, {6, 4}, NumberPadding -> {"*", "0"}] & /@ 
  {1234.567, -1234.567, 12.34567, -12.34567, 1.234567, -1.234567}
 {*1234.5700, -1234.5700, *12.3457, -12.3457, **1.2346, *-1.2346}
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.