Exception on Number Class doubleValue - java

When I run my main method I get the following exception: Exception in thread "main" java.lang.StackOverflowError, followed by this: at Rational.doubleValue(Rational.java:62) like 100+ times. This is for an assignment where the main class is provided for me, so I can't change anything in there. Here is the my code:
public class Rational extends Number implements Comparable<Rational>
{
private int num;
private int denom;
public Rational(int num, int denom)
{
this.num = num;
this.denom = denom;
}
public int compareTo(Rational r)
{
if ((num/denom) - (r.num/r.denom) > 0)
{
return +1;
}
else if ((num/denom) - (r.num/r.denom) < 0)
{
return -1;
}
return 0;
}
public Rational add(Rational r)
{
return new Rational(num + r.num, denom + r.denom);
}
public Rational sub(Rational r)
{
return new Rational(num - r.num, denom - r.denom);
}
public Rational mul(Rational r)
{
return new Rational(num * r.num, denom * r.denom);
}
public Rational div(Rational r)
{
return new Rational(num * r.denom, denom * r.num);
}
public int gcd(Rational r)
{
int i = 1;
while(i != 0)
{
i = denom % r.denom;
denom = r.denom;
r.denom = i;
}
return denom;
}
public String toString()
{
String a = num + "/" + denom;
return a;
}
public double doubleValue()
{
return (double)doubleValue();
}
public float floatValue()
{
return (float)floatValue();
}
public int intValue()
{
return (int)intValue();
}
public long longValue()
{
return (long)longValue();
}
}
And here is the main class(which I cannot modify)
public class Main {
public static void main(String[] args) {
Rational a = new Rational(2, 4);
Rational b = new Rational(2, 6);
System.out.println(a + " + " + b + " = " + a.add(b));
System.out.println(a + " - " + b + " = " + a.sub(b));
System.out.println(a + " * " + b + " = " + a.mul(b));
System.out.println(a + " / " + b + " = " + a.div(b));
Rational[] arr = {new Rational(7, 1), new Rational(6, 1),
new Rational(5, 1), new Rational(4, 1),
new Rational(3, 1), new Rational(2, 1),
new Rational(1, 1), new Rational(1, 2),
new Rational(1, 3), new Rational(1, 4),
new Rational(1, 5), new Rational(1, 6),
new Rational(1, 7), new Rational(1, 8),
new Rational(1, 9), new Rational(0, 1)};
selectSort(arr);
for (int i = 0; i < arr.length-1; ++i) {
if (arr[i].compareTo(arr[i+1]) > 0) {
System.exit(1);
}
}
// for (Rational r : arr) {
// System.out.println(r);
// }
Number n = new Rational(3, 2);
System.out.println(n.doubleValue());
System.out.println(n.floatValue());
System.out.println(n.intValue());
System.out.println(n.longValue());
}
public static <T extends Comparable<? super T>> void selectSort(T[] array) {
T temp;
int mini;
for (int i = 0; i < array.length - 1; ++i) {
mini = i;
for (int j = i + 1; j < array.length; ++j) {
if (array[j].compareTo(array[mini]) < 0) {
mini = j;
}
}
if (i != mini) {
temp = array[i];
array[i] = array[mini];
array[mini] = temp;
}
}
}
}

These methods
public double doubleValue()
{
return (double)doubleValue();
}
public float floatValue()
{
return (float)floatValue();
}
public int intValue()
{
return (int)intValue();
}
public long longValue()
{
return (long)longValue();
}
all result in stack overflow because they're recursively calling themselves with no exit. This is not what you intended.
For each of these methods you need to write code that converts the number represented by your Rational into a double, float, int or long.
By the way, you also have other problems in your definitions of add(), subtract(), and compare() but those have to do with the algorithm you are using vis-a-vis the arithmetical rules that apply to those operations.
public class Rational extends Number implements Comparable<Rational> {
private int num;
private int denom;
public Rational(int num, int denom) {
this.num = num;
this.denom = denom;
}
public int compareTo(Rational r) {
if ((num / denom) - (r.num / r.denom) > 0) {
return +1;
} else if ((num / denom) - (r.num / r.denom) < 0) {
return -1;
}
return 0;
}
public Rational add(Rational r) {
return new Rational(num + r.num, denom + r.denom);
}
public Rational sub(Rational r) {
return new Rational(num - r.num, denom - r.denom);
}
public Rational mul(Rational r) {
return new Rational(num * r.num, denom * r.denom);
}
public Rational div(Rational r) {
return new Rational(num * r.denom, denom * r.num);
}
public int gcd(Rational r) {
int i = 1;
while (i != 0) {
i = denom % r.denom;
denom = r.denom;
r.denom = i;
}
return denom;
}
public String toString() {
String a = num + "/" + denom;
return a;
}
public double doubleValue() {
return (double)num / (double)denom;
}
public float floatValue() {
return (float)num / (float)denom;
}
public int intValue() {
return Math.round(num / denom);
}
public long longValue() {
return Math.round(num / denom);
}
}

