NumberForm

NumberForm[expr,n]

prints with approximate real numbers in expr given to ndigit precision.

NumberForm[expr,{n,f}]

prints with approximate real numbers having n digits, with f digits to the right of the decimal point.

NumberForm[expr]

prints using the default options of NumberForm.

Details and Options

Examples

open allclose all

Basic Examples  (2)

Display the first 10 digits of a numeric approximation to :

Display a number with 3 precise digits and 4 digits to the right of the decimal:

Scope  (6)

The default display for a machine number:

Display more digits than the default:

Display fewer digits:

Format a complex number:

Format a high-precision number:

Change the display of numbers in a vector:

A matrix:

Change the display of inexact numbers in a mixed expression:

This number renders in a notebook with two digits of precision:

Force the number to be rendered with default options:

Options  (13)

DefaultPrintPrecision  (1)

By default, machine real numbers are typeset with 6 digits of precision:

Increase to 8 digits:

DigitBlock  (2)

A default integer:

Digits separated in blocks of length 3:

Use fivedigit blocks with spaces as separators:

ExponentFunction  (1)

Compute approximate powers of :

Restrict exponents to multiples of 3:

Include exponents only for powers greater than 10:

ExponentStep  (1)

Default formatting to 10 digits:

Restrict exponent to multiples of 6:

NumberFormat  (1)

Display numbers in a Fortranlike form:

Display only the mantissas:

Display the exponents after converting to scientific form:

NumberMultiplier  (1)

Use the default multiplier ×:

Use an asterisk (*) instead:

NumberPadding  (1)

The default does not pad on the left or right:

Pad with spaces on the left:

Pad with 0s on the right:

NumberPoint  (1)

The default is a period:

Display with a comma (,) instead:

NumberSeparator  (1)

The default separator is a comma (,):

Use spaces instead:

NumberSigns  (1)

The default includes negative signs but not positive signs:

Include positive signs as well:

Use words instead of symbols:

ScientificNotationThreshold  (1)

By default, real numbers between 10-5 and 106 in absolute value are printed in decimal form, and in scientific form otherwise:

Change the transition thresholds:

SignPadding  (1)

The default pads before signs:

Pad between signs and numbers instead:

Applications  (1)

Display numeric approximations of with increasing precision and number of decimal digits:

Display in a tabular form:

Properties & Relations  (5)

NumberForm and PaddedForm use the same mantissas and exponents by default:

ScientificForm has a single digit to the left of the decimal:

EngineeringForm uses exponents that are multiples of 3:

AccountingForm does not have exponents:

Convert a number to base 2:

Represent the number precise to 3 decimal digits in base 2:

Reconstruct the base 10 number precise to 3 digits:

Affect the display of numbers in MatrixForm or TableForm:

The typeset form of NumberForm[expr,n] is interpreted the same as expr when used in input:

Copy the output and paste it into an input cell. The 1.2 is interpreted as 1.23:

When an input evaluates to NumberForm[expr,n], NumberForm does not appear in the output:

Out is assigned the value 1.23, not NumberForm[1.23,2]:

Possible Issues  (2)

Placeholder zeros may be needed if the requested precision is small:

Even when an output omits NumberForm from the top level, it is not stripped from subexpressions:

The output does not have NumberForm in it:

However, the variable e does have NumberForm in it, which may affect subsequent evaluations:

The product is not evaluated due to the intervening NumberForm:

Assign variables first and then apply NumberForm to the result to maintain computability:

Wolfram Research (1988), NumberForm, Wolfram Language function, https://reference.wolfram.com/language/ref/NumberForm.html (updated 2017).

Text

Wolfram Research (1988), NumberForm, Wolfram Language function, https://reference.wolfram.com/language/ref/NumberForm.html (updated 2017).

CMS

Wolfram Language. 1988. "NumberForm." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2017. https://reference.wolfram.com/language/ref/NumberForm.html.

APA

Wolfram Language. (1988). NumberForm. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NumberForm.html

BibTeX

@misc{reference.wolfram_2024_numberform, author="Wolfram Research", title="{NumberForm}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/NumberForm.html}", note=[Accessed: 26-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_numberform, organization={Wolfram Research}, title={NumberForm}, year={2017}, url={https://reference.wolfram.com/language/ref/NumberForm.html}, note=[Accessed: 26-December-2024 ]}