Skip to content

Commit

Permalink
Bit of cleanup in rational.jl.
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKarpinski committed Apr 17, 2012
1 parent 27294d0 commit 4bd8386
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions base/rational.jl
Expand Up @@ -16,13 +16,12 @@ Rational{T<:Integer}(n::T, d::T) = Rational{T}(n,d)
Rational(n::Integer, d::Integer) = Rational(promote(n,d)...)
Rational(n::Integer) = Rational(n,one(n))

//(n::Integer, d::Integer) = Rational(n,d)
//(x::Rational, y::Integer) = x.num // (x.den*y)
//(x::Integer, y::Rational) = (x*y.den) // y.num
//(x::Rational, y::Rational) = (x.num*y.den) // (x.den*y.num)
//(x::Complex, y::Real) = complex(real(x)//y, imag(x)//y)
//(x::Real, y::Complex) = x*y'//real(y*y')
//(x::Rational, y::Rational) = Rational(x.num*y.den, x.den*y.num)
//(n::Integer, d::Integer ) = Rational(n,d)
//(x::Rational, y::Integer ) = x.num//(x.den*y)
//(x::Integer, y::Rational) = (x*y.den)//y.num
//(x::Rational, y::Rational) = (x.num*y.den)//(x.den*y.num)
//(x::Complex, y::Real ) = complex(real(x)//y,imag(x)//y)
//(x::Real, y::Complex ) = x*y'//real(y*y')

function //(x::Complex, y::Complex)
xy = x*y'
Expand Down Expand Up @@ -93,7 +92,7 @@ hash(x::Rational) = integer_valued(x) ? hash(x.num) :
+(x::Rational, y::Rational) = (x.num*y.den + x.den*y.num) // (x.den*y.den)
-(x::Rational, y::Rational) = (x.num*y.den - x.den*y.num) // (x.den*y.den)
*(x::Rational, y::Rational) = (x.num*y.num) // (x.den*y.den)
/(x::Rational, y::Rational) = x // y
/(x::Rational, y::Rational) = (x.num*y.den) // (x.den*y.num)
/(x::Rational, z::ComplexPair) = inv(z/x)

==(x::Rational, y::Rational) = x.den == y.den && x.num == y.num
Expand Down

0 comments on commit 4bd8386

Please sign in to comment.