Method: Flt::FormatBase.canonicalized

Defined in:
lib/float-formats/classes.rb

.canonicalized(s, m, e, normalize = nil) ⇒ Object



658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
# File 'lib/float-formats/classes.rb', line 658

def self.canonicalized(s,m,e,normalize=nil)
  #puts "s=#{s} m=#{m} e=#{e}"
  #return [s,m,e]
  normalize = @normalized if normalize.nil?
  min_exp = radix_min_exp(:integral_significand)
  e = min_exp if e==:denormal
  if m.kind_of?(Integer) && m>0 && e.kind_of?(Integer)
    while e<min_exp
      e += 1
      m /= radix # TODO: round
    end
  end
  s,m,e = normalized(s,m,e) if normalize

  if m==0 && e.kind_of?(Integer)
    e=:zero
  end
  #puts " -> s=#{s} m=#{m} e=#{e}"
  [s,m,e]
end