るりまサーチ

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

別のキーワード

  1. _builtin b
  2. string b
  3. b string
  4. b
  5. b _builtin

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Integer#to_bn -> OpenSSL::BN (27222.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#bit_length -> Integer (27207.0)

self を表すのに必要なビット数を返します。

...じ結果][ruby]{
(-2**12-1).bit_length # => 13
(-2**12).bit_length # => 12
(-2**12+1).bit_length # => 12
-0x101.bit_length # => 9
-0x100.bit_length # => 8
-0xff.bit_length # => 8
-2.bit_length # => 1
-1.bit_length # => 0
0.bit_length...
...# => 0
1.bit_length # => 1
0xff.bit_length # => 8
0x100.bit_length # => 9
(2**12-1).bit_length # => 12
(2**12).bit_length # => 13
(2**12+1).bit_length # => 13
//}

@see Integer#size...

Integer#abs -> Integer (27202.0)

self の絶対値を返します。

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

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

Integer#allbits?(mask) -> bool (27148.0)

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

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

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

@see Integer#anybits?
@see Integer#nobits?...

Integer#anybits?(mask) -> bool (27148.0)

self & mask のいずれかのビットが 1 なら true を返します。

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

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

@see Integer#allbits?
@see Integer#nobits?...

絞り込み条件を変える

Integer#nobits?(mask) -> bool (27148.0)

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

...am 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#anybits?...

bigdecimal (26108.0)

bigdecimal は浮動小数点数演算ライブラリです。 任意の精度で 10 進表現された浮動小数点数を扱えます。

...bigdecimal は浮動小数点数演算ライブラリです。
任意の精度で 10 進表現された浮動小数点数を扱えます。

//emlist[][ruby]{
require 'bigdecimal'
a = BigDecimal("0.123456789123456789")
b
= BigDecimal("123456.78912345678", 40)
print a + b # => 0.123456912580245903456...
...BigDecimal では正確な値を得る事ができます。

//emlist[例1: 0.0001 を 10000 回足す場合。][ruby]{
sum = 0
for i in (1..10000)
sum = sum + 0.0001
end
print sum # => 0.9999999999999062
//}

//emlist[例2: 0.0001 を 10000 回足す場合。(BigDecimal)][ruby]{
require 'bigde...
.../emlist[][ruby]{
require "bigdecimal"
require "bigdecimal/math"
a = BigMath.E(10)
p c = "0.123456789" * a # => "0.1234567890.123456789"
//}

これは、String#* の内部で、BigDecimal が暗黙的に Integer に変換された結果です。

===[a:internal_structure] 内部構造

B
igDecimal...

bigdecimal/util (26022.0)

String、Integer、Float、Rational, NilClass オブジェクトを BigDecimal オブジェクトに変換する機能を提供します。

...Integer、Float、Rational オブジェクトを
B
igDecimal オブジェクトに変換する機能を提供します。

* String#to_d
* Integer#to_d
* Float#to_d
* Rational#to_d


これらのメソッドを使うには 'bigdecimal/util' を require する必要があります。

なお、Rub...
...y 2.6.0 以降では、'bigdecimal/util' を require すると、
'bigdecimal' 本体も require されます。...
...String、Integer、Float、Rational, NilClass オブジェクトを
B
igDecimal オブジェクトに変換する機能を提供します。

* String#to_d
* Integer#to_d
* Float#to_d
* Rational#to_d
* NilClass#to_d


これらのメソッドを使うには 'bigdecimal/util' を require する...
...必要があります。

なお、Ruby 2.6.0 以降では、'bigdecimal/util' を require すると、
'bigdecimal' 本体も require されます。...

Integer#magnitude -> Integer (24102.0)

self の絶対値を返します。

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

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

Integer.try_convert(obj) -> Integer | nil (21253.0)

obj を Integer に変換しようと試みます。変換には Object#to_int メソッドが使われます。

...obj を Integer に変換しようと試みます。変換には Object#to_int
メソッドが使われます。

Integer
ならそのままobjを返します。
そうでなければ obj.to_int の結果を返すか、nil が返されます。

@param obj 変換する任意のオブジェクト...
...@return Integer または nil
@raise TypeError to_int が Integer を返さなかった場合に発生します。

//emlist[例][ruby]{
Integer
.try_convert(1) # => 1
Integer
.try_convert(1.25) # => 1
Integer
.try_convert([]) # => nil
//}...

絞り込み条件を変える

<< 1 2 3 ... > >>