This is where gauge comes in. You knit a swatch a little over 4 x 4 inches using your yarn and needles and see how many stitches per inch you get. You make it 4 inches to allow for slight differences in tension.
Then you use that number to see how many stitches you need to make your hat (or whatever) the size you want it to be.
For example, if the gauge of the hat with bulky yarn was 3 stitches per inch, and it was 20 inches around, then the cast on would be 60 inches.
If, with your yarn and needles the gauge was 4 stitches per inch, you'd have to cast on 80 for the same size.
Width gauge is most important. You can change how many rows you knit to make it longer.