util: avoid using variables of type double to store widths

While here, also document some magic number and why the cast from double
to int is safe in this special case.