1 # depends on: integer.rb class.rb
5 # NOTE do not define to_sym or id2name. It's been deprecated for 5 years and
6 # we've decided to remove it.
11 MAX = Platform::Fixnum.MAX
13 def self.induced_from(obj)
20 raise RangeError, "Object is out of range for a Fixnum"
25 value = Type.coerce_to(obj, Integer, :to_int)
26 return self.induced_from(value)
31 # see README-DEVELOPERS regarding safe math compiler plugin
34 alias_method :/, :divide
35 alias_method :modulo, :%
38 c = Type.coerce_to(c, Integer, :to_int)
39 raise RangeError, "Object is out of range for a Fixnum" unless c.is_a?(Fixnum)
40 return self >> -c if c < 0
42 bits = self.size * 8 - 1
43 if (c > bits || self >> bits - c > 0 || c.kind_of?(Bignum))
44 return __bignum_new__(self) << c
46 __fixnum_left_shift__(c)
50 c = Type.coerce_to(c, Integer, :to_int)
51 return self << -c if c < 0
58 return __bignum_new__(self) >> c
61 __fixnum_right_shift__(c)
65 raise ArgumentError, 'base must be between 2 and 36' unless base.between?(2, 36)
70 # taint and untaint are noops on Fixnum