Class: Float

Inherits:
Object
  • Object
show all
Defined in:
lib/wordRS-lib.rb

Instance Method Summary collapse

Instance Method Details

#orig_to_sObject



174
# File 'lib/wordRS-lib.rb', line 174

alias_method :orig_to_s, :to_s

#signObject



194
195
196
# File 'lib/wordRS-lib.rb', line 194

def sign
  self < 0 ? -1 : 1
end

#to_e(arg = nil) ⇒ Object



185
186
187
188
189
190
191
192
# File 'lib/wordRS-lib.rb', line 185

def to_e(arg = nil)
  if arg.nil?
    #orig_to_s
    sprintf("%.#{2}e", self)
  else
    sprintf("%.#{arg}e", self)
  end
end

#to_s(arg = nil) ⇒ Object



176
177
178
179
180
181
182
183
# File 'lib/wordRS-lib.rb', line 176

def to_s(arg = nil)
  if arg.nil?
    #orig_to_s
    sprintf("%f", self)
  else
    sprintf("%.#{arg}f", self)
  end
end