Igor_Anic
(Igor Anic)
1
Sorry for the stupid question, but I colud not find the method to round float to the specific number of decimal places.
(1.234).method = 1.23
do I really had to write that by hand.
Thanks,
Igor
···
--
Igor Anić
email: ianic@4dva.hr
gsm: +385 91 53 90 849
42
www.4dva.hr
I. Lučića 5, Zagreb
tel: +385 1 61 68 552
Robert
(Robert)
2
Igor Anic wrote:
Sorry for the stupid question, but I colud not find the method to
round float to the specific number of decimal places.
(1.234).method = 1.23
do I really had to write that by hand.
Several options off the top of my head:
(1.234 * 100).round / 100.0
=> 1.23
("%5.2f" % 1.234).to_f
=> 1.23
Kind regards
robert
7rans
(7rans)
3
Facets has round_to and round_at.
T.
NBarnes
(NBarnes)
5
In other words, Ruby doesn't support that function without extension.
I rolled my own when I found I needed it.