Traditionally, bikes were sized by standover clearance. Modern bikes generally have more than enough of this clearance and are sized by reach from saddle to bars. There us some adjustment in saddle (fore-aft) position so reach is a bit of a movable feast, but still one of the most critical dimensions for comfortable riding.
Correct reach for you depends on your body dimensions and your riding stance. As a beginner you might expect to start more upright and gradually ease into a lower/longer riding position over months, if this is what you prefer.
A bike can be fitted to a rider if it is close enough in length by switching the seatpost to one with different lay-back and switching the handlebar stem to one with a different length or height.
As you can see there is no precise formula guaranteed to work.
If your first bike is going to be expensive, try and get hold of a cheaper one of roughly correct size so you can establish a baseline of (dis) comfort.
If you want to read lots of words on the topic you can include this.
https://www.peterwhitecycles.com/fitting.php