Module: Precision
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
-
.included ⇒ Object
call_seq: included.
Instance Method Summary collapse
-
#prec(klass) ⇒ Object
Converts self into an instance of klass.
-
#prec_f ⇒ Float
Returns a
Floatconverted from num. -
#prec_i ⇒ Integer
Returns an
Integerconverted from num.
Class Method Details
.included ⇒ Object
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_f ⇒ Float
Returns a Float converted from num. It is equivalent to prec(Float).
66 67 68 |
# File 'prec.c', line 66 static VALUE prec_prec_f(x) VALUE x; |
#prec_i ⇒ Integer
Returns an Integer converted from num. It is equivalent to prec(Integer).
49 50 51 |
# File 'prec.c', line 49 static VALUE prec_prec_i(x) VALUE x; |