[ANN] RepeatingDecimalNotations.jl

Hi all,
I’m pleased to announce my package RepeatingDecimalNotations.jl (repo, docs).

Package logo

This package has some operations with repeating decimals.

  • 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> 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> 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> stringify(1//19)
"0.(052631578947368421)"

julia> 052631578 + 947368421
999999999

julia> 052631 + 578947 + 368421
999999

Hope you like this package!

13 Likes

Hi, RepeatingDecimalNotations.jl v0.1.3 is released, and DotsNotation is now supported!

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 or later, the characters will be rendered correctly like this :smile:

image