るりまサーチ

最速Rubyリファレンスマニュアル検索!
722件ヒット [201-300件を表示] (0.070秒)
トップページ > クエリ:ruby[x] > クエリ:Ruby[x] > クエリ:@[x] > 種類:インスタンスメソッド[x] > クラス:Integer[x]

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

キーワード

検索結果

<< < 1 2 3 4 5 ... > >>

Integer#downto(min) -> Enumerator (32.0)

self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。 self < min であれば何もしません。

...で 1 ずつ減らしながらブロックを繰り返し実行します。
self < min であれば何もしません。

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

//emlist[][ruby]{
5.downto(1) {|i| print i, " " } # => 5 4 3 2 1
//}

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

Integer#downto(min) {|n| ... } -> self (32.0)

self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。 self < min であれば何もしません。

...で 1 ずつ減らしながらブロックを繰り返し実行します。
self < min であれば何もしません。

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

//emlist[][ruby]{
5.downto(1) {|i| print i, " " } # => 5 4 3 2 1
//}

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

Integer#inspect(base=10) -> String (32.0)

整数を 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#nobits?(mask) -> bool (32.0)

self & mask のすべてのビットが 0 なら true を返します。

...

@
param mask ビットマスクを整数で指定します。

//emlist[][ruby]{
42.nobits?(42) # => false
0b1010_1010.nobits?(0b1000_0010) # => false
0b1010_1010.nobits?(0b1000_0001) # => false
0b0100_0101.nobits?(0b1010_1010) # => true
//}

@
see Integer#allbits?
@
see Integer#any...

Integer#round(ndigits = 0, half: :up) -> Integer (32.0)

self ともっとも近い整数を返します。

...もっとも近い整数を返します。

@
param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
負の整数を指定した場合、小数点位置から左に少なくとも n 個の 0 が並びます。
@
param half ちょうど半分の値の丸...
...方に丸められます。
* :even: もっとも近い偶数に丸められます。
* :down: 0に近い方に丸められます。

//emlist[][ruby]{
1.round # => 1
1.round(2) # => 1
15.round(-1) # => 20
(-15).round(-1) # => -20

25.round(-1, half: :up) # => 30
25.round(-1,...
...) # => 20
25.round(-1, half: :even) # => 20
35.round(-1, half: :up) # => 40
35.round(-1, half: :down) # => 30
35.round(-1, half: :even) # => 40
(-25).round(-1, half: :up) # => -30
(-25).round(-1, half: :down) # => -20
(-25).round(-1, half: :even) # => -20
//}

@
see Numeric#round...

絞り込み条件を変える

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

self ともっとも近い整数を返します。

...

@
param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
正の整数を指定した場合、Float を返します。
小数点以下を、最大 n 桁にします。
負の整数を指定した場合、Integer を返...
...します。
小数点位置から左に少なくとも n 個の 0 が並びます。
@
param half ちょうど半分の値の丸め方を指定します。
サポートされている値は以下の通りです。

* :up or nil: 0から遠い方に丸められます。
* :eve...
...n: もっとも近い偶数に丸められます。
* :down: 0に近い方に丸められます。

//emlist[][ruby]{
1.round # => 1
1.round(2) # => 1.0
15.round(-1) # => 20
(-15).round(-1) # => -20

25.round(-1, half: :up) # => 30
25.round(-1, half: :down) # => 20
25.round...

Integer#to_bn -> OpenSSL::BN (32.0)

Integer を同じ数を表す OpenSSL::BN のオブジェクトに 変換します。

...
Integer
を同じ数を表す OpenSSL::BN のオブジェクトに
変換します。

//emlist[][ruby]{
require 'pp'
require 'openssl'

pp 5.to_bn #=> #<OpenSSL::BN 5>
pp (-5).to_bn #=> #<OpenSSL::BN -5>
//}

なお、実装は、以下のようになっています。

//emlist[][ruby]{
clas...
...s Integer
def to_bn
OpenSSL::BN::new(self)
end
end
//}

@
see OpenSSL::BN.new, OpenSSL::BN#to_i...
...
Integer
を同じ数を表す OpenSSL::BN のオブジェクトに
変換します。

//emlist[][ruby]{
require 'openssl'

pp 5.to_bn #=> #<OpenSSL::BN 5>
pp (-5).to_bn #=> #<OpenSSL::BN -5>
//}

なお、実装は、以下のようになっています。

//emlist[][ruby]{
class Integer
d...
...ef to_bn
OpenSSL::BN::new(self)
end
end
//}

@
see OpenSSL::BN.new, OpenSSL::BN#to_i...

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

整数を 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#upto(max) -> Enumerator (32.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 (32.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) -> Numeric (26.0)

算術演算子。剰余を計算します。

...算術演算子。剰余を計算します。

//emlist[][ruby]{
13 % 4 # => 1
13 % -4 # => -3
-13 % 4 # => 3
-13 % -4 # => -1
//}

@
param other 二項演算の右側の引数(対象)
@
return 計算結果...
<< < 1 2 3 4 5 ... > >>