るりまサーチ

最速Rubyリファレンスマニュアル検索!
561件ヒット [1-100件を表示] (0.099秒)

別のキーワード

  1. _builtin to_s
  2. openssl to_der
  3. openssl to_s
  4. _builtin to_a
  5. openssl to_pem

ライブラリ

クラス

キーワード

検索結果

<< 1 2 3 ... > >>

Integer#to_i -> self (39108.0)

self を返します。

...self を返します。

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

Integer#to_int -> self (27108.0)

self を返します。

...self を返します。

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

Integer#to_bn -> OpenSSL::BN (21029.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_f -> Float (21013.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
//}...

String#to_i(base = 10) -> Integer (18323.0)

文字列を 10 進数表現された整数であると解釈して、整数に変換します。

...れた整数であると解釈して、整数に変換します。

//emlist[例][ruby]{
p " 10".to_i # => 10
p "+10".to_i # => 10
p "-10".to_i # => -10

p "010".to_i # => 10
p "-010".to_i # => -10
//}

整数とみなせない文字があればそこまでを変換対象とします...
...
変換対象が空文字列であれば 0 を返します。

//emlist[例][ruby]{
p "0x11".to_i # => 0
p "".to_i # => 0
//}

基数を指定することでデフォルトの 10 進以外に 2 〜 36 進数表現へ変換できます。
それぞれ Ruby の整数リテラルで使用可...
...例][ruby]{
p "01".to_i(2) # => 1
p "0b1".to_i(2) # => 1

p "07".to_i(8) # => 7
p "0o7".to_i(8) # => 7

p "1f".to_i(16) # => 31
p "0x1f".to_i(16) # => 31

p "0b10".to_i(0) # => 2
p "0o10".to_i(0) # => 8
p "010".to_i(0) # => 8
p "0d10".to_i(0) # => 10
p "0x10".to_i(0) # => 16
//}

@...

絞り込み条件を変える

Rational#to_i -> Integer (18234.0)

小数点以下を切り捨てて値を整数に変換します。

...外のものを指定すると発生します。

//emlist[例][ruby]{
Rational(2, 3).to_i # => 0
Rational(3).to_i # => 3
Rational(300.6).to_i # => 300
Rational(98, 71).to_i # => 1
Rational(-31, 2).to_i # => -15
//}

precision を指定した場合は指定した桁数で切り捨てた整...

Complex#to_i -> Integer (18221.0)

自身を整数に変換します。

...自身を整数に変換します。

@raise RangeError 虚部が実数か、0 ではない場合に発生します。

//emlist[例][ruby]{
Complex(3).to_i # => 3
Complex(3.5).to_i # => 3
Complex(3, 2).to_i # => RangeError
//}...

OpenSSL::BN#to_i -> Integer (18220.0)

自身を Integer のインスタンスに変換します。

...自身を Integer のインスタンスに変換します。

@raise OpenSSL::BNError 変換に失敗した場合に発生します...

Float#to_i -> Integer (18210.0)

小数点以下を切り捨てて値を整数に変換します。

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

//emlist[例][ruby]{
2.8.truncate...
<< 1 2 3 ... > >>