self made pow() c++

I have looked at this paper here which describes how to approximate the exponential function for double precision. After a little research on Wikipedia about single precision floating point representation I have worked out the equivalent algorithms. They only implemented the exp function, so I found an inverse function for the log and then simply … 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

Wrong result by Java Math.pow

You’ve exceeded the number of significant digits available (~15 to 16) in double-precision floating-point values. Once you do that, you can’t expect the least significant digit(s) of your result to actually be meaningful/precise. If you need arbitrarily precise arithmetic in Java, consider using BigInteger and BigDecimal.