Class: Numeric
Instance Method Summary
collapse
Methods included from Comparable
#<, #<=, #==, #>, #>=, #between?
Instance Method Details
382
383
384
385
|
# File 'lib/builtinME.rb', line 382
def abs
return -self if (self <=> 0) == -1
self
end
|
#div(value) ⇒ Object
387
388
389
|
# File 'lib/builtinME.rb', line 387
def div value
(self/value).floor
end
|
#divmod(value) ⇒ Object
391
392
393
|
# File 'lib/builtinME.rb', line 391
def divmod(value)
[(self/value).floor, self % value]
end
|
378
379
380
|
# File 'lib/builtinME.rb', line 378
def floor
self.to_f.floor
end
|
#integer? ⇒ Boolean
395
396
397
|
# File 'lib/builtinME.rb', line 395
def integer?
false
end
|
#modulo(value) ⇒ Object
401
402
403
|
# File 'lib/builtinME.rb', line 401
def modulo(value)
self % value
end
|
#nonzero? ⇒ Boolean
405
406
407
408
|
# File 'lib/builtinME.rb', line 405
def nonzero?
return nil if self == 0
self
end
|
#remainder(value) ⇒ Object
415
416
417
418
419
420
|
# File 'lib/builtinME.rb', line 415
def remainder(value)
self_sign = (self < 0)
value_sign = (value < 0)
return self % value if self_sign == value_sign
self % (-value)
end
|
#zero? ⇒ Boolean
410
411
412
413
|
# File 'lib/builtinME.rb', line 410
def zero?
return true if self == 0
false
end
|