### 10 unstable releases (3 breaking)

0.3.0 | Apr 15, 2022 |
---|---|

0.3.0-alpha | Apr 11, 2022 |

0.2.0 | Apr 8, 2022 |

0.2.0-alpha | Mar 3, 2022 |

0.0.3 | Jan 18, 2022 |

#**1694** in Math

Used in **2** crates

**Apache-2.0**

175KB

4K
SLoC

# num-irrational

This crate provides representations of irrational numbers within following categories:

- Math constants (

,`pi`

, etc.)`e` - Quadratic Numbers
- Quadratic irrational aka. Quadratic surd
- Quadratic integer
- Gaussian integer / Eisenstein integer

- Continued Fraction
- Simple (aka. Regular) continued fraction
- General continued fraction
- Hurwitz continued fraction

As you can see, the support for irrational number is not limited in the real field, it also support several
numeric types in the complex field (by enabling the

feature). It's based on the `complex`

creates.`num`

###
`lib.rs`

:

This crate provides representations of irrational numbers within following categories:

- Math constants (

,`pi`

, etc.)`e`- Values and continued fraction representations

- Quadratic Numbers
- Quadratic Irrational: [QuadraticSurd]
- Quadratic Integer: [QuadraticInt]
- Gaussian Integer: [GaussianInt]

- Continued Fraction
- Simple continued fraction: [ContinuedFraction], [InfiniteContinuedFraction]
- General continued fraction: [GeneralContinuedFraction]
- Transcendental functions represented in continued fractions

It's based on the

creates.`num`

# Examples

`use` `num_irrational``::``{`FromSqrt`,` QuadraticSurd`}``;`
`let` sq2 `=` `QuadraticSurd``::`from_sqrt`(``2``i32``)``.``unwrap``(``)``;`
`println!``(``"`Square root of 2: `{}``"``,` sq2`)``;` `//` √2
`use` `num_irrational``::`Computable`;`
`let` sq2_approx `=` sq2`.``approximated``(``&``100``)``.``value``(``)``;`
`println!``(``"`Rational approximation with denominator under 100: `{}``"``,` sq2_approx`)``;` `//` 99/70
`use` `core``::``convert``::`TryFrom`;`
`use` `num_irrational``::`ContinuedFraction`;`
`//` let sq2_fraction = ContinuedFraction::from(sq2); // only if feature `complex` is disabled
`let` sq2_fraction `=` `ContinuedFraction``::`try_from`(`sq2`)``.``unwrap``(``)``;`
`println!``(``"`Continued Fraction: `{}``"``,` sq2_fraction`)``;` `//` [1; (2)]

# Optional Features

: Enable negative square root base support for [QuadraticSurd]. Note that this flag might change some behavior of the operators on [QuadraticSurd].`complex`

: Enable converting [QuadraticSurd] to`num-complex`

. You probably want to enable the`num_complex`Complex`::`

feature at the same time.`complex`

: Enable using big integers as the internal representation.`num-bigint`

#### Dependencies

~625KB

~14K SLoC