Ruby 2.2.0 リファレンスマニュアル > ライブラリ一覧 > opensslライブラリ > Integerクラス > to_bn

instance method Integer#to_bn

to_bn -> OpenSSL::BN[permalink][rdoc] [added by openssl]

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


require 'pp'
require 'openssl'

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

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


class Integer
  def to_bn
    OpenSSL::BN::new(self)
  end
end

[SEE_ALSO] OpenSSL::BN.new, OpenSSL::BN#to_i