Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

formatting a floating point number in ruby

def print_float(value)
  sprintf('%05.2f', value)
end
print_float(1)
# => "01.00" 
print_float(2.4)
# => "02.40" 
print_float(1.4455)
# => "01.45"
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #formatting #floating #point #number #ruby
ADD COMMENT
Topic
Name
2+7 =