A priori collision detection

In platform games when you make your character jump you need a priori collision detection in order not to see your character standing “in” the ground.

So when the character starts falling you need to check the next Y position of your character for a collision, and if collision is true, to set character exactly on ground.

In order to accomplish this, by the time the next Y character location is colliding with ground, you need to know the distance between the character and the ground line underneath him.

If you know the distance you just make character.y+=distance

How am I going to know this distance?

(I have figured out a function that estimates the distance with multiple hitTestPoint collision checks in a loop. But still, it’s an estimation and the character doesn’t always stop exactly on ground.)

Is there any other better way?

Thx in advance