Sha256: be3fc1eff6559b099700628d951e4e2cc2595f3b997951e94fe6e4dac250a408
Contents?: true
Size: 950 Bytes
Versions: 1
Compression:
Stored size: 950 Bytes
Contents
# frozen_string_literal: true module TTFunk # Scientific number representation class SciForm # Significand # @return [Float, Integer] attr_reader :significand # Exponent # @return [Float, Integer] attr_reader :exponent # @param significand [Float, Integer] # @param exponent [Float, Integer] def initialize(significand, exponent = 0) @significand = significand @exponent = exponent end # Convert to Float. # # @return [Float] def to_f significand * (10**exponent) end # Check equality to another number. # # @param other [Float, SciForm] # @return [Boolean] def ==(other) case other when Float other == to_f # rubocop: disable Lint/FloatComparison when self.class other.significand == significand && other.exponent == exponent else false end end alias eql? == end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ttfunk-1.8.0 | lib/ttfunk/sci_form.rb |