Class: Numeric

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
mrblib/numeric.rb,
src/numeric.c

Overview

15.2.7

Direct Known Subclasses

Float, Integer

Instance Method Summary (collapse)

Methods included from Comparable

#<, #<=, #==, #>, #>=, #between?

Instance Method Details

- (Object) +@

Returns the receiver simply.

ISO 15.2.7.4.1



11
12
13
# File 'mrblib/numeric.rb', line 11

def +@
  self
end

- (Object) -@

Returns the receiver's value, negated.

ISO 15.2.7.4.2



19
20
21
# File 'mrblib/numeric.rb', line 19

def -@
  0 - self
end

- (Object) abs

Returns the absolute value of the receiver.

ISO 15.2.7.4.3



27
28
29
30
31
32
33
# File 'mrblib/numeric.rb', line 27

def abs
  if self < 0
    -self
  else
    self
  end
end

- (Object) quo(numeric)

Returns most exact division.



89
90
91
92
93
94
95
96
# File 'src/numeric.c', line 89

static mrb_value
num_div(mrb_state *mrb, mrb_value x)
{
  mrb_float y;

  mrb_get_args(mrb, "f", &y);
  return mrb_float_value(mrb, mrb_to_flo(mrb, x) / y);
}