Class: Float
- Inherits:
-
Numeric
- Object
- Numeric
- Float
- Includes:
- Integral
- Defined in:
- mrblib/numeric.rb,
src/numeric.c
Overview
15.2.9
Instance Method Summary (collapse)
- - (Object) <<(other)
-
- (Object) >>(other)
mruby special - since mruby integers may be upgraded to floats, floats should be compatible to integers.
Methods included from Integral
#downto, #next, #step, #times, #upto
Methods inherited from Numeric
Methods included from Comparable
#<, #<=, #==, #>, #>=, #between?
Instance Method Details
- (Object) <<(other)
184 185 186 187 188 189 190 191 192 193 |
# File 'mrblib/numeric.rb', line 184 def << other n = self.to_i other = other.to_i if other < 0 n >> -other else other.times { n *= 2 } n end end |
- (Object) >>(other)
mruby special - since mruby integers may be upgraded to floats, floats should be compatible to integers.
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'mrblib/numeric.rb', line 166 def >> other n = self.to_i other = other.to_i if other < 0 n << -other else other.times { n /= 2 } if n.abs < 1 if n >= 0 0 else -1 end else n.to_i end end end |