rationals 0.2.0 rationals: ^0.2.0 copied to clipboard
Rational Numbers
// Copyright (c) 2013, Google Inc. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.
// Author: Paul Brauner (polux@google.com)
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}");
}