How to calculate an $n$ digit decimal approximation of a fraction? Say I have a number $x \in \mathbb{Q}$ which possibly cannot be writen exactly in decimal form, but at least $x \notin \mathbb{Z}$ ($x$ is not an integer).
How do I calculate the first $n$ digits of this number $x$, for a given $n$? Also, how do I know if it has a finite or infinite amount of (nonzero) digits in decimal form?
For example, if $x = \frac{1000}{1001}$, how do I calculate the first $n = 10$ digits of this number?
I know this question sounds really basic, but since it is basically always done by means of a calculator or other computing device, I've never really done it before.
 A: A simple algorithm is the following :
Take integer part $\rightarrow$  multiply the numerator of the remainder by $10$ (in base $10$) $\rightarrow$ divide by the denominator $\rightarrow$ repeat
Each integer part obtained is one digit.
Once you decide you have enough digits, use common sense to place the dot.
Example :
For $\frac{1000}{1001}$
The integer part is $0$ so the first digit is $0$
The remainder is  $\frac{1000}{1001}$
We multiply the numerator by $10$ : $1000\times10=10000$
We divide by the denominator $1001$ and take the integer part : $9$
So the second digit is $9$.
The numerator of the remainder is $10000-9\times1001=991$
Multiply it by $10$ and get $9910$
Divide by $1001$, take the integer part : $9$, which is our third digit...
etc.
So the first three digits are $0.99$
I let you compute the other ones !
(It is basically long division, but it was so badly taught to me I didn't even understand I could just work that way without drawings or fluff, and it seems much easier now, especially for mental maths.)
A: To find if it has a terminating decimal, so has a finite number of nonzero digits, check if the denominator factors as $2^a5^b$.  If the denominator has any prime factors other than $2$ or $5$, the decimal will repeat infinitely.  The termination will come at $\max (a,b)$ because the denominator will divide evenly into $10^{\max(a,b)}$
