るりまサーチ

最速Rubyリファレンスマニュアル検索!
846件ヒット [701-800件を表示] (0.010秒)
トップページ > クラス:Integer[x]

ライブラリ

キーワード

検索結果

<< < ... 6 7 8 9 > >>

Integer#to_f -> Float (1.0)

self を浮動小数点数(Float)に変換します。

self を浮動小数点数(Float)に変換します。

self が Float の範囲に収まらない場合、Float::INFINITY を返します。

//emlist[][ruby]{
1.to_f # => 1.0
(Float::MAX.to_i * 2).to_f # => Infinity
(-Float::MAX.to_i * 2).to_f # => -Infinity
//}

Integer#to_i -> self (1.0)

self を返します。

self を返します。

//emlist[][ruby]{
10.to_i # => 10
//}

Integer#to_int -> self (1.0)

self を返します。

self を返します。

//emlist[][ruby]{
10.to_i # => 10
//}

Integer#to_r -> Rational (1.0)

自身を Rational に変換します。

自身を Rational に変換します。

//emlist[][ruby]{
1.to_r # => (1/1)
(1<<64).to_r # => (18446744073709551616/1)
//}

Integer#to_s(base=10) -> String (1.0)

整数を 10 進文字列表現に変換します。

整数を 10 進文字列表現に変換します。

引数を指定すれば、それを基数とした文字列表
現に変換します。

//emlist[][ruby]{
p 10.to_s(2) # => "1010"
p 10.to_s(8) # => "12"
p 10.to_s(16) # => "a"
p 35.to_s(36) # => "z"
//}

@return 数値の文字列表現
@param base 基数となる 2 - 36 の数値。
@raise ArgumentError base に 2 - 36 以外の数値を指定した場合に発生します。

絞り込み条件を変える

Integer#truncate(ndigits = 0) -> Integer (1.0)

0 から self までの整数で、自身にもっとも近い整数を返します。

0 から self までの整数で、自身にもっとも近い整数を返します。

@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
負の整数を指定した場合、小数点位置から左に少なくとも n 個の 0 が並びます。

//emlist[][ruby]{
1.truncate # => 1
1.truncate(2) # => 1
18.truncate(-1) # => 10
(-18).truncate(-1) # => -10
//}

@see Numeric#truncate

Integer#truncate(ndigits = 0) -> Integer | Float (1.0)

0 から self までの整数で、自身にもっとも近い整数を返します。

...合、Float を返します。
小数点以下を、最大 n 桁にします。
負の整数を指定した場合、Integer を返します。
小数点位置から左に少なくとも n 個の 0 が並びます。

//emlist[][ruby]{
1.truncate...

Integer#upto(max) -> Enumerator (1.0)

self から max まで 1 ずつ増やしながら繰り返します。 self > max であれば何もしません。

...self から max まで 1 ずつ増やしながら繰り返します。
self > max であれば何もしません。

@param max 数値
@return self を返します。

//emlist[][ruby]{
5.upto(10) {|i| print i, " " } # => 5 6 7 8 9 10
//}

@see Integer#downto, Numeric#step, Integer#times...

Integer#upto(max) {|n| ... } -> Integer (1.0)

self から max まで 1 ずつ増やしながら繰り返します。 self > max であれば何もしません。

...self から max まで 1 ずつ増やしながら繰り返します。
self > max であれば何もしません。

@param max 数値
@return self を返します。

//emlist[][ruby]{
5.upto(10) {|i| print i, " " } # => 5 6 7 8 9 10
//}

@see Integer#downto, Numeric#step, Integer#times...

Integer#|(other) -> Integer (1.0)

ビット二項演算子。論理和を計算します。

ビット二項演算子。論理和を計算します。

@param other 数値

//emlist[][ruby]{
1 | 1 # => 1
2 | 3 # => 3
//}

絞り込み条件を変える

Integer#~ -> Integer (1.0)

ビット演算子。否定を計算します。

ビット演算子。否定を計算します。

//emlist[][ruby]{
~1 # => -2
~3 # => -4
~-4 # => 3
//}
<< < ... 6 7 8 9 > >>