For a toric pair (X,D), where X is a projective toric variety of dimension d−1≥1 and D is a very ample T-Cartier divisor, we show that the Hilbert–Kunz density function HKd(X,D)(λ) is the d−1 dimensional volume of P‾D∩{z=λ}, where P‾D⊂Rd is a compact d-dimensional set (which is a finite union of convex polytopes).We also show that, for k≥1, the function HKd(X,kD) can be replaced by another compactly supported continuous function φkD which is ‘linear in k’. This gives the formula for the associated coordinate ring (R,m):limk→∞eHK(R,mk)−e0(R,mk)/d!kd−1=e0(R,m)(d−1)!∫0∞φD(λ)dλ, where φD (see Proposition 1.2) is solely determined by the shape of the polytope PD, associated to the toric pair (X,D). Moreover φD is a multiplicative function for Segre products.This yields explicit computation of φD (and hence the limit), for smooth Fano toric surfaces with respect to anticanonical divisor. In general, due to this formulation in terms of the polytope PD, one can explicitly compute the limit for two dimensional toric pairs and their Segre products.We further show that (Theorem 6.3) the renormalized limit takes the minimum value if and only if the polytope PDtiles the spaceMR=Rd−1 (with the lattice M=Zd−1). As a consequence, one gets an algebraic formulation of the tiling property of any rational convex polytope.