rationals 0.3.1 rationals: ^0.3.1 copied to clipboard
Rational Numbers (deprecated)
Rational Numbers #
This package is deprecated, please use the rational package instead.
Rational numbers for Dart. Binary operations accept integers and doubles.
import 'package:rationals/rationals.dart';
main() {
final q0 = new Rational(0, 1);
final q1 = new Rational(0, 10);
print("0/1 == 0/10 = ${q0 == q1}");
final q2 = new Rational(1, 2);
final q3 = new Rational(2, 4);
print("1/2 == 2/4 = ${q2 == q3}");
print("1/2 == 0 = ${q2 == q1}");
final q4 = new Rational(-1, 2);
final q5 = new Rational(1, -2);
print("-1/2 == 1/-2 = ${q4 == q5}");
print("1/2 > -1/2 = ${q2 > q4}");
print("1/2 > 0.6 = ${q2 > 0.6}");
print("1/2 + 1/2 = ${q2 + q2}");
print("1/2 + 4 = ${q2 + 4}");
print("-(1/2) = ${-q2}");
print("1/2 - 1/2 = ${q2 - q2}");
print("1/2 - 4 = ${q2 - 4}");
print("1/2 * 1/2 = ${q2 * q2}");
print("1/2 * 3 = ${q2 * 3}");
print("(1/2) / (1/2) = ${q2 / q2}");
print("(1/2) / 4 = ${q2 / 4}");
}