Expand description
A simple, lightweight crate for fraction arithmetic.
This crate provides a Fraction
type that supports basic arithmetic operations
with automatic reduction to lowest terms.
§Examples
use fractions::Fraction;
let half = Fraction::new(1, 2)?;
let third = Fraction::new(1, 3)?;
let sum = half + third;
assert_eq!(sum.to_string(), "5/6");
let product = half * third;
assert_eq!(product.to_string(), "1/6");
Structs§
- Fraction
- A fraction with numerator and denominator.
Enums§
- Fraction
Error - Error types for fraction operations.