1273件ヒット
[1-100件を表示]
(0.085秒)
ライブラリ
- ビルトイン (850)
- bigdecimal (72)
-
bigdecimal
/ util (12) - date (84)
-
json
/ add / rational (24) - mathn (8)
- matrix (144)
-
net
/ http (7) - stringio (12)
クラス
キーワード
- * (24)
- ** (16)
- + (12)
- - (24)
- -@ (21)
-
/ (35) - <=> (24)
- == (12)
- BigDecimal (24)
-
NEWS for Ruby 2
. 1 . 0 (12) - Numeric (12)
- Ruby用語集 (12)
- abs (9)
- ajd (12)
- amjd (12)
- at (53)
-
bigdecimal
/ util (12) - ceil (12)
- coerce (48)
- cofactor (12)
-
cofactor
_ expansion (12) - convert (12)
- denominator (36)
- det (12)
-
det
_ e (12) - determinant (12)
-
determinant
_ e (12) - div (12)
-
elements
_ to _ r (12) - exp (12)
- fdiv (12)
- finite? (9)
- floor (12)
- hash (12)
- inspect (12)
-
json
/ add / rational (12) -
json
_ create (12) -
laplace
_ expansion (12) - log (12)
- magnitude (9)
-
marshal
_ dump (12) - matrix (12)
- negative? (9)
- nonzero? (12)
- numerator (36)
- offset (12)
- positive? (9)
- putc (12)
- quo (24)
- rand (24)
- rank (12)
- rationalize (108)
- real (12)
- real? (12)
- round (12)
- rsqrt (4)
-
sec
_ fraction (12) -
second
_ fraction (12) - subsec (12)
-
to
_ c (12) -
to
_ d (12) -
to
_ f (12) -
to
_ i (12) -
to
_ int (12) -
to
_ json (12) -
to
_ r (96) -
to
_ s (12) - tr (12)
- trace (12)
- truncate (12)
-
write
_ timeout= (7)
検索結果
先頭5件
-
Rational (44060.0)
-
有理数を扱うクラスです。
...できます。Integer や Float
と同様に Rational.new ではなく、 Kernel.#Rational を使用して
Rational オブジェクトを作成します。
//emlist[例][ruby]{
Rational(1, 3) # => (1/3)
Rational('1/3') # => (1/3)
Rational('0.33') # => (33/100)
Rational.new(1, 3) #......=> NoMethodError
//}
Rational オブジェクトは常に既約(それ以上約分できない状態)である
事に注意してください。
//emlist[例][ruby]{
Rational(2, 6) # => (1/3)
Rational(1, 3) * 3 # => (1/1)
//}... -
Rational
# rationalize(eps = 0) -> Rational (36435.0) -
自身から eps で指定した許容誤差の範囲に収まるような Rational を返 します。
...な Rational を返
します。
eps を省略した場合は self を返します。
@param eps 許容する誤差
//emlist[例][ruby]{
r = Rational(5033165, 16777216)
r.rationalize # => (5033165/16777216)
r.rationalize(Rational(0.01)) # => (3/10)
r.rationalize(Rational(0.1))... -
Rational
# ceil(precision = 0) -> Integer | Rational (27267.0) -
自身と等しいかより大きな整数のうち最小のものを返します。
...を返します。
@param precision 計算結果の精度
@raise TypeError precision に整数以外のものを指定すると発生します。
//emlist[例][ruby]{
Rational(3).ceil # => 3
Rational(2, 3).ceil # => 1
Rational(-3, 2).ceil # => -1
//}
precision を指定した場合は指......か Rational を返します。
//emlist[例][ruby]{
Rational('-123.456').ceil(+1) # => (-617/5)
Rational('-123.456').ceil(+1).to_f # => -123.4
Rational('-123.456').ceil(0) # => -123
Rational('-123.456').ceil(-1) # => -120
//}
@see Rational#floor, Rational#round, Rational#trunc... -
Rational
# denominator -> Integer (27230.0) -
分母を返します。常に正の整数を返します。
...分母を返します。常に正の整数を返します。
@return 分母を返します。
//emlist[例][ruby]{
Rational(7).denominator # => 1
Rational(7, 1).denominator # => 1
Rational(9, -4).denominator # => 4
Rational(-2, -10).denominator # => 5
//}
@see Rational#numerator... -
Rational
# inspect -> String (27230.0) -
自身を人間が読みやすい形の文字列表現にして返します。
...に10進数の表記を返します。
@return 有理数の表記にした文字列を返します。
//emlist[例][ruby]{
Rational(5, 8).inspect # => "(5/8)"
Rational(2).inspect # => "(2/1)"
Rational(-8, 6).inspect # => "(-4/3)"
Rational(0.5).inspect # => "(1/2)"
//}
@see Rational#to_s... -
Rational
# magnitude -> Rational (27214.0) -
自身の絶対値を返します。
...自身の絶対値を返します。
//emlist[例][ruby]{
Rational(1, 2).abs # => (1/2)
Rational(-1, 2).abs # => (1/2)
//}... -
Rational
# to _ i -> Integer (27204.0) -
小数点以下を切り捨てて値を整数に変換します。
...ision 計算結果の精度
@raise TypeError precision に整数以外のものを指定すると発生します。
//emlist[例][ruby]{
Rational(2, 3).to_i # => 0
Rational(3).to_i # => 3
Rational(300.6).to_i # => 300
Rational(98, 71).to_i # => 1
Rational(-31, 2).to_i # => -15
//}
precisi......か
Rational を返します。
//emlist[例][ruby]{
Rational('-123.456').truncate(+1) # => (-617/5)
Rational('-123.456').truncate(+1).to_f # => -123.4
Rational('-123.456').truncate(0) # => -123
Rational('-123.456').truncate(-1) # => -120
//}
@see Rational#ceil, Rational#floor... -
Rational
# fdiv(other) -> Float (27130.0) -
self を other で割った商を Float で返します。 other に虚数を指定することは出来ません。
...@param other 自身を割る数
//emlist[例][ruby]{
Rational(2, 3).fdiv(1) # => 0.6666666666666666
Rational(2, 3).fdiv(0.5) # => 1.3333333333333333
Rational(2).fdiv(3) # => 0.6666666666666666
Rational(1).fdiv(Complex(1, 0)) # => 1.0
Rational(1).fdiv(Complex(0, 1)) # => RangeError
//}... -
Rational
# negative? -> bool (27118.0) -
self が 0 未満の場合に true を返します。そうでない場合に false を返します。
...self が 0 未満の場合に true を返します。そうでない場合に false を返します。
//emlist[例][ruby]{
Rational(1, 2).negative? # => false
Rational(-1, 2).negative? # => true
//}
@see Rational#positive?...