Related

Using two methods in a class (Rational) to simplify a fraction

I have a class definition for a class of rational numbers. My assignment is to be able to add, multiply and divide any fraction I put in my main function. My program can do all that, but I'm having trouble simplifying the fractions. I want to try and use only two methods to simplify, for example public void reduce(); and private static gcd();
public class Rational {
private int num;
private int denom;
public Rational() {
num = 0;
denom = 1;
}
public Rational(int n, int d) {
num = n;
denom = d;
reduce();
}
public Rational plus(Rational t) {
int tnum = 0;
int tdenom = 1;
tnum = (this.num * t.denom) + (this.denom * t.num);
tdenom = (t.denom * this.denom);
Rational r = new Rational (tnum, tdenom);
return r;
}
public Rational minus(Rational t) {
int tnum = 0;
int tdenom = 1;
tnum = (this.num * t.denom) - (this.denom * t.num);
tdenom = (t.denom * this.denom);
Rational r = new Rational (tnum, tdenom);
return r;
}
public Rational multiply(Rational t) {
int tnum = 0;
int tdenom = 1;
tnum = this.num * t.num;
tdenom = t.denom * this.denom;
Rational r = new Rational (tnum, tdenom);
return r;
}
public Rational divide(Rational t) {
int tnum = 0;
int tdenom = 1;
tnum = this.num / t.num;
tdenom = this.denom / t.denom;
Rational r = new Rational (tnum, tdenom);
return r;
}
private static int gcd(int n, int d) {
return gcd(d, n%d);
}
public void reduce() {
//call gcd
gcd(num, denom);
//divide num and denom by gcd by
num = num / gcd(num,denom);
denom = denom / gcd(num,denom);
}
public String toString() {
return String.format("%d/%d", num, denom);
}
}
public class RationalMain {
public static void main(String[] args) {
Rational x = new Rational();
Rational y = new Rational(1,4);
Rational z = new Rational(1,2);
//x = y - z;
x = y.plus(z);
System.out.printf("%s = %s + %s\n", x.toString(), y.toString(), z.toString());
x = z.minus(y);
System.out.printf("%s = %s - %s\n", x.toString(), z.toString(), y.toString());
x = z.multiply(y);
System.out.printf("%s = %s * %s\n", x.toString(), z.toString(), y.toString());
x = y.divide(z);
System.out.printf("%s = %s / %s\n", x.toString(), y.toString(), z.toString());
}
}
That's not how you might achieve the Greatest Common Divisor (GCD). Before you will be able to get your code to work properly you will need to at least fix your gcd() method since currently it will recurse until an ArithmeticException (/ by zero) is generated. You might achieve the task this way:
private static int gcd(int num, int den) {
num = Math.abs(num); // if numerator is signed convert to unsigned.
int gcd = Math.abs(den); // if denominator is signed convert to unsigned.
int temp = num % gcd;
while (temp > 0) {
num = gcd;
gcd = temp;
temp = num % gcd;
}
return gcd;
}
To convert your fractions too their Lowest Terms your reduce() method might look like this if it accepted a Fraction String as an argument (you modify the method parameters if you like):
/*
A Fraction String can be supplied as: "1/2", or "2 1/2", or
"2-1/2, or "-2 32/64", or "-2-32/64". The last 2 examples are
negative fraction values.
*/
private String reduce(String fractionString) {
// Fraction can be supplied as: "1/2", or "2 1/2", or "2-1/2".
// Make sure it's a Fraction String that was supplied as argument...
inputString = inputString.replaceAll("\\s+", " ").trim();
if (!inputString.matches("\\d+\\/\\d+|\\d+\\s+\\d+\\/\\d+|\\d+\\-\\d+\\/\\d+")) {
return null;
}
str2 = new StringBuilder();
String wholeNumber, actualFraction;
if (inputString.contains(" ")) {
wholeNumber = inputString.substring(0, inputString.indexOf(" "));
actualFraction = inputString.substring(inputString.indexOf(" ") + 1);
str2.append(wholeNumber);
str2.append(" ");
}
else if (inputString.contains("-")) {
wholeNumber = inputString.substring(0, inputString.indexOf("-"));
actualFraction = inputString.substring(inputString.indexOf("-") + 1);
str2.append(wholeNumber);
str2.append("-");
}
else {
actualFraction = inputString;
}
String[] tfltParts = actualFraction.split("\\/");
int tfltNumerator = Integer.parseInt(tfltParts[0]);
int tfltDenominator = Integer.parseInt(tfltParts[1]);
// find the larger of the numerator and denominator
int tfltN = tfltNumerator;
int tfltD = tfltDenominator;
int tfltLargest;
if (tfltNumerator < 0) {
tfltN = -tfltNumerator;
}
if (tfltN > tfltD) {
tfltLargest = tfltN;
}
else {
tfltLargest = tfltD;
}
// Find the largest number that divides the numerator and
// denominator evenly
int tfltGCD = 0;
for (int tlftI = tfltLargest; tlftI >= 2; tlftI--) {
if (tfltNumerator % tlftI == 0 && tfltDenominator % tlftI == 0) {
tfltGCD = tlftI;
break;
}
}
// Divide the largest common denominator out of numerator, denominator
if (tfltGCD != 0) {
tfltNumerator /= tfltGCD;
tfltDenominator /= tfltGCD;
}
str2.append(String.valueOf(tfltNumerator)).append("/").append(String.valueOf(tfltDenominator));
return str2.toString();
}
As you can see, a whole number can also be supplied with your fraction so, if you do a call to the above reduce() method like this:
System.out.println(reduce("12-32/64"));
System.out.println(reduce("12 32/64"));
The console window will display:
12-1/2
12 1/2

