From: Noah Easterly Date: 2006-10-20T05:00:36+09:00 Subject: Re: How to format an array [1.0, 2.0, 3, 4,5,6].map { |num| "%5.3f" % num } #=> ["1.000", "2.000", "3.000", "4.000", "5.000", "6.000"] On Oct 19, 3:49 pm, Li Chen wrote: > Hi all, > > I have an array [1.0, 2.0, 3, 4,5,6]. I want to format all the elements > within the array into to this format "%5.3f", that is 5 > spaces/characters for each number/element, followed by 3 floating > points. Any help will be appreciate. > > Li > > -- > Posted viahttp://www.ruby-forum.com/.