From: "i.v.r." Date: 2005-11-01T08:02:27+09:00 Subject: Re: Newbie: How to format a number to always show two decimals? James Edward Gray II wrote: > On Oct 31, 2005, at 4:47 PM, i.v.r. wrote: > >> Hi, >> >> This seems like a simple task, yet I've been unable to accomplish it. >> Somewhere I read you could do: >> >> num.round(2).to_s("F") >> >> But that is not working, as the round method doesn't accept any >> parameters. >> >> Could someone help me figure this out? > > >> sprintf("%.2f", 1.012345) > => "1.01" > >> # ... or ... > ?> "%.2f" % 1.012345 > => "1.01" > > Hope that helps. > > James Edward Gray II > > That was fast! Thanks a lot.