RealDigits
Usage
• RealDigits[x] 给出近似实数x中的数字构成的阵列,和小数点左边的数位个数.
• RealDigits[x, b]给出x中一列以b为基底的数字.
• RealDigits[x, b, len] 给出 len 个数位的列表.
• RealDigits[x, b, len, n] 给出以  的系数开始的 len个数位.
Notes
• RealDigits[x] 通常返回一个长度等于Precision[x]的数字列表. • RealDigits[x] 和 RealDigits[x, b] 通常要求 x 是一个由,举例来讲,N返回的近似实数. RealDigits[x, b, len] 也适用于精确数. • 对于一个精确的有理数, RealDigits[x]返回一个形如  , , ... ,  , , ...   的数字列表,表示数字  被  的无限循环跟随. • 如果 len 大于 Log[10, b] Precision[x]剩下的数字以Indeterminate填充. • RealDigits[x, b, len, n] 以  的系数开始,并在必要时用0截断或填充. • RealDigits[x, b, len, -1] 以x中紧挨以b为基底的小数点右边的数字开始. • RealDigits[x, b]中的基底 b不必是整数.对使得  的任意实数 b , RealDigits[x, b]连续找到 b的幂的最大整数倍使得当得到一个非负余项时可以被去掉. • RealDigits[x] 不考虑 x 的符号. • FromDigits可以被用作RealDigits的逆.
Further Examples
Here is an approximation to .
In[1]:=
|
Out[1]=
|
This gives the individual digits as a list. The at the end means that there are digits to the left of the decimal point.
In[2]:=
|
Out[2]=
|
As an exact fraction, has a repeating part.
In[3]:=
|
Out[3]=
|
Here is an approximate number.
In[4]:=
|
Here are its digits. The at the end means that there are digits to the left of the decimal point.
In[5]:=
|
Out[5]=
|
RealDigits returns a list of digits whose length is equal to the number's precision.
In[6]:=
|
Out[6]=
|
In[7]:=
|
Out[7]=
|
Similarly, these are its digits in base . There are digits in all.
In[8]:=
|
Out[8]=
|
digits in base is digits in base .
In[9]:=
|
Out[9]=
|
Here is an exact number.
In[10]:=
|
Out[10]//BaseForm=
|
This shows the first digits of n in base .The total number of digits is .
In[11]:=
|
Out[11]=
|
This gives the first digits starting with the coefficient of . There are digits counting from that coefficient.
In[12]:=
|
Out[12]=
|
In[13]:=
|
|