るりまサーチ

最速Rubyリファレンスマニュアル検索!
326件ヒット [1-100件を表示] (0.127秒)
トップページ > クエリ:-[x] > クエリ:Float[x] > クエリ:r[x] > クエリ:**[x]

別のキーワード

  1. _builtin float
  2. float to_d
  3. json float
  4. float rationalize
  5. fiddle type_float

ライブラリ

クラス

モジュール

検索結果

<< 1 2 3 ... > >>

Float#**(other) -> Float (39425.0)

算術演算子。冪を計算します。

...算術演算子。冪を計算します。

@param other 二項演算の右側の引数(対象)

//emlist[例][ruby]{
# 冪
1.2 ** 3.0 # => 1.7279999999999998
3.0 + 4.5 - 1.3 / 2.4 * 3 % 1.2 ** 3.0 # => 5.875
0.0 ** 0 # => 1.0
//}...

Float#round(ndigits = 0) -> Integer | Float (27344.0)

自身ともっとも近い整数もしくは実数を返します。

...身ともっとも近い整数もしくは実数を返します。

中央値 0.5, -0.5 はそれぞれ 1,-1 に切り上げされます。
いわゆる四捨五入ですが、偶数丸めではありません。

@param ndigits 丸める位を指定します。
ndigitsが0ならば、小数...
...ruby]{
1.0.round # => 1
1.2.round # => 1
(-1.2).round # => -1
(-1.5).round # => -2

t = Math::PI # => 3.141592653589793
t.round(3) # => 3.142
t.round(0) # => 3
t.round(1) # => 3.1

t = t**10 # => 93648.04747608298
t.round(-0) # => 93648
t.round(-1) # => 93650
t.round(-...
...2) # => 93600
t.round(-3) # => 94000
t.round(-100) # => 0

2.5.round(half: :up) # => 3
2.5.round(half: :even) # => 2
2.5.round(half: :down) # => 2
3.5.round(half: :up) # => 4
3.5.round(half: :even) # => 4
3.5.round(half: :down) # => 3
//}

@see Float#ceil, Float#floor, Float#truncate...

Float#round(ndigits = 0, half: :up) -> Integer | Float (27344.0)

自身ともっとも近い整数もしくは実数を返します。

...身ともっとも近い整数もしくは実数を返します。

中央値 0.5, -0.5 はそれぞれ 1,-1 に切り上げされます。
いわゆる四捨五入ですが、偶数丸めではありません。

@param ndigits 丸める位を指定します。
ndigitsが0ならば、小数...
...ruby]{
1.0.round # => 1
1.2.round # => 1
(-1.2).round # => -1
(-1.5).round # => -2

t = Math::PI # => 3.141592653589793
t.round(3) # => 3.142
t.round(0) # => 3
t.round(1) # => 3.1

t = t**10 # => 93648.04747608298
t.round(-0) # => 93648
t.round(-1) # => 93650
t.round(-...
...2) # => 93600
t.round(-3) # => 94000
t.round(-100) # => 0

2.5.round(half: :up) # => 3
2.5.round(half: :even) # => 2
2.5.round(half: :down) # => 2
3.5.round(half: :up) # => 4
3.5.round(half: :even) # => 4
3.5.round(half: :down) # => 3
//}

@see Float#ceil, Float#floor, Float#truncate...

Float#round(ndigits = 0) -> Integer | Float (27343.0)

自身ともっとも近い整数もしくは実数を返します。

...身ともっとも近い整数もしくは実数を返します。

中央値 0.5, -0.5 はそれぞれ 1,-1 に切り上げされます。
いわゆる四捨五入ですが、偶数丸めではありません。

@param ndigits 丸める位を指定します。
ndigitsが0ならば、小数...
...ruby]{
1.0.round # => 1
1.2.round # => 1
(-1.2).round # => -1
(-1.5).round # => -2

t = Math::PI # => 3.141592653589793
t.round(3) # => 3.142
t.round(0) # => 3
t.round(1) # => 3.1

t = t**10 # => 93648.04747608298
t.round(-0) # => 93648
t.round(-1) # => 93650
t.round(-...
...2) # => 93600
t.round(-3) # => 94000
t.round(-100) # => 0
//}

@see Float#ceil, Float#floor, Float#truncate...

Rational#**(other) -> Rational | Float (21473.0)

冪(べき)乗を計算します。

...す。

@param other 自身を other 乗する数

other Float を指定した場合は、計算結果を Float で返しま
す。other が有理数であっても、計算結果が無理数だった場合は Float
を返します。

//emlist[例][ruby]{
r
= Rational(3, 4)
r
** Rational(2, 1)...
...# => (9/16)
r
** 2 # => (9/16)
r
** 2.0 # => 0.5625
r
** Rational(1, 2) # => 0.866025403784439
//}...

絞り込み条件を変える

Integer#**(other) -> Numeric (21408.0)

算術演算子。冪(べき乗)を計算します。

...param other 二項演算の右側の引数(対象)
@param modulo 指定すると、計算途中に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@ra...
...ise RangeError 2引数 pow で other に負の数を指定した場合に発生します。

//emlist[][ruby]{
2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1
3.pow(3, 8) # => 3
3.pow(3, -8) # => -5
3.pow(2, -2) # => -1
-
3.pow(3, 8) # => 5
-
3.pow(3, -8) # => -3
5.pow(2, -8) # => -7
//}

結果が...
...数になりそうなとき、警告を出したうえで Float::INFINITY を返します。

//emlist[計算を放棄して Float::INFINITY を返す例][ruby]{
p 100**9999999
# => warning: in a**b, b may be too big
# Infinity
//}

判定の閾値は変わりえます。

@see BigDecimal#power...

Bignum#**(other) -> Fixnum | Bignum | Float (18419.0)

算術演算子。冪(べき乗)を計算します。

...算術演算子。冪(べき乗)を計算します。

@param other 二項演算の右側の引数(対象)
@return 計算結果

2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1...

Fixnum#**(other) -> Fixnum | Bignum | Float (18419.0)

算術演算子。冪(べき乗)を計算します。

...算術演算子。冪(べき乗)を計算します。

@param other 二項演算の右側の引数(対象)
@return 計算結果

2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1...

ruby 1.6 feature (8316.0)

ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。

...ruby 1.6 feature
r
uby version 1.6 は安定版です。この版での変更はバグ修正がメイン
になります。

((<stable-snapshot|URL:ftp://ftp.netlab.co.jp/pub/lang/ruby/stable-snapshot.tar.gz>)) は、日々更新される安定版の最新ソースです。

== 1.6.8 (2002-12-24) ->...
...た。
((<ruby-bugs-ja:PR#107>))

END {
p 1
END { p 2 }
}

=> ruby 1.6.5 (2001-09-19) [i586-linux]
1

=> ruby 1.6.5 (2001-11-01) [i586-linux]
1
2

: String#succ

((<ruby-talk:22557>))

p "***".succ...
...> ruby 1.6.5 (2001-09-19) [i586-linux]
NotImplementedError
MatchData
Exception
Numeric
MatchData
Segmentation fault

=> ruby 1.6.5 (2001-10-15) [i586-linux]
MatchData
NotImplementedError
Float
D...

Numeric (8278.0)

数値を表す抽象クラスです。Integer や Float などの数値クラス は Numeric のサブクラスとして実装されています。

...を表す抽象クラスです。Integer Float などの数値クラス
は Numeric のサブクラスとして実装されています。

演算や比較を行うメソッド(+, -, *, /, <=>)は Numeric のサブクラスで定義されま
す。Numeric で定義されているメソッドは...
...るメソッド
(+, -, *, /, %) を利用して定義されるものがほとんどです。
つまり Numeric で定義されているメソッドは、Numeric のサブクラスとして新たに数値クラスを定義した時に、
演算メソッド(+, -, *, /, %, <=>, coerce)だけを定義...
...o - o o o - -
& | - - o o - - -
* | - - o o o o o
**
| -...
...----------------------------------------
% | o o o - -
& | - o - - -
* | - o o o o
**
...

絞り込み条件を変える

Kernel.#format(format, *arg) -> String (6450.0)

format 文字列を C 言語の sprintf と同じように解釈し、 引数をフォーマットした文字列を返します。

...format 文字列を C 言語の sprintf と同じように解釈し、
引数をフォーマットした文字列を返します。

@param format フォーマット文字列です。
@param arg フォーマットされる引数です。
@see Kernel.#printf,Time#strftime,Date.strptime

=== sprintf...
...), -, 0 の5種類があります。

: #

2進、8進、16進の指示子(b, B, o, x, X) ではそれぞれプレフィック
スとして "0b", "0B", "0", "0x", "0X" を付加します。
C 言語と同様引数が 0 の場合にはプレフィックスが付加されません。

//emlist[][ru...
...数が -4 より小さいか精度以上の場合に e と同じ出力を、それ以
外では f と同じ出力を行います。ただし、小数部の末尾の0は取り除かれ
ます。

a, A は指数表現の16進数("-h.hhh±pd") で数値を出力します。ただし、Float::INFINIT...

Kernel.#sprintf(format, *arg) -> String (6450.0)

format 文字列を C 言語の sprintf と同じように解釈し、 引数をフォーマットした文字列を返します。

...format 文字列を C 言語の sprintf と同じように解釈し、
引数をフォーマットした文字列を返します。

@param format フォーマット文字列です。
@param arg フォーマットされる引数です。
@see Kernel.#printf,Time#strftime,Date.strptime

=== sprintf...
...), -, 0 の5種類があります。

: #

2進、8進、16進の指示子(b, B, o, x, X) ではそれぞれプレフィック
スとして "0b", "0B", "0", "0x", "0X" を付加します。
C 言語と同様引数が 0 の場合にはプレフィックスが付加されません。

//emlist[][ru...
...数が -4 より小さいか精度以上の場合に e と同じ出力を、それ以
外では f と同じ出力を行います。ただし、小数部の末尾の0は取り除かれ
ます。

a, A は指数表現の16進数("-h.hhh±pd") で数値を出力します。ただし、Float::INFINIT...
<< 1 2 3 ... > >>