class TTFunk::SciForm
Scientific number representation
Attributes
exponent[R]
Exponent @return [Float, Integer]
significand[R]
Significand @return [Float, Integer]
Public Class Methods
new(significand, exponent = 0)
click to toggle source
@param significand [Float, Integer] @param exponent [Float, Integer]
# File lib/ttfunk/sci_form.rb, line 16 def initialize(significand, exponent = 0) @significand = significand @exponent = exponent end
Public Instance Methods
==(other)
click to toggle source
Check equality to another number.
@param other [Float, SciForm] @return [Boolean]
# File lib/ttfunk/sci_form.rb, line 32 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
Also aliased as: eql?
to_f()
click to toggle source
Convert to Float.
@return [Float]
# File lib/ttfunk/sci_form.rb, line 24 def to_f significand * (10**exponent) end