Calculation result discrepancy

No one will ever read a 617 lines code. Please read Read before posting: How do I get my question answered? and try again in a new post, with a minimal (but complete code), more context, and a meaningful title.