For large degree polynomials (>=5) with real coefficients, the only general root-finding algorithms are approximate. Since polynomials might have complex roots, any algorithm for finding the real roots of a polynomial must apply an approximate root-finding algorithm, then filter the results to obtain only real solutions.
A naive algorithm for filtering the results for real solutions, by simply checking that the imaginary part is identical to 0:
Filter Algorithm 1:
\begin{align*} \text{complex}(x) = \begin{cases} \text{True} & \text{imag}(x) = 0, \\ \text{False}& \text{else} \end{cases} \end{align*}
Is insufficient, since, due to the approximate nature of the initial root-finding, real solutions are not guaranteed to have imaginary parts that are identical to 0.
One possibility is to apply a "tolerance" to check that the imaginary part is not above a certain threshold. However, complex roots may have small imaginary parts, and this risks identifying actual complex roots as real ones.
Another possibility may be to check to see if the complex conjugate of a particular root is also a root, but, since we have already narrowed our search to approximate roots with small imaginary parts, then this will not help separate real roots from complex ones.
How can we determine with higher precision if a particular approximate root is "truly" a complex root, or is actually a real root with a floating-point error imaginary part?
You simply can't tell, by nature of it being an approximate algorithm. Even if the imaginary part is $0$ as a floating point number, that doesn't rule out that the imaginary part is nonzero, but smaller than the smallest possible floating point number.
The way to ensure that the root is real is by using a root finding algorithm whose search space is the real numbers instead of the complex numbers. Root finding algorithms for real roots of real valued functions exist, like the bisection method or Newton's method. You have to have some alternative way of guaranteeing that you've found all of the roots, but this has probably been done if it has been done for complex roots.