Округлить дробное число до двух разрядов
gpo6Hoe_4ucJIo = 3.1415926535 puts ( gpo6Hoe_4ucJIo * 100 ).to_i.to_f / 100 puts sprintf( "%.2f", gpo6Hoe_4ucJIo ).to_f # предпочтительнее, так как действительно округляет
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
gpo6Hoe_4ucJIo = 3.1415926535 puts ( gpo6Hoe_4ucJIo * 100 ).to_i.to_f / 100 puts sprintf( "%.2f", gpo6Hoe_4ucJIo ).to_f # предпочтительнее, так как действительно округляет