|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.ObjectSquareRootFraction
class SquareRootFraction
This class introduces all square roots of fractions (SRF) and features basic necessary operations with them.
SquareRootFractions are numbers in form (n*√nSqrt)/d, where all n, nSqrt, and d are integers (nSqrt is a non-negative integer).
| Field Summary | |
|---|---|
(package private) long |
d
denominator |
(package private) long |
n
whole part of the numerator |
(package private) long |
nSqrt
square-root-part of the numerator |
| Constructor Summary | |
|---|---|
SquareRootFraction(Fraction F)
Constructs a SquareRootFraction from a Fraction. |
|
SquareRootFraction(long nn)
Constructs a SquareRootFraction from an integer. |
|
SquareRootFraction(long nn,
long dd)
Constructs a SquareRootFraction from its numerator and denominator. |
|
| Method Summary | |
|---|---|
(package private) Fraction |
convertToFraction()
Converts this SquareRootFraction to a Fraction if it indeed is a rational number. |
(package private) SquareRootFraction |
divide(SquareRootFraction d)
Divides this SquareRootFraction by another SquareRootFraction. |
(package private) boolean |
isEqual(SquareRootFraction c)
Checks if two SquareRootFractions are equal. |
(package private) SquareRootFraction |
multiply(SquareRootFraction f)
Multiplies this SquareRootFraction by another SquareRootFraction. |
(package private) Fraction |
squared()
Squares SquareRootFraction producing a simple fraction. |
(package private) String |
toTeX()
Prints this SquareRootFraction formatted as TeX code. |
(package private) String |
toText()
Prints this SquareRootFraction formatted as text. |
| Methods inherited from class |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
long d
long n
long nSqrt
| Constructor Detail |
|---|
SquareRootFraction(Fraction F)
SquareRootFraction from a Fraction. For example, SquareRootFraction(new Fraction(1,2)) yields √2/2.
F - fraction to be taken the square root of
IllegalArgumentException - Throws an exception if the fraction is negative.
IllegalArgumentException - Throws an exception if the denominator would be zero.SquareRootFraction(long nn)
SquareRootFraction from an integer. For example, SquareRootFraction(2) yields √2.
nn - integer to be taken a square root of
IllegalArgumentException - Throws an exception if the number is negative.
SquareRootFraction(long nn,
long dd)
SquareRootFraction from its numerator and denominator. For example, SquareRootFraction(1,2) yields √2/2.
nn - nominatordd - denominator
IllegalArgumentException - Throws an exception if the fraction is negative.
IllegalArgumentException - Throws an exception if the denominator would be zero.| Method Detail |
|---|
Fraction convertToFraction()
SquareRootFraction to a Fraction if it indeed is a rational number.
SquareRootFraction re-typed to Fraction with preserved valueSquareRootFraction divide(SquareRootFraction d)
SquareRootFraction by another SquareRootFraction.
d - divisorboolean isEqual(SquareRootFraction c)
SquareRootFractions are equal.
c - comparand
SquareRootFraction is equal to the comparand, false otherwiseSquareRootFraction multiply(SquareRootFraction f)
SquareRootFraction by another SquareRootFraction.
f - factor
Fraction squared()
SquareRootFraction producing a simple fraction.
SquareRootFractionString toTeX()
SquareRootFraction formatted as TeX code.
SquareRootFraction; for example, -3*√2/7 yields -\frac{3\sqrt{2}}{7}String toText()
SquareRootFraction formatted as text.
SquareRootFraction; for example, -3*√2/7 yields -3*sqrt(2)/7
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||