I want to truncate a simple number to n decimal digits. For example, 2/3. I used
f[x_, n_] := N[IntegerPart[x 10^n]/10^n]
but I get
f[2/3, 20] = 0.666667
Is there a way to get
f[2/3, 20] = 0.66666666666666666666
?
I have searched a lot but I haven't really found an answer. I am looking for something like N
or Round
for truncation.
N[2/3, 20]
$\endgroup$ – J42161217 Nov 27 '18 at 12:10N
rounds the last decimal digit. I getN[2/3, 20] = 0.66666666666666666667
$\endgroup$ – Alex Nov 27 '18 at 12:12RealDigits[2/3, 10, 20]
$\endgroup$ – Carl Lange Nov 27 '18 at 12:18NumberForm[N[2/3], 30]
stops after 15 to 16 decimals but does not round up. $\endgroup$ – Titus Nov 27 '18 at 12:37