use lrintf to avoid double conversion