C style cast, you want to write: int(nh*pt.val[0]/360.0) and not (int)(nh*pt.val[0]/360.0)  (Warnings on some compilers)