Is this what you want?

>> val = 5
=> 5
>> puts "#{val}".rjust(3,'0')
005

Mayank

On Mon, Jul 18, 2011 at 6:22 PM, raju sathliya <raju.sathliya / gmail.com>wrote:

> Hello,
> I need to display number in 3 digit instead by defaul digit.
> e.g.
> val = 5
> puts #{val}
>
> will give me answer as 5
> but need to display output in 3 digit only like 005.
>
> Can anyone suggest me solution for this.
>
> Thanks,
> raju
>
> --
> Posted via http://www.ruby-forum.com/.
>
>