Sha256: 63137304776c9d667b7c1b92b96847c2eba624993096cde1a2984536de329de8

Contents?: true

Size: 520 Bytes

Versions: 4

Compression:

Stored size: 520 Bytes

Contents

# frozen_string_literal: true

module TTFunk
  class SciForm
    attr_reader :significand, :exponent
    alias eql? ==

    def initialize(significand, exponent = 0)
      @significand = significand
      @exponent = exponent
    end

    def to_f
      significand * 10**exponent
    end

    def ==(other)
      case other
      when Float
        other == to_f
      when self.class
        other.significand == significand &&
          other.exponent == exponent
      else
        false
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ttfunk-1.6.2.1 lib/ttfunk/sci_form.rb
ttfunk-1.6.2 lib/ttfunk/sci_form.rb
ttfunk-1.6.1 lib/ttfunk/sci_form.rb
ttfunk-1.6.0 lib/ttfunk/sci_form.rb