hello
i need to format the retrieved value to two decimal points in ruby. MY
problem is: if the value is 15.0 i need to print it as 15.00 and if it
is 12.5 it should be 12.50. please help me in this.
In Ruby or Rails? If you are using rails, it comes with a nice helper
method
called number_to_currency.
Use it like so,
number_to_currency(15.0) or number_to_currency(variable_name)
Hope that helps,
Tyler P.
‘%.2f’ % 12.5 => “12.50”
Am 11.09.2006 um 11:05 schrieb Ks Ben:
hello
i need to format the retrieved value to two decimal points in ruby. MY
problem is: if the value is 15.0 i need to print it as 15.00 and if it
is 12.5 it should be 12.50. please help me in this.–
Posted via http://www.ruby-forum.com/.
–
Thomas F.
wollzelle
questentier on AIM
madrobby on irc.freenode.net
http://www.fluxiom.com :: online digital asset management
http://script.aculo.us :: Web 2.0 JavaScript
http://mir.aculo.us :: Where no web developer has gone before