Ruby 2.2.0 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > Fixnumクラス

class Fixnum

要約

Alias of Integer

インスタンスメソッド

定義 説明
self % other -> Fixnum | Bignum | Float
modulo(other) -> Fixnum | Bignum | Float

算術演算子。剰余を計算します。

self & other -> Fixnum | Bignum

ビット二項演算子。論理積を計算します。

self * other -> Fixnum | Bignum | Float

算術演算子。積を計算します。

self ** other -> Fixnum | Bignum | Float

算術演算子。冪(べき乗)を計算します。

self + other -> Fixnum | Bignum | Float

算術演算子。和を計算します。

self - other -> Fixnum | Bignum | Float

算術演算子。差を計算します。

- self -> Integer

単項演算子の - です。 self の符号を反転させたものを返します。

self / other -> Fixnum | Bignum | Float
div(other) -> Fixnum | Bignum | Float

算術演算子。商を計算します。

self / other

@todo

mathn
self < other -> bool

比較演算子。数値として小さいか判定します。

self << bits -> Fixnum | Bignum

シフト演算子。bits だけビットを左にシフトします。

self <= other -> bool

比較演算子。数値として等しいまたは小さいか判定します。

self <=> other -> Fixnum

self と other を比較して、self が大きい時に正、等しい時に 0、小さい時に負の整数を返します。

self == other -> bool

比較演算子。数値として等しいか判定します。

self > other -> bool

比較演算子。数値として大きいか判定します。

self >= other -> bool

比較演算子。数値として等しいまたは大きいか判定します。

self >> bits -> Fixnum | Bignum

シフト演算子。bits だけビットを右にシフトします。

self[nth] -> Fixnum

nth 番目のビット(最下位ビット(LSB)が 0 番目)が立っている時 1 を、そうでなければ 0 を返します。

self ^ other -> Fixnum | Bignum

ビット二項演算子。排他的論理和を計算します。

abs -> Fixnum | Bignum
magnitude -> Fixnum | Bignum

self の絶対値を返します。

bit_length -> Integer

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

divmod(other) -> [Integer, Numeric]

self を other で割った商 q と余り r を、 [q, r] という 2 要素の配列にして返します。 商 q は常に整数ですが、余り r は整数であるとは限りません。

even? -> bool

self が偶数の場合に true を返します。そうでない場合に false を返します。

fdiv(other) -> Float | Complex

self を other で割った商を Float で返します。ただし Complex が関わる場合は例外です。その場合も成分は Float になります。

to_s(base = 10) -> String
inspect(base = 10) -> String

self を引数で指定した基数の文字列表現に変換します。

odd? -> bool

self が奇数の場合に true を返します。そうでない場合に false を返します。

size -> Fixnum

整数の実装上のサイズをバイト数で返します。

succ -> Fixnum | Bignum

self の次の整数を返します。

to_f -> Float

値を浮動小数点数(Float)に変換します。

zero? -> bool

self が 0 の場合に true を返します。そうでない場合に false を返します。

self | other -> Fixnum | Bignum

ビット二項演算子。論理和を計算します。

~ self -> Fixnum | Bignum

ビット演算子。否定を計算します。

継承したメソッド

! != __id__ __send__ instance_eval instance_exec method_missing singleton_method_added singleton_method_removed singleton_method_undefined % & * ** + - -@ / < << <= <=> == > >= >> [] ^ abs bit_length ceil chr denominator digits div divmod downto even? fdiv floor gcd gcdlcm inspect integer? lcm next numerator odd? ord pred prime? prime_division rationalize remainder round size times to_bn to_d to_f to_i to_r truncate upto | ~ .each_prime .from_prime_division +@ abs2 angle coerce conj eql? i imag nonzero? polar quo real real? rect step to_c zero? !~ =~ _dump class clone define_singleton_method display enum_for equal? extend freeze frozen? hash initialize initialize_copy instance_of? instance_variable_defined? instance_variable_get instance_variable_set instance_variables is_a? itself marshal_dump marshal_load method methods nil? object_id pretty_inspect pretty_print pretty_print_cycle pretty_print_inspect pretty_print_instance_variables private_methods protected_methods psych_to_yaml public_method public_methods public_send remove_instance_variable respond_to? respond_to_missing? send singleton_class singleton_method singleton_methods taint tainted? tap to_a to_ary to_hash to_io to_proc to_regexp to_str trust untaint untrust untrusted? .new .yaml_tag ::ARGF ::ARGV ::DATA ::ENV ::FALSE ::NIL ::RUBY_COPYRIGHT ::RUBY_DESCRIPTION ::RUBY_ENGINE ::RUBY_PATCHLEVEL ::RUBY_PLATFORM ::RUBY_RELEASE_DATE ::RUBY_REVISION ::RUBY_VERSION ::SCRIPT_LINES__ ::STDERR ::STDIN ::STDOUT ::TOPLEVEL_BINDING ::TRUE