Every time TeX constructs a box, it calculates a measure of the quality of spacing within the box known as badness. It is an integer between 0 and 10000. The TeX primitive \badness is a integer parameter that is set by TeX each times a box is constructed. If there is no overflow error for the box being constructed, then \badness is set to the badness of the constructed box. If there is an overflow error, then \badness is set to 1000000.