Thank you so much for your help! I got it working. The returned number was indeed a problem, and I had to handle it by rounding. I also had created my own logging but didn't include it in my function I posted. So using the one already there that you showed is easier and great to know about. I am posting the final function here in the hopes it helps someone else down the line.
SimVar("(A:PLANE HEADING DEGREES MAGNETIC, Degrees)")
SimVar("K:HEADING_BUG_SET")
function PFD_HDG_SYNC()
local curhdg = SimRead("(A:PLANE HEADING DEGREES MAGNETIC, Degrees)")
curhdg = math.floor(curhdg + 0.5)
Log("K:HEADING_BUG_SET:" .. curhdg)
SimCommand("K:HEADING_BUG_SET:" .. curhdg)
end