The formula I came up with for my script isn't 100% accurate, but I could never figure out why. It might be possible that it just comes down to some mathematical accuracy/rounding issues or something like that. But I think you can still rely on the formula being 99%+ accurate.