On Dec 1, 2007, at 12:04 PM, Armando Padilla wrote:
> If i use sprintf im assuming that the argument is changed to a  
> string type.  If then i chose to calculate additional values with  
> this string type i would have to reconvert it to a float.  On the  
> surface its fine, i wouldnt mind doing it but I need speed and any  
> less lines that ruby will translate too in terms of machine  
> language is beneficial to me.


This statement just confused me more.  sprintf doesn't change the
underlying objects--it just creates a string representation of them.
You are free to use the original objects as you like.

It sounds like you aren't primarily interested in the format of the
string representation of a float but instead would like to compute
a rounded or truncated value.  That is a completely different
problem.  Pat's solution included a roundtrip conversion to a
decimal/string representation, which is going to be inaccurate and
expensive.  Of course if you want to 'round' a float then you'll
want to round to a power of two to avoid conversion problems.

Maybe BigDecimal objects would work better for you?  You could
at least avoid the base2/base10 conversion problems.

Gary Wright