The idea revolves around a unit who has their level set will have the minimum XP to get to that level, which is the required XP for that particular level.
That works I suppose, but it's rather clunky. Well shit though, the very fact it works is enough to merit its use. Reminds me of how Pitzer once did the GetItemCost function. (At least I think that's what it was... It used the same method you used, basically) Whatever works dude, rock on.