Float Question



This is probably the stupidest question ive ever had to ask on any board so im sorry lol. :-p

Yes i've googled and found a solution but i cant believe that the solution presented is correct or that the great minds behind ruby did not include something like this.

I want to get a float 2.3333 to display as 2.33 or 2.333 etc.

Now, i read the manual, Numerical, Float, Math sections but could not find a way to do this. Yes you can use string manipulation but that just defeats the purpose of having something like this built into the Float stack.

ex. someFloat = Float.new(2) ==> 2.12
someFloat = Float.new(5) => 2.12345

Any thoughts?
.



Relevant Pages