# \[ANN\] RepeatingDecimalNotations.jl

**URL:** <https://discourse.julialang.org/t/ann-repeatingdecimalnotations-jl/108011>\
**Category:** Package Announcements\
**Tags:** numbers, rationals, math\
**Created:** [December 24, 2023, 6:22pm UTC](https://discourse.julialang.org/t/ann-repeatingdecimalnotations-jl/108011 "2023-12-24T18:22:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hyrodium](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hyrodium/32/27015_2.png) [@hyrodium](https://discourse.julialang.org/u/hyrodium)\
**Post date:** [December 24, 2023, 6:22pm UTC](https://discourse.julialang.org/t/ann-repeatingdecimalnotations-jl/108011/1 "2023-12-24T18:22:42Z")

</div>

Hi all,  
I’m pleased to announce my package RepeatingDecimalNotations.jl ([repo](https://github.com/hyrodium/RepeatingDecimalNotations.jl), [docs](https://hyrodium.github.io/RepeatingDecimalNotations.jl)).

![Package logo](https://github.com/hyrodium/RepeatingDecimalNotations.jl/raw/main/docs/src/assets/logo.svg)

This package has some operations with [repeating decimals](https://en.wikipedia.org/wiki/Repeating_decimal).

- Define rational number with string macro like `rd"123.4(56)"`.
- Convert `Rational` to `String`, `1//7` ↦ `"0.(142857)"`
- Convert `String` to `Rational`, `0.1(6)` ↦ `1//6`.

Here are some examples of usage:

**Define rational numbers with sting macro**

```julia
julia> using RepeatingDecimalNotations

julia> r = rd"123.4(56)" # 123.4565656...
61111//495

julia> rd"1.234r56e2" # Other notations
61111//495

julia> rd"123.45656..." # are also supported.
61111//495

julia> float(r) # Check floating point number approximation.
123.45656565656566

julia> rd"0.(9)" # 0.999... is equal to 1.
1//1

julia> rd"0.99(9)", rd"1", rd"1.000_000" # The notation of repeating decimals is not unique.
(1//1, 1//1, 1//1)

```

**Conversion between rational numbers and string**

```julia
julia> using RepeatingDecimalNotations: stringify, rationalify

julia> stringify(1//7) # Generate `String` from `Rational`.
"0.(142857)"

julia> rationalify("0.1(6)") # vice versa.
1//6

```

**Enjoy Midy’s theorem**

```julia
julia> stringify(1//19)
"0.(052631578947368421)"

julia> 052631578 + 947368421
999999999

julia> 052631 + 578947 + 368421
999999

```

Hope you like this package!

---

<div class="post-metadata">

**Author:** ![hyrodium](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hyrodium/32/27015_2.png) [@hyrodium](https://discourse.julialang.org/u/hyrodium)\
**Post date:** [January 6, 2024, 6:54am UTC](https://discourse.julialang.org/t/ann-repeatingdecimalnotations-jl/108011/2 "2024-01-06T06:54:35Z")

</div>

Hi, [RepeatingDecimalNotations.jl v0.1.3](https://github.com/hyrodium/RepeatingDecimalNotations.jl/releases/tag/v0.1.3) is released, and `DotsNotation` is now supported!

```julia
julia> rd"123.456̇78̇"
4111111//33300

julia> no = DotsNotation()
DotsNotation()

julia> stringify(no, 1//11)
"0.0̇9̇"

julia> rationalify(no, "123.456̇78̇")
4111111//33300

```

Note that the above code block may not show `\dot (\u0307)` correctly. If you are using [JuliaMono v0.053](https://github.com/cormullion/juliamono/releases/tag/v0.053) or later, the characters will be rendered correctly like this 😄

![image](https://global.discourse-cdn.com/julialang/original/3X/c/f/cfaf93ade91efa459a4b1db999e1738fcf26a9c6.png)
