From: Joel VanderWerf Date: 2008-07-02T07:14:33+09:00 Subject: Re: Is posible String#to_s doesn't add the decimal value if not needed? I単aki Baz Castillo wrote: > Hi, I want to convert a string to a Float value: > > irb> "1.5".to_f > => 1.5 > > But if I do: > > irb> "1".to_f > => 1.0 > > I get '1.0' instead of just '1'. Is not possible to just get '1' in this case? Well, you could do this: a = ["1", "1.5"].map do |x| Float x # validate eval x end p a -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407