るりまサーチ

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

別のキーワード

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

ライブラリ

キーワード

検索結果

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

Integer#digits -> [Integer] (154.0)

base を基数として self を位取り記数法で表記した数値を配列で返します。 base を指定しない場合の基数は 10 です。

...base を基数として self を位取り記数法で表記した数値を配列で返します。
base を指定しない場合の基数は 10 です。

//emlist[][ruby]{
16.digits # => [6, 1]
16.digits(16) # => [0, 1]
//}

self
は非負整数でなければいけません。非負整数で...
...ない場合は、Math::DomainErrorが発生します。

//emlist[][ruby]{
-
10.digits # Math::DomainError: out of domain が発生
//}

@return 位取り記数法で表した時の数値の配列
@param base 基数となる数値。
@raise ArgumentError base に正の整数以外を指定し...

Integer#digits(base) -> [Integer] (154.0)

base を基数として self を位取り記数法で表記した数値を配列で返します。 base を指定しない場合の基数は 10 です。

...base を基数として self を位取り記数法で表記した数値を配列で返します。
base を指定しない場合の基数は 10 です。

//emlist[][ruby]{
16.digits # => [6, 1]
16.digits(16) # => [0, 1]
//}

self
は非負整数でなければいけません。非負整数で...
...ない場合は、Math::DomainErrorが発生します。

//emlist[][ruby]{
-
10.digits # Math::DomainError: out of domain が発生
//}

@return 位取り記数法で表した時の数値の配列
@param base 基数となる数値。
@raise ArgumentError base に正の整数以外を指定し...

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

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

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

@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
負の整数を指定した場合、小数点位置から左に少なくとも n 個の 0 が並びます。
@param half ちょうど半分の...
...[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, half: :down) # => 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 (154.0)

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

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

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

* :up or nil...
...

//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(-1, half: :even) # => 20
35.round(-1, half: :up) # => 40
35.round(-1, half: :down) #...

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

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

...
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#ste...
...p, Integer#times...

絞り込み条件を変える

Integer#pred -> Integer (152.0)

self から -1 した値を返します。

...
self
から -1 した値を返します。

//emlist[][ruby]{
1.pred #=> 0
(-1).pred #=> -2
//}

@see Integer#next...

Integer#upto(max) -> Enumerator (152.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 (152.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#gcdlcm(n) -> [Integer] (146.0)

自身と整数 n の最大公約数と最小公倍数の配列 [self.gcd(n), self.lcm(n)] を返します。

...倍数の配列 [self.gcd(n), self.lcm(n)]
を返します。

@raise ArgumentError n に整数以外のものを指定すると発生します。

//emlist[][ruby]{
2.gcdlcm(2) # => [2, 2]
3.gcdlcm(-7) # => [1, 21]
((1<<31)-1).gcdlcm((1<<61)-1) # => [1, 4951760...
...154835678088235319297]
//}

@see Integer#gcd, Integer#lcm...

Integer#abs -> Integer (142.0)

self の絶対値を返します。

...
self
の絶対値を返します。

//emlist[][ruby]{
-
12345.abs # => 12345
12345.abs # => 12345
-
1234567890987654321.abs # => 1234567890987654321
//}...

絞り込み条件を変える

Integer#magnitude -> Integer (142.0)

self の絶対値を返します。

...
self
の絶対値を返します。

//emlist[][ruby]{
-
12345.abs # => 12345
12345.abs # => 12345
-
1234567890987654321.abs # => 1234567890987654321
//}...
<< < 1 2 3 4 5 ... > >>