DecimalForm

DecimalForm[expr]

prints with approximate real numbers in expr always given in decimal form, without scientific notation.

DecimalForm[expr,n]

prints with approximate real numbers given in decimal form to n-digit precision.

DecimalForm[expr,{n,f}]

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

Details and Options

Examples

open allclose all

Basic Examples  (2)

This approximate number is displayed by default in scientific notation:

Show it in decimal form:

Show all 9 digits:

Display a small length in decimal form:

Scope  (5)

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:

Use fewer digits:

Change the display of numbers in a vector:

A matrix:

Change the display of inexact numbers in a mixed expression:

Options  (8)

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 5digit blocks with spaces as separators:

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:

SignPadding  (1)

The default pads before signs:

Pad between signs and numbers instead:

Properties & Relations  (2)

Like DecimalForm, AccountingForm does not use scientific notation:

They differ in other aspects, like the representation of negative numbers:

NumberForm and PaddedForm have exponents for powers greater than 5:

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

EngineeringForm uses exponents that are multiples of 3:

DecimalForm is effectively equivalent to NumberForm deactivating the option ExponentFunction:

Possible Issues  (1)

Zeros will be added to the left of the decimal point for large numbers with few digits in input:

If the input precision is too small, a message will be issued:

The same message will be issued if few significant digits are requested:

Introduced in 2017
 (11.2)