rationals 0.2.0 copy "rationals: ^0.2.0" to clipboard
rationals: ^0.2.0 copied to clipboard

outdatedDart 1 only

Rational Numbers

Rational Numbers #

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}");
}
0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

Rational Numbers

Homepage

License

unknown (license)

More

Packages that depend on rationals