corrected math for halfhex variable