IntegerPart[x]
gives the integer part of x.
IntegerPart
IntegerPart[x]
gives the integer part of x.
Details
- Mathematical function, suitable for both symbolic and numerical manipulation.
- IntegerPart[x] in effect takes all digits to the left of the decimal point and drops the others.
- IntegerPart[x]+FractionalPart[x] is always exactly x.
- IntegerPart[x] returns an integer when x is any numeric quantity, whether or not it is an explicit number.
- For exact numeric quantities, IntegerPart internally uses numerical approximations to establish its result. This process can be affected by the setting of the global variable $MaxExtraPrecision.
- IntegerPart applies separately to real and imaginary parts of complex numbers.
- IntegerPart automatically threads over lists.
Examples
open all close allBasic Examples (3)
Scope (28)
Numerical Evaluation (6)
IntegerPart[456.457]IntegerPart[-5 / 4]IntegerPart[Pi + E]IntegerPart[78 / 47 - 4.2I]Evaluate efficiently at high precision:
IntegerPart[7545`1000 / 4660`10000]//TimingN[IntegerPart[(E + Pi) ^ 2 - E ^ 2 - Pi ^ 2 - 2 E Pi], 10^5]//Quiet//TimingIntegerPart threads elementwise over lists:
IntegerPart[{2.4, 2.5, 3.0}]IntegerPart can deal with real‐valued intervals:
IntegerPart[Interval[{-1, 3 / 2}]]Compute average-case statistical intervals using Around:
IntegerPart[{1, Around[.2, 0.01]}]Specific Values (6)
Values of IntegerPart at fixed points:
Table[IntegerPart[n], {n, {1 / 7, 5 / 4, 7 / 3, 7 / 2}}]IntegerPart[0]Value at Infinity:
IntegerPart[Infinity]PiecewiseExpand[IntegerPart[x], 0 < x < 4]Manipulate IntegerPart symbolically:
FullSimplify[IntegerPart[x] + IntegerPart[x + 1 / 2], 1 / 3 < x < 1 / 2]Reduce[IntegerPart[x] + IntegerPart[2x - 1] == 2 && 0 < x < 4, x, Reals]Find a value of x for which the IntegerPart[x]=1:
xval = x /. FindRoot[IntegerPart[x] == 1, {x, 1.5}]Plot[IntegerPart[x], {x, -2, 3}, Epilog -> Style[Point[{xval, IntegerPart[xval]}], PointSize[Large], Red], ExclusionsStyle -> Dotted]Visualization (4)
Plot the IntegerPart function:
Plot[IntegerPart[x], {x, -3, 3}, Filling -> Axis]Plot scaled IntegerPart functions:
Plot[{IntegerPart[x], IntegerPart[x / 2], IntegerPart[2x]}, {x, -4, 4}, PlotLegends -> "Expressions", PlotTheme -> "DashedLines", Filling -> Axis]Plot IntegerPart in three dimensions:
Plot3D[IntegerPart[x + y], {x, -3, 3}, {y, -3, 3}, ColorFunction -> "BlueGreenYellow"]Visualize IntegerPart in the complex plane:
ComplexPlot3D[IntegerPart[z], {z, 3}, PlotLegends -> Automatic]Function Properties (9)
IntegerPart is defined for all real and complex inputs:
FunctionDomain[IntegerPart[x], x]FunctionDomain[IntegerPart[x], x, Complexes]IntegerPart can produce infinitely large and small results:
FunctionRange[IntegerPart[x], x, y]//QuietIntegerPart is an odd function:
IntegerPart[-x] == -IntegerPart[x]IntegerPart is not an analytic function:
FunctionAnalytic[IntegerPart[x], x]It has both singularities and discontinuities:
FunctionSingularities[IntegerPart[x], x]FunctionDiscontinuities[IntegerPart[x], x]IntegerPart is nondecreasing:
FunctionMonotonicity[IntegerPart[x], x]IntegerPart is not injective:
FunctionInjective[IntegerPart[x], x]Plot[{IntegerPart[x], 2}, {x, -5, 5}, PlotStyle -> {Thick}]IntegerPart is not surjective:
FunctionSurjective[IntegerPart[x], x]Plot[{IntegerPart[x], -2.5}, {x, -5, 5}, PlotStyle -> {Thick}]IntegerPart is neither non-negative nor non-positive:
FunctionSign[IntegerPart[x], x]IntegerPart is neither convex nor concave:
FunctionConvexity[IntegerPart[x], x]Differentiation and Integration (3)
First derivative with respect to x:
D[IntegerPart[x], x]Definite integrals of IntegerPart:
Integrate[IntegerPart[x], {x, 0, E}]Integrate[IntegerPart[x ^ 3], {x, 0, 2}]Series[IntegerPart[x ^ 2], {x, 1, 2}, Assumptions -> Element[x, Reals]]Applications (9)
Plot[IntegerPart[x + x ^ 2], {x, -3, 3}]Plot the absolute value of the integer part of
:
Plot3D[Abs[IntegerPart[x + I y]], {x, -2.5, 2.5}, {y, -2.5, 2.5}, ExclusionsStyle -> {None, Directive[Thick, White]}]Iso-curves become full‐dimensional regions for piecewise constant functions:
RegionPlot[IntegerPart[x ^ 2 + y ^ 2] == 1, {x, -2, 2}, {y, -2, 2}]Table[IntegerPart[GoldenRatio ^ k / Sqrt[5]] + Mod[k, 2], {k, 15}]Table[Fibonacci[k], {k, 15}]Implement a divide-and-conquer‐type recursion relation:
f[x_] := 2 / 3f[IntegerPart[x / 2]] + 2;f[0] = 0;f[10]Find the 1000000
digit of the fraction 1/99^2 in base 10:
With[{p = 1, q = 99 ^ 2, n = 10 ^ 6, base = 10}, IntegerPart[base Mod[p PowerMod[base, n - 1, q], q] / q]]Compare with RealDigits functionality:
RealDigits[1 / 99 ^ 2, 10, 1, -10 ^ 6]Find the day of the week in the Gregorian calendar:
dow[year_, month_, day_] := {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}[[Mod[IntegerPart[23 month / 9] + day + 4 + year + (IntegerPart[# / 4] - IntegerPart[# / 100] + IntegerPart[# / 400])&[If[month < 3, year - 1, year]] - If[month >= 3, 2, 0], 7] + 1]]dow[1707, 4, 15]Compare with DateString:
DateString[{1707, 04, 15}, "DayName"]Implement the Frisch continuous-but-nowhere-differentiable function:
f[x_, n_] := Sum[Boole[IntegerPart[k x] == IntegerPart[(k + 1)x]] / 2 ^ k, {k, n}]ListLinePlot[{#, f[#, 100]}& /@ Union[Flatten[Table[i / j, {j, 50}, {i, 0, j}]]]]Consider the IntegerPart of the earthquake magnitudes recorded in the US from 1935 to 1989:
ExampleData[{"Statistics", "USEarthquakes"}, "LongDescription"]magnitudes = Cases[ExampleData[{"Statistics", "USEarthquakes"}], {yr_ /; yr ≥ 1935, __, magn_} :> IntegerPart[magn]];The integer parts of the magnitudes recorded on a Richter scale can be modeled with a ParetoDistribution:
edist = EstimatedDistribution[magnitudes, ParetoDistribution[k, α, γ, μ]]Compare the histogram of the magnitudes with the fitted distribution:
Show[Histogram[magnitudes, {0.5, 9.5, 1}, "PDF"], Plot[PDF[edist, x], {x, 0, 10}, PlotRange -> All, PlotStyle -> Thick]]Find the probability of an earthquake with magnitude at least 6 on the Richter scale:
NProbability[x ≥ 6, xedist]Mean[edist]Simulate the next 30 earthquakes:
ListPlot[{RandomVariate[edist, 30], {{0, Mean[edist]}, {30, Mean[edist]}}}, Joined -> {False, True}, Filling -> Axis, AxesOrigin -> {0, 2}]Properties & Relations (5)
Simplify expressions containing IntegerPart:
Simplify[IntegerPart[x + 1] - IntegerPart[x], x ≥ 0]FullSimplify[IntegerPart[z - IntegerPart[z]] - 2IntegerPart[Round[z]]]Symbolically expand for complex arguments:
ComplexExpand[IntegerPart[x + I y]]IntegerPart is idempotent:
IntegerPart[IntegerPart[x]]Use PiecewiseExpand to canonicalize:
PiecewiseExpand[IntegerPart[x ^ 2 + Sqrt[x]], 0 < x < 2]PiecewiseExpand[IntegerPart[x + 1 / 3 + IntegerPart[1 - x / 2] ^ 3], x∈Reals && -2 < x < 3]Reduce equations containing IntegerPart:
Reduce[IntegerPart[x + 1 / 2] == 2 IntegerPart[x] && -1 < x < 1, x, Reals]Possible Issues (3)
Numerical decision procedures with default settings cannot simplify this expression:
IntegerPart[π ^ 2 + 2π + 1 - (π + 1) ^ 2]Use Simplify to resolve:
Simplify[%]Machine‐precision numericalization of IntegerPart can give wrong results:
IntegerPart[1 + (E + 1) ^ 2 - E ^ 2 - 2E - 1 + Exp[-Exp[E] ^ 2]]N[%]Use arbitrary-precision evaluation instead:
N[%%, 20]Because the answer is exact, raising the internal precision does not remove the message:
Block[{$MaxExtraPrecision = 10000}, N[%%%, 100]]Symbolic preprocessing of functions containing IntegerPart can be time consuming:
NIntegrate[IntegerPart[x + x ^ 2], {x, 0, 5}]//TimingAs a discontinuous function, IntegerPart can cause numerical algorithms to converge slowly:
NIntegrate[IntegerPart[x + x ^ 2], {x, 0, 5}, Method -> {Automatic, "SymbolicProcessing" -> 0}]//TimingNeat Examples (1)
Build a nondecreasing sequence of integers where each number
occurs
times [more info]:
s[n_] := Table[IntegerPart[Sqrt[2k] + 1 / 2], {k, n(1 + n) / 2}]Generate the sequence up to 5:
s[5]Split[%]Tech Notes
Related Guides
Related Links
History
Introduced in 1996 (3.0)
Text
Wolfram Research (1996), IntegerPart, Wolfram Language function, https://reference.wolfram.com/language/ref/IntegerPart.html.
CMS
Wolfram Language. 1996. "IntegerPart." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/IntegerPart.html.
APA
Wolfram Language. (1996). IntegerPart. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/IntegerPart.html
BibTeX
@misc{reference.wolfram_2026_integerpart, author="Wolfram Research", title="{IntegerPart}", year="1996", howpublished="\url{https://reference.wolfram.com/language/ref/IntegerPart.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_integerpart, organization={Wolfram Research}, title={IntegerPart}, year={1996}, url={https://reference.wolfram.com/language/ref/IntegerPart.html}, note=[Accessed: 13-June-2026]}