Rational

Rational

ri

 ---------------------------------------------- Class: Rational < Numeric
      Rational implements a rational class for numbers.
 
      _A rational number is a number that can be expressed as a fraction
      p/q where p and q are integers and q != 0. A rational number p/q is
      said to have numerator p and denominator q. Numbers that are not
      rational are called irrational numbers._
      (http://mathworld.wolfram.com/RationalNumber.html)
 
      To create a Rational Number:
 
        Rational(a,b)             # -> a/b
        Rational.new!(a,b)        # -> a/b
 
      Examples:
 
        Rational(5,6)             # -> 5/6
        Rational(5)               # -> 5/1
 
      Rational numbers are reduced to their lowest terms:
 
        Rational(6,10)            # -> 3/5
 
      But not if you use the unusual method "new!":
 
        Rational.new!(6,10)       # -> 6/10
 
      Division by zero is obviously not allowed:
 
        Rational(3,0)             # -> ZeroDivisionError
 
 ------------------------------------------------------------------------
 
 
 Class methods:
 --------------
      new, new!, reduce
 
 
 Instance methods:
 -----------------
      %, *, **,  , -, /, <=>, ==, abs, coerce, divmod, hash, inspect,
      to_f, to_i, to_r, to_s
 
 Attributes:
      denominator, numerator

refe

 ==== Rational ====
 執筆者募集
 ---- Singleton methods ----
 ---- Instance methods ----
 % * **   - / <=> abs divmod to_f to_i to_s
 ---- Singleton methods (inherited) ----
 ---- Instance methods (inherited) ----
  @ -@ < <= == === =~ > >= __id__ __send__ _dump _load
 between? ceil class clone coerce display div dup eql?
 equal? extend floor freeze frozen? hash id initialize
 initialize_copy inspect instance_eval instance_of?
 instance_variable_get instance_variable_set
 instance_variables integer? is_a? kind_of? marshal_dump
 marshal_load method method_missing methods modulo nil?
 nonzero? object_id pretty_print pretty_print_cycle
 pretty_print_instance_variables private_methods
 protected_methods public_methods quo remainder
 remove_instance_variable respond_to? round send
 singleton_method_added singleton_method_removed
 singleton_method_undefined singleton_methods step taint
 tainted? to_a to_ary to_hash to_int to_str truncate type
 untaint zero?

  • 2006/05/12 19:52:11 %
  • 2006/05/12 19:52:25 *
  • 2006/05/12 19:52:41 -
  • 2006/05/12 19:52:48 <
  • 2006/05/12 19:53:03 <=
  • 2006/05/12 19:53:11 <=>
  • 2006/05/12 19:53:19 ==
  • 2006/05/12 19:53:41 >
  • 2006/05/15 12:32:31 inspect
  • 2006/05/15 12:42:14 new
  • 2006/05/12 20:38:01 Rational
  • 2006/05/15 13:05:00 to_f
  • 2006/05/15 13:05:16 to_i
  • 2006/05/15 13:05:31 to_s
  • 2006/05/15 11:59:52 ^