There's no "conversion logic". They're both transcendental functions and there's no nice way to implement one in terms of the other. Since they're inverses, you could use Newton's method or some other root-finding method to find the zero of log(x) - a
, and call that value exp(a)
, but that would be both less accurate and vastly less efficient than using the builtin implementation.
If you're asking how those functions are usually implemented in mathematical libraries, a common approach is range reduction followed by polynomial approximation. For instance, any positive number can be reduced into the range [1,2)
by multiplying or dividing it by two zero or more times; and log(x * 2) == log(x) + log(2)
, so all we need is a high-precision constant for log(2)
, to be added or subtracted from the final result the appropriate number of times. Then we can use a Taylor series for the function log(1+x)
over [0,1)
; you can get high accuracy without too many terms because of the limited domain. Alternatively, lookup tables and linear interpolation could be used on platforms where multiplication is particularly expensive.