Class: Math::SetTheory::IntegerNumbers

Inherits:
NumberSet show all
Includes:
Singleton
Defined in:
lib/ruuuby/math/set_theory/discrete/integer_numbers.rb

Instance Attribute Summary

Attributes inherited from NumberSet

#name, #symbol, #𝔠

Attributes inherited from Closure

#axioms

Instance Method Summary collapse

Methods inherited from NumberSet

#countable?, #countably_infinite?, #finite?, #uncountable?, #∌?, #βŠ‚?, #βŠƒ?, #βŠ„?, #βŠ…?, #βŠ†?, #βŠ‡?

Constructor Details

#initializeIntegerNumbers

Returns a new instance of IntegerNumbers.



10
11
12
13
14
15
16
17
18
# File 'lib/ruuuby/math/set_theory/discrete/integer_numbers.rb', line 10

def initialize
  super(:β„€, ::Math::SetTheory::NumberSet::AlephNumbers::ZERO, {
      closed_under_addition: true,
      closed_under_multiplication: true,
      closed_under_subtraction: true
  })
  @subset_of   = [:π•Œ, :𝔸ᡣ, :𝔸, :ℝ, :β„‚, :β„š]
  @superset_of = [:𝔹, :β„•, :π•Ž]
end

Instance Method Details

#βˆ‹?(n) ⇒ Boolean

Returns true, if this number is equivalent to 0 or 1 numbers in the boolean-domain(+𝔹+).

Returns:

  • (Boolean)

    true, if this number is equivalent to 0 or 1 numbers in the boolean-domain(+𝔹+)



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/ruuuby/math/set_theory/discrete/integer_numbers.rb', line 21

def βˆ‹?(n)
  case(n)
  when ::Integer
    true
  when ::Float
    (!(n.∞?)) && (n.zero? || ((n % 1) == 0))
  when ::BigDecimal
    case n.sign
    when ::BigDecimal::SIGN_NaN, ::BigDecimal::SIGN_POSITIVE_INFINITE, ::BigDecimal::SIGN_NEGATIVE_INFINITE
      false
    when ::BigDecimal::SIGN_POSITIVE_ZERO, ::BigDecimal::SIGN_NEGATIVE_ZERO, ::BigDecimal::SIGN_NEGATIVE_FINITE
      true
    else
      n.smells_like_int?
    end
  when ::Complex
    n.imaginary == 0 && β„€.βˆ‹?(n.real)
    #  n.imaginary == 0 && β„•.βˆ‹?(n.real)
  when ::Rational
    n.finite? && (n.fdiv(1) % 1 == 0)
  else
    false
  end
end