wouldn't
if rank == NaN
{code to print 'inactive' instead of NaN}
do the trick?
A function print_sane(num, str) that takes a numerical value and a default string, checks if num is NaN, prints num as a string if num != NaN and str if num == NaN could be used to treat all instances where a number is to be printed and is expected to be NaN sometimes without it being a bug.