Class: Float

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

Instance Method Summary collapse

Instance Method Details

#orig_to_sObject



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

alias_method :orig_to_s, :to_s

#signObject



156
157
158
# File 'lib/wordRS-lib.rb', line 156

def sign
  self < 0 ? -1 : 1
end

#to_e(arg = nil) ⇒ Object



147
148
149
150
151
152
153
154
# File 'lib/wordRS-lib.rb', line 147

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



138
139
140
141
142
143
144
145
# File 'lib/wordRS-lib.rb', line 138

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