module Cognum
Helpers for {Bignum} and {Fixnum}
Public Instance Methods
signed?(bits)
click to toggle source
@param bits [Fixnum] the size of a signed integer @return [Boolean] whether or not this number can fit in a singed integer of the given size in the {Cog::Config::LanguageConfig#active_language Cog.active_language}
# File lib/cog/primitive.rb, line 34 def signed?(bits) limit = 2 ** (bits - 1) self >= -limit && self < limit end
to_lit()
click to toggle source
@return [String] literal representation in the {Cog::Config::LanguageConfig#active_language Cog.active_language}
# File lib/cog/primitive.rb, line 28 def to_lit Cog.active_language.to_integer(self) || Cog.active_language.to_long(self) end