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  (4)

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:

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

Copy the output and paste it into an input cell. The 1000000. is interpreted as 1.`*^6:

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

Out is assigned the value 1.`*^6, not DecimalForm[10.^6]:

Possible Issues  (2)

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:

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

The output does not have DecimalForm in it:

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

The product is not evaluated due to the intervening DecimalForm:

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

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

Text

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

CMS

Wolfram Language. 2017. "DecimalForm." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/DecimalForm.html.

APA

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

BibTeX

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

BibLaTeX

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