Calculate two to the power of decimal

124 Views Asked by At

I have a decimal number $a$ with integer and fractional parts as follows:

$$ a_{int} = a_0 + a_1 2 + a_2 2^2 + \cdots $$ $$ a_{fr} = \frac{a_{-1}}{2} + \frac{a_{-2}}{2^2} + \cdots $$

I want to compute $b=2^a$. The problem is that $a$ is very big so I want to implement the power function by myself. I have two questions:

  1. What is the most efficient way to calculate $b$?
  2. If I want to get only the integer part of $b$, how much precision do I need to have in $a_{fr}$? In other words, how the precisions of $b$ and $a$ are related?