Module: Cognum
Overview
Instance Method Summary collapse
-
#signed?(bits) ⇒ Boolean
Whether or not this number can fit in a singed integer of the given size in the Cog.active_language.
-
#to_lit ⇒ String
Literal representation in the Cog.active_language.
Instance Method Details
#signed?(bits) ⇒ Boolean
Returns whether or not this number can fit in a singed integer of the given size in the Cog.active_language.
34 35 36 37 |
# File 'lib/cog/primitive.rb', line 34 def signed?(bits) limit = 2 ** (bits - 1) self >= -limit && self < limit end |
#to_lit ⇒ String
Returns literal representation in the Cog.active_language.
28 29 30 |
# File 'lib/cog/primitive.rb', line 28 def to_lit Cog.active_language.to_integer(self) || Cog.active_language.to_long(self) end |