## com.perisic.ring Class RationalField

```java.lang.Object
com.perisic.ring.Ring
com.perisic.ring.RationalField
```

`public class RationalFieldextends Ring`

The field Q of rational numbers. The only instance of this field is Ring.Q

• Last Change: 13.12.2003: GPL.
• Email: ring@perisic.com. Please let me know if you use this software.
• WWW: www.ring.perisic.com
• The com.perisic.ring library is distributed under the terms of the GNU Lesser General Public License (LGPL).
• disclaimer: The classes are provided "as is". There is no warranty implied by using the com.perisic.ring package.

Version:
0.2
Author:

Field Summary

Fields inherited from class com.perisic.ring.Ring
`C, F2, R, Z`

Method Summary
` RingElt` ```add(RingElt a, RingElt b)```
Returns a + b.
` RingElt` ```construct(java.math.BigInteger numerator, java.math.BigInteger denominator)```
Returns numerator/denominator.
`static java.math.BigInteger` `denominatorToBigInteger(RingElt b)`
Returns the denominator s if b = r/s.
` boolean` `equalZero(RingElt b)`
True if b == 0.
` RingElt` `inv(RingElt b)`
Returns the multiplicative inverse.
` boolean` `isField()`
Returns true.
`static boolean` `isIntegral(RingElt b)`
true if denominator of b equals 1.
` RingElt` `map(RingElt a)`
Maps Ring.Z elements and into this.
` RingElt` `map(java.lang.String a)`
Maps the String a of the form xxxxx/yyyyy and xxxxxx into this field.
` RingElt` ```mult(RingElt a, RingElt b)```
Returns a * b.
` RingElt` `neg(RingElt b)`
Returns -b.
`static java.math.BigInteger` `numeratorToBigInteger(RingElt b)`
Returns the numerator r if b = r/s.
` RingElt` `one()`
Returns 1.
` java.lang.String` `toString()`
Returns "Q".
` RingElt` `zero()`
Returns 0.

Methods inherited from class com.perisic.ring.Ring
`div, ediv, eltToString, equal, evaluatePolynomial, gcd, isEuclidian, isUFD, map, map, map, mod, pow, pow, sub, tdiv`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Method Detail

### isField

`public boolean isField()`
Returns true.

Overrides:
`isField` in class `Ring`

```public RingElt add(RingElt a,
RingElt b)```
Returns a + b.

Specified by:
`add` in class `Ring`

### mult

```public RingElt mult(RingElt a,
RingElt b)```
Returns a * b.

Specified by:
`mult` in class `Ring`

### one

`public RingElt one()`
Returns 1.

Overrides:
`one` in class `Ring`

### zero

`public RingElt zero()`
Returns 0.

Specified by:
`zero` in class `Ring`

### inv

`public RingElt inv(RingElt b)`
Returns the multiplicative inverse.

Overrides:
`inv` in class `Ring`

### neg

`public RingElt neg(RingElt b)`
Returns -b.

Specified by:
`neg` in class `Ring`

### equalZero

`public boolean equalZero(RingElt b)`
True if b == 0.

Specified by:
`equalZero` in class `Ring`

### map

`public RingElt map(RingElt a)`
Maps Ring.Z elements and into this.

Overrides:
`map` in class `Ring`

### toString

`public java.lang.String toString()`
Returns "Q".

Overrides:
`toString` in class `java.lang.Object`

### isIntegral

`public static boolean isIntegral(RingElt b)`
true if denominator of b equals 1.

### numeratorToBigInteger

`public static java.math.BigInteger numeratorToBigInteger(RingElt b)`
Returns the numerator r if b = r/s.

### denominatorToBigInteger

`public static java.math.BigInteger denominatorToBigInteger(RingElt b)`
Returns the denominator s if b = r/s.

### construct

```public RingElt construct(java.math.BigInteger numerator,
java.math.BigInteger denominator)```
Returns numerator/denominator.

### map

`public RingElt map(java.lang.String a)`
Maps the String a of the form xxxxx/yyyyy and xxxxxx into this field.

Overrides:
`map` in class `Ring`
Throws:
`RingException` - if the String is not of the form above.