From: Harry Kakueki Date: 2009-08-06T08:11:47+09:00 Subject: Re: zero placeholder exponential sprintf? > > We have a request for 0.112345e+02 instead of, > > % ruby -e "puts '%.6e' % [ 1.123450e+2 ]" > 1.123450e+02 > > Possible? > Sorry for posting yet again. Just a little adjustment. I'll stop now. x = 1.12345e2 s,y,h = 7, Math.log10(x).floor+1,{-1=>"e-",0=>"e+",1=>"e+"} p (x*10**(y*-1)).to_s[0..s+1].ljust(s+2,"0")+h[(y<=>0)]+y.abs.to_s.rjust(2,"0") Harry -- A Look into Japanese Ruby List in English http://www.kakueki.com/ruby/list.html