java syntax help for ADT rational implementation [Error: cannot find symbol]

so I am trying to build this ADT for rational numbers in java but for some reason I keep getting this error that says cannot find symbol when trying to compile. What em I doing wrong? Is this error because of my syntax?
Author: Juan Suarez
// Class : CS1102 ~ java
// Date : 01/30/2018
// Topic : This porblem set focuse on the implemantation of an
// ADT for rational numbers.
public class RationalC implements Rational {
private int num;
private int den;
// ****************** CONSTRUCTOR **********************************
public RationalC (int numerator, int denominator) {
if (this.den == 0){
throw new ArithmeticException("*** WARNING! input non zero denominator");
}
int reduceFraction = gcd(numerator, denominator);
this.num = numerator / reduceFraction;
this.den = denominator / reduceFraction;
if (this.den < 0) {
this.den = this.den * -1;
this.num = this.num * -1;
}
}
//********************* GETTERS ************************************
public int getNumerator() { return this.num; }
public int getDenominator() { return this.den; }
public boolean equal(Rational b) {
boolean
a = this.getNumerator == b.getNumerator;
v = this.getDenominator == b.getDenominator;
return a && v;
}
// ******************* OPERATIONS **********************************
//return this + that
//
public RationalC plus(Rational b) {
int commonDenominator = this.getDenominator() * b.getDenominator();
int num1 = b.getDenominator() * this.getNumerator();
int num2 = b.getNumerator() * this.getDenominator();
int complete = num1 + num2;
return new RationalC (complete, commonDenominator);
}
//returns this - that
//
public RationalC subtract(Rational b) {
int commonDenominator = this.getDenominator() * b.getDenominator();
int num1 = b.getDenominator() * this.getNumerator();
int num2 = b.getNumerator() * this.getDenominator();
int complete = num1 - num2;
return new RationalC (complete, commonDenominator);
}
// return this * that
//
public Rational multiply(Rational b){
int top = this.getNumerator() * b.getNumerator();
int bottom = this.getDenominator() * b.getDenominator();
return new RationalC (top, bottom);
}
//return this / that
//
public Rational divide(Rational b){
int top = this.getNumerator() * b.getDenominator();
int bottom = this.getDenominator() * b.getNumerator();
return new RationalC (top, bottom);
}
//retuns value
//
public boolean equals(Rational b) {
if (num == b.getNumerator() && this.getDenominator() == b.getDenominator() )
return(true);
}
//********************* TOOLS **************************************
//returns the rational number to a string
//
public String toString() {
return "(" + this.num + "," + this.den + ")";
}
//returns -1 , 0, +1 if the value of the rational is <, >, or =
//
public int compareTo(Rational b) {
long leftHand = this.getNumerator() * b.getDenominator();
long rightHand = this.getDenominator() * b.getNumerator();
if (leftHand < rightHand) return -1;
if (leftHand > rightHand) return +1;
return 0;
}
private static int gcd(int m, int n) {
if(m < 0) m = -m;
if(n < 0) n = -n;
return m * (n / gcd(m,n));
}
public Rational reciprical(Rational b){
return new RationalC (this.getDenominator(), this.getNumerator() );
}
//******************* TEST UNIT ************************************
public static void main(String[] args) {
x = new Rational (1,2);
y = new Rational (1,3);
z = x.plus(y);
StdOut.println(z);
}
}
In the below piece of code, you didn't declare local variable v.
public boolean equal(Rational b) {
boolean
a = this.getNumerator == b.getNumerator;
v = this.getDenominator == b.getDenominator;
return a && v;
}
getNumerator and getDenominator are methods.
Call them as this.getNumerator() and this.getDenominator().
Also make sure Rational class is having getNumerator and getDenominator methods.

