Methods Summary |
---|
public oracle.sql.CustomDatum | create(oracle.sql.Datum d, int sqlType)
if (d == null) return null;
MyRationalC o = new MyRationalC();
o._struct = new MutableStruct((STRUCT) d, _sqlType, _factory);
return o;
|
public static int | gcd(int x, int y)
if (x < y)
return gcd(y, x);
if (x % y == 0)
return y;
return gcd (y, x / y);
|
public static oracle.sql.CustomDatumFactory | getFactory()
return _MyRationalCFactory;
|
public void | normalize()
int n = getNumerator();
int d = getDenominator();
int g = gcd(n, d);
setNumerator(n/g);
setDenominator(d/g);
|
public MyRationalC | plus(MyRationalC x)
return new MyRationalC(
getNumerator() * x.getDenominator() +
x.getNumerator() * getDenominator(),
getDenominator() * x.getDenominator());
|
public float | toReal()
return ((float) getNumerator())/getDenominator();
|
public java.lang.String | toString()
try
{
return getNumerator() + "/" + getDenominator();
}
catch (SQLException e)
{
return null;
}
|