Sha256: 4fa7300481bfd230767c30321910fe571863ad00f93dccc882f2446f6495864f

Contents?: true

Size: 278 Bytes

Versions: 1

Compression:

Stored size: 278 Bytes

Contents

# Redefine float with the apropriate options
class Float
  def sigfig(digits)
    f = format("%.#{digits - 1}e", self)
    f = f.to_f
    i = f.to_i
    (i == f ? i : f).to_s
  end

  def hisigfig(digits)
    format("%.#{digits - 1}e", self).split('e')[0].delete('.')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pdground-0.1.0 lib/pdground/extension.rb