Implementing comparable interface to rational class(java)

I am a beginner in Java and this is my first time using Comparable interface. I don't understand why it keeps returning zero when comparing r1 and r2. Can someone explain to me what is wrong with my code? Thank you.
public class Rational implements Comparable<Rational>{
private int num; //numerator
private int denom; //denominator
public Rational() {
num = 0;
denom = 1;
}
public Rational(int num, int denom) {
if(denom <=0 ){
throw new ArithmeticException("You cannot divide by a non-positive number");
}
this.num = num;
this.denom = denom;
}
//returns numerator of this rational number
public int getNum() {
return num;
}
//returns denominator of this rational number
public int getDenom() {
return denom;
}
public Rational add(Rational rhs) {
return new Rational(num*rhs.denom+rhs.num*denom, denom*rhs.denom);
}
public Rational subtract(Rational rhs) {
return new Rational(num*rhs.denom-rhs.num*denom, denom*rhs.denom);
}
public Rational multiply(Rational rhs) {
return new Rational(num*rhs.num, denom*rhs.denom);
}
public Rational divide(Rational rhs) {
return new Rational(num*rhs.denom, denom*rhs.num);
}
public String toString() {
String result;
if (num == 0)
result = "0";
else if(denom == 1)
result = num + "";
else
result = num + "/" + denom;
return result;
}
public int compareTo(Rational rhs){
double r1 = ((double) getNum()/getDenom());
double r2 = ((double)rhs.getNum() / rhs.getDenom());
return (int) (r1 - r2);
}
public static void main(String[] args) {
Rational r1 = new Rational(1, 2); // 1/2
Rational r2 = new Rational(3, 4); // 3/4
Rational result = r1.add(r2);
Rational result1 = r1.subtract(r2);
Rational result2 = r1.multiply(r2);
Rational result3 = r1.divide(r2);
System.out.println( "r1 + r2 = " + result + "\n" + "r1 - r2 = " + result1 + "\n" + "r1*r2 = "+ result2 + "\n" + "r1/r2 = " + result3 + "\n" + (r1.compareTo(r2)));
}
}
This formula
return (int) (r1 - r2);
produces zero when the difference between r1 and r2 is less than 1, which is the case that you are testing.
Since both denominators are positive by construction of your class, you can cross-multiply and subtract without using division at all:
long a = (long)getNum() * rhs.getDenom();
long b = (long)rhs.getNum() * getDenom();
return Long.compare(a, b);
Use long to avoid overflowing on multiplication.

Calculating Tarloy series in Java

