Ruby 2.2.0 リファレンスマニュアル > ライブラリ一覧 > opensslライブラリ > OpenSSL::BNクラス > <=>

instance method OpenSSL::BN#<=>

self <=> other -> -1 | 0 | 1[permalink][rdoc]
cmp(other) -> -1 | 0 | 1

自身と other を比較し、自身が小さいときには -1、等しいときには 0、大きいときには 1 を返します。


require 'openssl'

OpenSSL::BN.new(5) <=> 5  # =>  0

OpenSSL::BN.new(5) <=> OpenSSL::BN.new(9)  # => -1
OpenSSL::BN.new(5) <=> OpenSSL::BN.new(5)  # =>  0
OpenSSL::BN.new(5) <=> OpenSSL::BN.new(-5)  # =>  1
[PARAM] other:
比較する整数
[EXCEPTION] TypeError:
比較できないときに発生します。

[SEE_ALSO] OpenSSL::BN#ucmp