Module

Precision

Inheritance

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).

Methods

Class

Visibility Signature
public included (p1)

Instance

Visibility Signature
public prec (p1)
public prec_f ()
public prec_i ()

Class Method Detail

included(p1)

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.

Instance Method Detail

num.prec(klass) => a_klass

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.

num.prec_f => Float

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

num.prec_i => Integer

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