I want to calculate the sum of this function ((-1)^n)*(x^2n)/(2.n!) but my program isn't working.I need your help.Here's what i tried:
public double getCos()
{
double Cos = 0;
for(int i=0;i<=n;i++)
{
Cos+=(power(x,i)/facto(n));
}
return Cos;
}
private double facto(int n)
{
for (int i = 1; i <= n; i++) {
result = result * i;
}
return result*2;
}
private double power(int x,int n)
{
double power=Math.pow(-1,n)*Math.pow(x,2*n);
return power;
}
}
This is How You Make It I Just Fix Some Errors On Your Program :
public class Cos {
public static double getCos(double x) {
double Cos = 0;
for (int i = 0; i <= 5; i++) {
Cos += (power(-1, i) * power(x, 2*i)) / factorial(2*i) ;
}
return Cos;
}
public class Cos {
public static double getCos(double x) {
double Cos = 0;
for (int i = 0; i <= 5; i++) {
Cos += (power(-1, i) * power(x, 2*i)) / factorial(2*i) ;
}
return Cos;
}
private static double factorial(int n) {
int result = 1;
if( n == 0 || n == 1 )
return 1;
else {
for (int i = 1; i <= n; i++) {
result = result * i;
}
return result;
}
}
private static double power(double x, int n) {
return Math.pow(x, n);
}
public static void main(String[] args) {
System.out.println("Test For The 3 Methods!");
System.out.println("5^2 : " + power(5, 2));
System.out.println("4! : " + factorial(4));
System.out.println("Cos(0.2) : " + getCos(0.2));
}
}
private static double power(double x, int n) {
return Math.pow(x, n);
}
public static void main(String[] args) {
System.out.println("Test For The 3 Methods!");
System.out.println("5^2 : " + power(5, 2));
System.out.println("4! : " + factorial(4));
System.out.println("Cos(0.2) : " + getCos(0.2));
}
}
From what I can tell, your difficulties are arising in your facto method. First of all, result was never properly declared (at least in the code provided). Furthermore, when 0 is passed for the first term, i=1 and therefore i<=0 evaluates false and the loop never executes. So what value would result have?
private double facto(int n) {
if(n==0) return 1.0;
double result = 0.0;
for (int i = 1; i <= n; i++) {
result = result * i;
}
return result*2;
}
This is How I Will Make This Exercise :
public class TaylorSeries {
static double power(double x,int n)
{
double p = 1;
for (int i = 1; i <= n ; i++) {
p = p*x;
}
return p;
}
// this is the best way to make factorial function by recursion
static int factorial(int n)
{
if(n == 1 || n == 0)
{
return 1;
}
else
{
return n*factorial(n - 1);
}
}
// i = 0 to i = 5 the 5 is for the summation
static double cos(double x)
{
double cos = 0;
for (int i = 0; i <= 5 ; i++) {
cos += ( power(-1, i) * power(x, 2*i) ) / ( factorial(2*i) );
}
return cos;
}
public static void main(String[] args) {
System.out.println("2^3 : " + power(2, 3));
System.out.println("5! : " + factorial(5));
// 20 means summation from 0 to 20
System.out.println("Cos(0.15) : " + cos(0.15));
}
}

Rational Number Java Project

