calculate hex representations manually (instead of sprintf)