Type:
Class

mathn

mathn is a library for changing the way Ruby does math. If you need more precise rounding with multiple division or exponentiation operations, then mathn is the right tool.

Without mathn:

3 / 2 => 1 # Integer

With mathn:

3 / 2 => 3/2 # Rational

mathn features late rounding and lacks truncation of intermediate results:

Without mathn:

20 / 9 * 3 * 14 / 7 * 3 / 2 # => 18

With mathn:

20 / 9 * 3 * 14 / 7 * 3 / 2 # => 20

When you require 'mathn', the libraries for Prime, CMath, Matrix and Vector are also loaded.

Copyright

Author: Keiju ISHITSUKA (SHL Japan Inc.)

Document-class: FloatDomainError

Raised when attempting to convert special float values (in particular infinite or NaN) to numerical classes which don't support them.

Float::INFINITY.to_r

raises the exception:

FloatDomainError: Infinity
imaginary

num.imaginary â 0 Instance Public methods Returns zero.

2015-04-23 00:27:21
conj

num.conj â selfnum.conjugate â self Instance Public methods Returns

2015-04-22 23:54:27
to_c

num.to_c â complex Instance Public methods Returns the value as a complex

2015-04-23 01:49:37
arg

num.arg â 0 or float Instance Public methods Returns 0 if the value is positive

2015-04-22 23:42:32
conjugate

num.conjugate â self Instance Public methods Returns self.

2015-04-22 23:55:44
to_int

num.to_int â integer Instance Public methods Invokes the child class's to_i

2015-04-23 01:54:44
rectangular

num.rect â array Instance Public methods Returns an array; [num, 0].

2015-04-23 01:19:50
floor

num.floor â integer Instance Public methods Returns the largest integer less

2015-04-23 00:18:02
nonzero?

num.nonzero? â self or nil Instance Public methods Returns self

2015-04-23 00:44:33
abs

num.abs â numeric Instance Public methods Returns the absolute value

2015-04-22 23:25:16