class Zahlen
Public Class Methods
new(a)
click to toggle source
# File lib/m500.rb, line 1399 def initialize(a) if (a.kind_of?(Zahlen)) @a = a.to_i elsif a.kind_of?(Integer) #a.kind_of?(Fixnum) or a.kind_of?(Bignum) @a = a else end end
new!(num)
click to toggle source
# File lib/m500.rb, line 1395 def Zahlen.new!(num) new(num) end
Private Class Methods
new(a)
click to toggle source
# File lib/m500.rb, line 786 def initialize(a) if (a.kind_of?(Integer) && a >= 1) #(a.kind_of?(Fixnum) && a >= 1) or (a.kind_of?(Bignum) && a >= 1) @a = a else emptySet end end
Public Instance Methods
%(a)
click to toggle source
# File lib/m500.rb, line 1466 def % (a) self.to_i%(a.to_i) end
*(a)
click to toggle source
# File lib/m500.rb, line 1435 def * (a) if a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Integer) # a.kind_of?(Bignum) or a.kind_of?(Fixnum) Zahlen(self.to_i * a.to_i) elsif a.kind_of?(Quotient) or a.kind_of?(Fraction) a * Quotient(@a,1) elsif a.kind_of?(NaughtClass) or a.kind_of?(EmptySetClass) or a.nil? naught elsif a.kind_of?(NANClass) or a.kind_of?(InfinityClass) infinity else x , y = a.coerce(self) Zahlen(x * y) end end
**(a)
click to toggle source
# File lib/m500.rb, line 1458 def ** (a) if a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) Zahlen(self.to_i ** a.to_i) else x, y = a.coerce(self) Zahlen(x ** y) end end
+(a)
click to toggle source
# File lib/m500.rb, line 1407 def + (a) if a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Integer) #a.kind_of?(Bignum) or a.kind_of?(Fixnum) Zahlen(self.to_i + a.to_i) elsif a.kind_of?(Quotient) or a.kind_of?(Fraction) a + Quotient(@a,1) elsif a.kind_of?(NaughtClass) or a.kind_of?(EmptySetClass) self elsif a.kind_of?(NANClass) or a.kind_of?(InfinityClass) infinity else x, y = a.coerce(self) x + y end end
-(a)
click to toggle source
# File lib/m500.rb, line 1421 def - (a) if a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Integer) #a.kind_of?(Bignum) or a.kind_of?(Fixnum) Zahlen(self.to_i - a.to_i) elsif a.kind_of?(Quotient) or a.kind_of?(Fraction) a - Quotient(@a,1) elsif a.kind_of?(NaughtClass) or a.kind_of?(EmptySetClass) self elsif a.kind_of?(NANClass) or a.kind_of?(InfinityClass) infinity*(-1) else x, y = a.coerce(self) Zahlen(x - y) end end
/(a)
click to toggle source
# File lib/m500.rb, line 1449 def / (a) if (a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Integer)) and self.to_i%(a.to_i) == 0 #a.kind_of?(Bignum) or a.kind_of?(Fixnum)) and self.to_i%(a.to_i) == 0 Zahlen(self.to_i / a.to_i) elsif a.kind_of?(Quotient) or a.kind_of?(Fraction) self * Quotient(a.to_Q.denominator,a.to_Q.numerator) else emptySet end end
<=>(other)
click to toggle source
# File lib/m500.rb, line 1497 def <=>(other) self.to_i <=> other.to_i end
abs()
click to toggle source
# File lib/m500.rb, line 1469 def abs @a.to_i.abs end
coerce(other)
click to toggle source
# File lib/m500.rb, line 1481 def coerce(other) # if other.kind_of?(Float) then # other, @a # elsif other.kind_of?(Numeric) # return Zahlen.new!(other.to_i), self # else # other, @a # end [other, @a] end
gcd(n)
click to toggle source
# File lib/m500.rb, line 1472 def gcd(n) g = nil if @a>0 then g = Natural( @a).gcd(n) else g = Natural(-1* @a).gcd(n) end g end
inspect()
click to toggle source
# File lib/m500.rb, line 1536 def inspect sprintf("Zahlen(%s)", @a.to_s) end
next()
click to toggle source
# File lib/m500.rb, line 1491 def next self + Zahlen(1) end
next_prime()
click to toggle source
# File lib/m500.rb, line 1539 def next_prime emptySet end
succ()
click to toggle source
# File lib/m500.rb, line 1494 def succ self.next end
to_Dec()
click to toggle source
# File lib/m500.rb, line 1525 def to_Dec Decimal(@a,0,'0') end
to_Frac()
click to toggle source
# File lib/m500.rb, line 1519 def to_Frac Fraction(@a,Quotient(0,1)) end
to_K()
click to toggle source
# File lib/m500.rb, line 1531 def to_K Kettenbruch(self.to_Frac) end
to_N()
click to toggle source
# File lib/m500.rb, line 1509 def to_N Natural(@a) end
to_N0()
click to toggle source
# File lib/m500.rb, line 1512 def to_N0 Counting(@a) end
to_Q()
click to toggle source
# File lib/m500.rb, line 1522 def to_Q Quotient(@a,1) end
to_R()
click to toggle source
# File lib/m500.rb, line 1534 def to_R end
to_Sig()
click to toggle source
# File lib/m500.rb, line 1528 def to_Sig Sigma(self.to_Q) end
to_Z()
click to toggle source
# File lib/m500.rb, line 1515 def to_Z self #Zahlen(@a) end
to_f()
click to toggle source
# File lib/m500.rb, line 1503 def to_f @a.to_f end
to_i()
click to toggle source
# File lib/m500.rb, line 1500 def to_i @a.to_i end
to_s()
click to toggle source
# File lib/m500.rb, line 1506 def to_s "Zahlen(#{@a})" end
to_sgml()
click to toggle source
# File lib/m500.rb, line 1392 def to_sgml "<mn #{sgml_id}class='zahlen'>#{@a}</mn>" end