Solved this by formatting the grade using number_format to display the grade with a number of decimal places. So for 0 we display something like 0.00 and this displays OK in link_to_popup_window.
$gradedstateid = get_field('question_sessions', 'newgraded', 'attemptid',
$attempt->attemptuniqueid, 'questionid', $questionid);
if ($gradedstateid) {
- $grade = round(get_field('question_states', 'grade', 'id',
+ $grade = number_format(get_field('question_states', 'grade', 'id',
$gradedstateid), $quiz->decimalpoints);
} else {
$grade = '--';