Class: Math::SetTheory::IntegerNumbers
- Includes:
- Singleton
- Defined in:
- lib/ruuuby/math/set_theory/discrete/integer_numbers.rb
Instance Attribute Summary
Attributes inherited from NumberSet
Attributes inherited from Closure
Instance Method Summary collapse
-
#initialize ⇒ IntegerNumbers
constructor
A new instance of IntegerNumbers.
-
#β?(n) ⇒ Boolean
True, if this number is equivalent to 0 or 1 numbers in the boolean-domain(+πΉ+).
Methods inherited from NumberSet
#countable?, #countably_infinite?, #finite?, #uncountable?, #β?, #β?, #β?, #β?, #β ?, #β?, #β?
Constructor Details
#initialize ⇒ IntegerNumbers
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(+πΉ+).
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 |