Hat sizes are the diameter of your head in inches. Measure around the head in question where the hat band will be worn with a tailors tape (in inches). Then divide by pi (3.14) to get diameter to get decimal hat size.
Since hat sizes are in inches and fractions of inch, subtract the whole number and keep it. The multiply the decimal fraction by 8 and the result will be the top of the 1/8ths fraction.
Example: I measured 23 1/8th, gives 23.125, divide by 3.14 = 7.361 (this is decimal hat size), multiply the .361 by 8 = 2.89, round up to next whole number (3) and you have the number of eights, put it all together - my hat size is 7 3/8.