0.12.2 • Published 2 years ago

laminations-lib v0.12.2

Weekly downloads
3
License
MIT
Repository
github
Last release
2 years ago

laminations-lib

A collection of libraries for manipulating mathematical laminations.

Testing

Run tests with

npm run test

nary.ts

NaryFraction is a class for representing fractions on the interval [0, 1) as a sequence of exact digits followed by a sequence of repeating digits.

In base 3 (ternary), 0.1 (one third) would be represented by new NaryFraction(3, [1], []). In base 2 (binary), 0.101101101... (five sevenths) would be represented by new NaryFraction(2, [], [1,0,1]) and 0.1101101101... (twelve fourteenths) would be represented by new NaryFraction(2, [1], [1,0,1]).

Simplifications

Upon construction, NaryFractions will be simplified according to the following rules.

redundant exact suffix

If the suffix of any exact part could be represented by the repeating part, then the exact part will be shortened and repeating part rotated accordingly. For example:

([1], [1,0,1]) -> ([], [1,1,0])
([3,0,2], [1,0,2]) -> ([3], [0,2,1])

over-specified repeating part

If the repeating part of a fraction is itself repeated, then it will be shortend to the smallest-length equivalent. For example:

[1,0,1,1,0,1] -> [1,0,1]
[3,3,3] -> [3]

repeating d-1 in base d

If the repeating part of a fraction in base d is [d-1], then the exact part will be appropriately incremented. For example, in base 3:

([], [2]) -> ([], []) // one -> zero
([2, 1], [2]) -> ([2, 2], []) // eight-ninths

trailing zeroes

If there is no repeating part of a fraction, any trailing zeroes of the exact part will be removed. For example:

([1,0,0], []) -> ([1], [])

Also, any repeating part of only zeroes will be removed. For example:

([1], [0]) -> ([1], [])
0.12.0

2 years ago

0.12.1

2 years ago

0.12.2

2 years ago

0.11.0

2 years ago

0.11.1

2 years ago

0.10.1

4 years ago

0.10.0

4 years ago

0.9.5

4 years ago

0.9.4

4 years ago

0.9.3

4 years ago

0.9.2

4 years ago

0.9.0

4 years ago

0.9.1

4 years ago

0.8.0

4 years ago

0.7.0

4 years ago

0.6.3

4 years ago

0.6.2

4 years ago

0.6.1

4 years ago

0.6.0

4 years ago

0.5.3

5 years ago

0.5.2

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago

0.4.2

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago