I am trying to print a number with padding using the function NumberForm in order to get the number format like "01.1234567" where there are 9 significant digits with 7 to the right of the decimal point. This is meant to be similar to the seconds part of a time specification such as "01:15:01.123467". I would have thought this function would achieve the result but I seem to get an extra padded "0" to the left:

ToString@NumberForm[1.1234567, {9, 7}, NumberPadding -> {"0", "0"}]

but instead it returns:


Does anyone have a suggestion as to how I can get the result "01.1234567" using this function or is this a bug and I need to trying an alternative? Many thanks.


1 Answer 1


The extra "0" is added by the default NumberSigns -> {"-",""} option. You can remove it by setting NumberSigns -> {"",""}, but then negative numbers will be displayed without the minus sign:

NumberForm[-1.1234567, {9, 7}, NumberPadding -> {"0", "0"}]
NumberForm[1.1234567, {9, 7}, NumberPadding -> {"0", "0"}]
NumberForm[-1.1234567, {9, 7}, NumberPadding -> {"0", "0"}, NumberSigns -> {"", ""}]




This aspect of behavior of NumberForm isn't documented AFAIK.

  • $\begingroup$ Many thanks!!!! $\endgroup$
    – rfrasier
    Commented Mar 23, 2017 at 9:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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