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
real?

num.real? â true or false Instance Public methods Returns true

2015-04-23 01:07:01