Questions tagged [rational-number]

A rational is a number that can be expressed as the ratio of two integers.

In mathematics, a rational number is any number that can be expressed as the quotient or fraction p/q of two integers, p and q, with the denominator q not equal to zero. Since q may be equal to 1, every integer is a rational number. The set of all rational numbers is usually denoted by a boldface Q (or blackboard bold (\mathbb{Q} in LaTeX), Unicode ℚ); it was thus denoted in 1895 by Peano after quoziente, Italian for "quotient".

110 questions
0
votes
1 answer

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…
Somone
  • 63
  • 1
  • 2
  • 12
0
votes
3 answers

decimal number to utf-8 rational number in Java

i want to change 2.5 to 2½. Not sure how to change it. Let say I have “AMZN 2½ 22” in a long text that I have to highlight in java swing textpane but I have values in three variable as below A = AMZN B = 2.5 C = 22 Based on this value I will not be…
Rajiv525
  • 141
  • 2
  • 10
0
votes
2 answers

Which versions of Python use rational arithmetic by default?

If I type the following into either the Python 2.7.1 shell or the 3.3.2 shell: a = 0.1 b = 0.1 (a + b) == 0.2 it returns the value true. From stackoverflow and this video from MIT, I was under the impression that this would return false, since…
Chris Middleton
  • 5,654
  • 5
  • 31
  • 68
0
votes
1 answer

Methods in Class Rational

im almost done with my Class Rational, having a little problem when implementing comparison. when i compare a Rational number with int, if the Rational is the left operand, then all is well, but when the comparison is int < Rational, it doesn't…
0
votes
2 answers

Methods regarding Class Rational python

i wrote the two methods, i still see no difference between the two methods..my class works fine so far , but since the methods are written the same, i still can't understand why when i do : x+1 it calls add , and 1+x it calls radd ? def…
0
votes
1 answer

Method to Rational - numerator and denominator

In this class there is a Rational constructor that takes two numbers as parameters and turns them into a fraction. It uses the private method gcd to reduce the fraction into the lowest possible terms. The part I don't understand why the Rational…
Jessica M.
  • 1,451
  • 12
  • 39
  • 54
0
votes
2 answers

Writing a function to check if a relational statement is true or false

Here is the function (I hope the logic is fairly obvious). Let x be one of the '<' or '>' operators and a and b are the terms. int rationalCheck(x, a, b){ if ( x == '<' && a < b && b < a ){ printf( "a is less than b\n" ); } if…
RandomNumberFun
  • 638
  • 2
  • 8
  • 25
0
votes
1 answer

The fractions I enter always return 0?

Possible Duplicate: Division in Java always results in zero (0)? So I'm writing this program and I thought it was good. The GUI window popped up and I entered a numerator and a demoninator. But no matter what I enter, it always says that it…
0
votes
1 answer

constructor Rational in class Rational cannot be applied to the given types?

So the gist of this program is to create a Rational class so that when you run it, a GUI input will come up and ask for a numerator and a denominator. It will then return the reduced fraction. But I keep getting this error message and I don't know…
0
votes
2 answers

Rational numbers not behaving like fractions in algebra with Ruby

Can someone please explain this to me? x = Rational(3/4) * 8 => (0/1) # I Expected it to return 6 x.to_i => 0 Thanks.
steven_noble
  • 4,133
  • 10
  • 44
  • 77
0
votes
1 answer

Generate next rational number

How can i generate the next rational number into 2 integer variables. For example, If i have x=3 and y = 2 the next rational number is x=3 and y=3. The number generation need to be like the next order: See the needed order Someone has an idea how…
Ofir
  • 5,049
  • 5
  • 36
  • 61
-1
votes
1 answer

java-processing floating point rounding error, how to keep radians rational

I have modified this arcball class so that every call to arcball.rollforward(PI/180); rotates a matrix 1 degree. I have tried to set it up so arcball.rollback() is called with the accumulated float rotatebywithincludedfloaterror but it has had the…
cubesareneat
  • 302
  • 2
  • 14
-1
votes
2 answers

Java Methods Using Rationals

I have a rational class and a main class. A lot of my code is done in the rational class and then I invoke it in the main class. However, a few of the rationals are not printing like real numbers. They look like this: rational.Rational@7852e922. I…
Sikki Nixx
  • 49
  • 3
-1
votes
1 answer

How do I use a point class, rational number class, and line class to Solve a system of 2 linear equations?

I am fairly new to computer science and have been trying, unsuccessfully, to use a point class, a line class, and a Rational number class in order to solve a System of linear equations. The code for the System is old and I'm adapting it to work for…
hell2the0
  • 1
  • 1
-2
votes
2 answers

How to write Rational Fractions using classes in c++

I have to implement Rational class in order to get Rational fractions. The header.h file is provided by my instructor so I have to follow up. I also have to write copy constructor in Rational::Rational(const Rational& cRational) function so the…