1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
|
# File 'lib/m500.rb', line 1506
def + (a)
if a == 0
return self
elsif @numerator == 0 and @denominator == 1
return a.to_Q
elsif a.kind_of?(Fraction)
self + a.to_Q
elsif a.kind_of?(Quotient)
num = (@numerator*@abs1) * (a.denominator)
num_a = (a.numerator*a.abs1) * @denominator
Quotient(num + num_a, @denominator * a.denominator)
elsif a.kind_of?(NaughtClass) or a.kind_of?(EmptySetClass)
self
elsif a.kind_of?(NANClass) or a.kind_of?(InfinityClass)
infinity
elsif (a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Bignum) or a.kind_of?(Fixnum))
self + Quotient(a, 1)
elsif a.kind_of?(Float)
Float(self) + a
else
x, y = a.coerce(self)
x + y
end
end
|