Get direction (compass) with two longitude/latitude points

O forgot to say I found the answer eventually. The application is to determine compass direction of a transit vehicle and its destination. Essentially, fancy math for acquiring curvature of Earth, finding an angle/compass reading, and then matching that angle with a generic compass value. You could of course just keep the compassReading and apply … Read more

How are exponents calculated?

I’ve had a chance to look at fdlibm’s implementation. The comments describe the algorithm used: * n * Method: Let x = 2 * (1+f) * 1. Compute and return log2(x) in two pieces: * log2(x) = w1 + w2, * where w1 has 53-24 = 29 bit trailing zeros. * 2. Perform y*log2(x) = … Read more

Quadratic equation in Ada

Solving quadratic equations is not as simple as most people think. The standard formula for solving a x^2 + b x + c = 0 is delta = b^2 – 4 a c x1 = (-b + sqrt(delta)) / (2 a) (*) x2 = (-b – sqrt(delta)) / (2 a) but when 4 a c … Read more