Module: Precision

Included in:
Fixnum, Float, Integer
Defined in:
prec.c

Overview

Precision is a mixin for concrete numeric classes with precision. Here, ‘precision’ means the fineness of approximation of a real number, so, this module should not be included into anything which is not a subset of Real (so it should not be included in classes such as Complex or Matrix).

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.includedObject

call_seq:

included

When the Precision module is mixed-in to a class, this included method is used to add our default induced_from implementation to the host class.



106
107
108
# File 'prec.c', line 106

static VALUE
prec_included(module, include)
VALUE module, include;

Instance Method Details

#prec(klass) ⇒ Object

Converts self into an instance of klass. By default, prec invokes

klass.induced_from(num)

and returns its value. So, if klass.induced_from doesn’t return an instance of klass, it will be necessary to reimplement prec.



34
35
36
# File 'prec.c', line 34

static VALUE
prec_prec(x, klass)
VALUE x, klass;

#prec_fFloat

Returns a Float converted from num. It is equivalent to prec(Float).

Returns:



66
67
68
# File 'prec.c', line 66

static VALUE
prec_prec_f(x)
VALUE x;

#prec_iInteger

Returns an Integer converted from num. It is equivalent to prec(Integer).

Returns:



49
50
51
# File 'prec.c', line 49

static VALUE
prec_prec_i(x)
VALUE x;