is the head used for real (floating‐point) numbers.
Real
is the head used for real (floating‐point) numbers.
Details
- _Real can be used to stand for a real number in a pattern.
- You can enter a floating‐point number of any length.
- You can enter a number in scientific notation by using the form mantissa*^exponent.
- You can enter a floating‐point number in base b using b^^digits. The base can be up to 36. The letters a–z or A–Z are used in sequence to stand for digits 10 through 35.
- Real is also used to indicate an approximate real number in Read.
Examples
open all close allBasic Examples (1)
Scope (11)
Real numbers entered with just a few digits are generally represented as machine reals:
1.23456789MachineNumberQ[%]Enter a real number with many significant digits:
x = 987654321123456789.987654321123456789Arbitrary-precision reals are used when too many digits are given for a machine number:
MachineNumberQ[x]Its Accuracy is based on the number of digits to the right of the decimal point:
Accuracy[%%]Enter a real number with a specified Precision:
x = 1`23Precision[x]Enter a real number with a specified Accuracy:
x = 0``12Accuracy[x]Enter a real number with an exponent:
1.23*^45Enter a real number with an exponent and specified precision:
1.23`45.*^67Enter a real number in binary:
2^^101001000100001.0101101110111101111Enter a real number in binary with precision specified in terms of bits:
2^^101001000100001.0101101110111101111`100Precision[%]% * Log[2, 10]Enter a real number in hexadecimal:
16^^fab.beadEnter a real number in base 35:
35^^thecowjumpedoverthemoon.MachineNumberQ[%]Format a real number using base 2:
BaseForm[1.2345, 2]_Real can be used to represent a real number in a pattern:
MatchQ[1.23, _Real]A rule that replaces real numbers with nearby rationals:
1.4142135623730951×E^3.141592653589793 t /. x_Real :> Rationalize[x, 0]Applications (4)
Determine if a matrix consists entirely of approximate reals:
m = {{1`20, 2.}, {3, 4.5}};MatrixQ[m, MatchQ[#, _Real]&]MatrixQ[N[m], MatchQ[#, _Real]&]A rule that rounds all reals to have two digits after the decimal point:
rule = x_Real :> N[Round[100 x] / 100];Divide a restaurant bill to the nearest penny:
123.50 / 7 /. ruleDefine a function that only works for reals:
f[x_Real] := Total[First[RealDigits[x]]]{f[1.2], f[4]}Plot[f[x], {x, 0, 1}]Define a function that has a special case for reals:
sqrt[x_Real] := s /. FindRoot[s ^ 2 - x, {s, 1.}, WorkingPrecision -> Precision[x]];sqrt[2`47]For integers and rationals use the corresponding approximate real:
sqrt[x_Integer] := sqrt[N[x]]
sqrt[x_Rational] := sqrt[N[x]]sqrt[2]Properties & Relations (5)
NumberQ[12.34]Real is used for approximate reals:
ExactNumberQ[12.34]Reals are atomic objects with no subexpressions:
AtomQ[12.34]Use different formats for displaying a real number:
r = -Pi ^ 10.Table[f[r], {f, {ScientificForm, EngineeringForm, AccountingForm}}]Use Reals in assumptions and to indicate domain conditions:
Reduce[x Log[x] < 1, x, Reals]Possible Issues (1)
Real is only the head for approximate real numbers:
MatchQ[3 / 4, Real]You can use the following function to test for numbers on the real axis:
realAxisQ[x_] := NumberQ[x] && !MatchQ[x, _Complex]realAxisQ[3 / 4]Tech Notes
History
Introduced in 1988 (1.0) | Updated in 1996 (3.0)
Text
Wolfram Research (1988), Real, Wolfram Language function, https://reference.wolfram.com/language/ref/Real.html (updated 1996).
CMS
Wolfram Language. 1988. "Real." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 1996. https://reference.wolfram.com/language/ref/Real.html.
APA
Wolfram Language. (1988). Real. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Real.html
BibTeX
@misc{reference.wolfram_2026_real, author="Wolfram Research", title="{Real}", year="1996", howpublished="\url{https://reference.wolfram.com/language/ref/Real.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_real, organization={Wolfram Research}, title={Real}, year={1996}, url={https://reference.wolfram.com/language/ref/Real.html}, note=[Accessed: 13-June-2026]}