For this project I have to create a rational number class that has 2 parts an int numerator and int denominator. I had to add two contractions where the negative denominator has to be moved to the numerator. I also added getters and setters and a toString(). The data should print as numerator/denominator.
I also had to code member methods for addition, subtraction, multiplications, and division and negate(?) I am not sure what that last part means.
I have the class done already but Eclipse is giving me an error with the add and subtract method around the part where I typed "temp". Please let me know if I have anything that is incorrect or if I am missing something.
public class Rational {
private int numerator;
private int denominator;
public Rational()
{
numerator = 0;
denominator = 1;
}
public Rational(int n, int d, int num, int denom)
{
if (d < 0)
{
num = -n;
denom = d;
}
else if (d == 0)
{
num = n;
denom = 1;
}
else
{
num = n;
denom = 0;
}
}
public int getNumerator()
{
return numerator;
}
public int getDenominator()
{
return denominator;
}
public void setNumerator(int n)
{
numerator = n;
}
public void setDenominator(int n, int d, int num, int denom)
{
denominator = d;
if (d < 0)
{
num = -n;
denom = d;
}
else if (d == 0)
{
num = n;
denom = 1;
}
else
{
num = n;
denom = 0;
}
}
public String toString()
{
return numerator + "/" + denominator;
}
public boolean equals (Rational other)
{
if(numerator * other.denominator == denominator * other.numerator)
return true;
else
return false;
}
public boolean notequals(Rational other)
{
if (numerator * other.denominator != denominator * other.numerator)
return true;
else
return false;
}
//subtract method
public Rational subtract(Rational other)
{
Rational temp;
temp.numerator = numerator * other.denominator - denominator * other.numerator;
temp.denominator = denominator * other.denominator;
return temp;
}
//add method
public Rational add(Rational other)
{
Rational temp;
temp.numerator = numerator * other.denominator + denominator * other.numerator;
temp.denominator = denominator * other.denominator;
return temp;
}
public boolean lessThan(Rational other)
{
return(numerator * other.denominator < denominator * other.numerator);
}
public boolean greterThan(Rational other)
{
return(numerator * other.denominator > denominator * other.numerator);
}
public boolean lessThanEqualTo(Rational other)
{
return(numerator * other.denominator <= denominator * other.numerator);
}
public boolean greaterThanEqual(Rational other)
{
return(numerator * other.denominator >= denominator * other.numerator);
}
}
I am however struggling with the main to test each method.
Here is what I have so far:
public class Project4 {
public static void main(String[] args) {
Rational a = new Rational();
Rational b = new Rational();
Rational c;
c = a.add(b);
}
}
//Here goes commented code:
public class Rational
{
private int numerator; // You can declare private variables here all right
private int denominator;
// This constructor creates a new object of the class Rational. Objects are instances of that class, all right?
public Rational()
{
numerator = 0;
denominator = 1;
//private int numerator = 0;
//private int denominator = 1; // I get it, you need them even when not giving arguments, but it is better to do stuff in constructors. You better try to make declarations in the constructor and not in the begining of a class, if possible.
}
// Here is the constructor overriden, so you can create an instance that contains 4 arguments. (n,d,num,denom) Good.
public Rational(int n, int d, int num, int denom)
{
// You repeat yourself in the constructor.
// public void setDenominator(int n, int d, int num, int denom) does the same thing right?
// I don't remember now, but I think that on instantiation you can't use methods, if you don't add the word static.
// public static void setDenominator(int n, int d, int num, int denom) will make you able to call it in the constructor!
if (d < 0)
{
num = -n;
denom = d;
}
else if (d == 0)
{
num = n;
denom = 1;
}
else
{
num = n;
denom = 0;
}
}
public int getNumerator()
{
return numerator;
}
public int getDenominator()
{
return denominator;
}
public void setNumerator(int n)
{
numerator = n;
}
public void setDenominator(int n, int d, int num, int denom) // FIX IT. ADD STATIC
{
denominator = d;
if (d < 0)
{
num = -n;
denom = d;
}
else if (d == 0)
{
num = n;
denom = 1;
}
else
{
num = n;
denom = 0;
}
}
public String toString()
{
return numerator + "/" + denominator;
}
public boolean equals (Rational other)
{
if(numerator * other.denominator == denominator * other.numerator)
return true;
else
return false;
}
public boolean notequals(Rational other)
{
if (numerator * other.denominator != denominator * other.numerator)
return true;
else
return false;
}
//subtract method
public Rational subtract(Rational other)
{
Rational temp;
temp.numerator = numerator * other.denominator - denominator * other.numerator;
temp.denominator = denominator * other.denominator;
return temp;
} // THIS RETURNS temp THAT IS AN OBJECT OF THE TYPE Rational!!! Remember that.
//add method
public Rational add(Rational other)
{
Rational temp;
temp.numerator = numerator * other.denominator + denominator * other.numerator;
temp.denominator = denominator * other.denominator;
return temp;
}// THIS RETURNS temp THAT IS AN OBJECT OF THE TYPE Rational!!! Remember that.
public boolean lessThan(Rational other)
{
return(numerator * other.denominator < denominator * other.numerator);
}// What type is this method return? Here is the gap you must fill. If you learn how to handel what methods return, you will be fine. Try stuff out.
public boolean greterThan(Rational other)
{
return(numerator * other.denominator > denominator * other.numerator);
}
public boolean lessThanEqualTo(Rational other)
{
return(numerator * other.denominator <= denominator * other.numerator);
}
public boolean greaterThanEqual(Rational other)
{
return(numerator * other.denominator >= denominator * other.numerator);
}
}

Categories