Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Display a number in decimal form so that recurring digit sequences are highlighted and displayed only once
| ResourceFunction["RecurringDecimalForm"][val] displays numeric value val such that recurring digits are highlighted and displayed only once. | |
| ResourceFunction["RecurringDecimalForm"][val,b] displays numeric value val such that digits recurring in base b are highlighted and displayed only once. | 
| "MinRepeats" | 3 | number of times digits must repeat before they are assumed to be recurring | 
| "RoundingDigits" | 1 | number assumed to be affected by rounding and, as such, ignored | 
| "Notation" | "Vinculum" | display notation to be used for recurring digits; choices are "Vinculum", "Dots", "Parenthesis" or "Arc" | 
Some rational numbers have recurring decimal digits:
| In[1]:= | ![N[1/11, 31]](https://www.wolframcloud.com/obj/resourcesystem/images/985/985ddb9b-becf-4d14-98d6-ccbe2d206635/0d50fe82dd28d107.png) | 
| Out[1]= |  | 
RecurringDecimalForm displays this in a more compact notation:
| In[2]:= | ![ResourceFunction["RecurringDecimalForm"][1/11]](https://www.wolframcloud.com/obj/resourcesystem/images/985/985ddb9b-becf-4d14-98d6-ccbe2d206635/5f9cd6a9b1c3ac9f.png) | 
| Out[2]= |  | 
RecurringDecimalForm accepts any input that is numeric:
| In[3]:= | ![ResourceFunction["RecurringDecimalForm"][3.431212121212121212]](https://www.wolframcloud.com/obj/resourcesystem/images/985/985ddb9b-becf-4d14-98d6-ccbe2d206635/1dad2baebf9e336a.png) | 
| Out[3]= |  | 
RecurringDecimalForm ignores repeating zeros:
| In[4]:= | ![N[1/8]](https://www.wolframcloud.com/obj/resourcesystem/images/985/985ddb9b-becf-4d14-98d6-ccbe2d206635/38b9efdda9d70438.png) | 
| Out[4]= |  | 
| In[5]:= | ![ResourceFunction["RecurringDecimalForm"][1/8]](https://www.wolframcloud.com/obj/resourcesystem/images/985/985ddb9b-becf-4d14-98d6-ccbe2d206635/57781707dbb7a38f.png) | 
| Out[5]= |  | 
For numeric quantities, a repeating sequence in the final digits (excluding the last digit, which is subject to rounding) is assumed to be recurring:
| In[6]:= | ![ResourceFunction["RecurringDecimalForm"][1.23456565656565657]](https://www.wolframcloud.com/obj/resourcesystem/images/985/985ddb9b-becf-4d14-98d6-ccbe2d206635/60fd4c31921ea9be.png) | 
| Out[6]= |  | 
For exact numeric quantities that are not explicitly Rational, RecurringDecimalForm searches the first $MaxExtraPrecision digits:
| In[7]:= | ![ResourceFunction["RecurringDecimalForm"][Sin[1]]](https://www.wolframcloud.com/obj/resourcesystem/images/985/985ddb9b-becf-4d14-98d6-ccbe2d206635/240cbd5dc231d026.png) | 
| Out[7]= |  | 
Recurring digits can be found in other number bases:
| In[8]:= | ![ResourceFunction["RecurringDecimalForm"][0.2`30, 2]](https://www.wolframcloud.com/obj/resourcesystem/images/985/985ddb9b-becf-4d14-98d6-ccbe2d206635/326e93e2ab6b2d6b.png) | 
| Out[8]= |  | 
Digit sequences that repeat at least three times are assumed to be recurring:
| In[9]:= | ![ResourceFunction["RecurringDecimalForm"][1.31234567123456712]](https://www.wolframcloud.com/obj/resourcesystem/images/985/985ddb9b-becf-4d14-98d6-ccbe2d206635/6bb74fa968856747.png) | 
| Out[9]= |  | 
The option "MinRepeats" controls this sensitivity:
| In[10]:= | ![ResourceFunction["RecurringDecimalForm"][1.31234567123456712, "MinRepeats" -> 2]](https://www.wolframcloud.com/obj/resourcesystem/images/985/985ddb9b-becf-4d14-98d6-ccbe2d206635/0b4221411c9cf143.png) | 
| Out[10]= |  | 
There are several notations for the display of recurring digits used in different parts of the world:
| In[11]:= | ![Table[ResourceFunction["RecurringDecimalForm"][1/111, "Notation" -> n], {n, {"Vinculum", "Dots", "Parenthesis", "Arc"}}]](https://www.wolframcloud.com/obj/resourcesystem/images/985/985ddb9b-becf-4d14-98d6-ccbe2d206635/4eaa08caea349160.png) | 
| Out[11]= |  | 
By default, the final digit is assumed to be subject to rounding and is ignored:
| In[12]:= | ![ResourceFunction["RecurringDecimalForm"][0.6666666666666666666667]](https://www.wolframcloud.com/obj/resourcesystem/images/985/985ddb9b-becf-4d14-98d6-ccbe2d206635/38a432ac7c6ee672.png) | 
| Out[12]= |  | 
In some circumstances, more digits are affected by rounding:
| In[13]:= | ![RealDigits[0.2, 2]](https://www.wolframcloud.com/obj/resourcesystem/images/985/985ddb9b-becf-4d14-98d6-ccbe2d206635/797158e72d437007.png) | 
| Out[13]= |  | 
| In[14]:= | ![ResourceFunction["RecurringDecimalForm"][0.2, 2]](https://www.wolframcloud.com/obj/resourcesystem/images/985/985ddb9b-becf-4d14-98d6-ccbe2d206635/674c7e2b79954e8a.png) | 
| Out[14]= |  | 
You can ignore more digits with "RoundingDigits":
| In[15]:= | ![ResourceFunction["RecurringDecimalForm"][0.2, 2, "RoundingDigits" -> 2]](https://www.wolframcloud.com/obj/resourcesystem/images/985/985ddb9b-becf-4d14-98d6-ccbe2d206635/2d172cd9ca73144f.png) | 
| Out[15]= |  | 
By default, the final digit is assumed to be subject to rounding and is ignored:
| In[16]:= | ![ResourceFunction["RecurringDecimalForm"][0.6666666666666666666667]](https://www.wolframcloud.com/obj/resourcesystem/images/985/985ddb9b-becf-4d14-98d6-ccbe2d206635/63e455a7542785bf.png) | 
| Out[16]= |  | 
| In[17]:= | ![Rationalize[
 ToExpression[StringJoin["0.", StringJoin[Table["0999", {10}]]]]]](https://www.wolframcloud.com/obj/resourcesystem/images/985/985ddb9b-becf-4d14-98d6-ccbe2d206635/47eadf10e6d82a05.png) | 
| Out[17]= |  | 
In some circumstances, more digits are affected by rounding:
| In[18]:= |  | 
| Out[18]= |  | 
In these circumstances, RecurringDecimalForm will not recognize the repeat:
| In[19]:= | ![ResourceFunction["RecurringDecimalForm"][111/1111`30]](https://www.wolframcloud.com/obj/resourcesystem/images/985/985ddb9b-becf-4d14-98d6-ccbe2d206635/1636e4acb97eacdc.png) | 
| Out[19]= |  | 
You can ignore more digits with "RoundingDigits":
| In[20]:= | ![ResourceFunction["RecurringDecimalForm"][111/1111`30, "RoundingDigits" -> 3]](https://www.wolframcloud.com/obj/resourcesystem/images/985/985ddb9b-becf-4d14-98d6-ccbe2d206635/1b90d0dc01625475.png) | 
| Out[20]= |  | 
This work is licensed under a Creative Commons Attribution 4.0 International License