Bil Kleb wrote:
> Hi,
> 
> We have a request for 0.112345e+02 instead of,
> 
>   % ruby -e "puts '%.6e' % [ 1.123450e+2 ]"
>   1.123450e+02
> 
> Possible?
> 
> Thanks,

I'm not sure this works for all possible cases, but you could just 
manipulate the string a bit:

class Float
  def fmt(prec=6)
    str = "%.*e" % [prec-1, self]
    if str =~ /^([1-9])\.(\d+)e([+-])(\d+)$/
      str = "0.%s%se%s%02d" % [$1,$2,$3,$4.to_i]
    end
    str
  end
end

a = 1.123450e+2
puts a.fmt
-- 
Posted via http://www.ruby-forum.com/.