This is just me taking a stab here, since I don't have the code to look at to make sure, buuuutttt.....
It more than likely reads that since that is the "number" that returns after the code does it's little equation of the characters stats. This "number" then gets output to your client, which then displays it.
The fix would be to have a check in the equation, that if the character's stats are low enough to cause the player to have less than 0 mana points, then it would just give them 0 as thier mana. Maybe it does this already, but I don't have the code so I can't check.
Or it could be some other bug that cuased it to have an odd man glitch thingy.