Module: Math

### Home Classes Methods

### In Files

- lib/backports/1.9.1/math/log.rb

### Methods

- ::log2
- ::log_with_optional_base

### Class/Module Index

Quicksearch

- Prime
- Prime::EratosthenesGenerator
- Prime::EratosthenesSieve
- Prime::Generator23
- Prime::OldCompatibility
- Prime::PseudoPrimeGenerator
- Prime::TrialDivision
- Prime::TrialDivisionGenerator
- Backports
- Backports::MOST_EXTREME_OBJECT_EVER
- Backports::Random
- Backports::Random::Implementation
- Backports::Random::MT19937
- Backports::StdLib
- Backports::StdLib::LoadedFeatures
- Enumerator
- Enumerator::GeneratorBP
- Enumerator::Lazy
- Enumerator::Yielder
- Matrix
- Matrix::EigenvalueDecomposition
- Matrix::LUPDecomposition
- Enumerable
- Enumerable::Enumerator
- File
- File::Constants
- ARGF
- Array
- BasicObject
- Bignum
- Binding
- Complex
- Dir
- ENV
- Fixnum
- Float
- GC
- Hash
- IO
- Integer
- Kernel
- Math
- Method
- Module
- NilClass
- Numeric
- Object
- ObjectSpace
- OpenStruct
- Proc
- Process
- Random
- Range
- Regexp
- Set
- StopIteration
- String
- Struct
- Symbol
- UnboundMethod

No matching classes.

# Math

### Public Class Methods

log2(numeric) click to toggle source

    # File lib/backports/1.9.1/math/log2.rb, line 2
    def Math.log2(numeric)
      log(numeric) / log(2)
    end

log_with_optional_base(numeric, base = Backports::Undefined) click to toggle source

Standard in Ruby 1.9. See official documentation

    # File lib/backports/1.9.1/math/log.rb, line 7
    def log_with_optional_base(numeric, base = Backports::Undefined)
      if base.equal?(Backports::Undefined)
        # Math.log(n) in 1.9.1 no longer accepts string arguments as it
        # did on 1.8.x, but we won't risk redefining existing behavior
        # when called with just one argument.
        log_without_optional_base(numeric)
      else
        # Math.log(n, b) in 1.9.1 does not accept string arguments:
        raise TypeError, "can't convert String into Float" if numeric.is_a?(String) || base.is_a?(String)
        log_without_optional_base(numeric) / log_without_optional_base(base)
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.