From: Jean-Julien Fleck Date: 2010-04-14T15:47:13+09:00 Subject: Re: Method to groom a string to floating point representation Hello, 2010/4/14 Josh Cheek : > On Tue, Apr 13, 2010 at 6:20 AM, Alex DeCaria > wrote: > >> Delete any decimals in an exponent: >> '245e7.6' => '2.45e76' >> > > Where did the dot in between 2 and 4 come from? Am I interpreting the String > or just cleaning it? As said Josh, here you are interpreting the string rather than cleaning it. 245e76 is a valid float, just not in the usual 2.45e78 form. BTW, I would rather not do any cleaning under the hood: let the user correct its input himself. For example, give the input to Float() and if an error is raised (which Float does as opposed to to_f which never raise an error), rescue it by giving feedback to the user (where you could use your method to propose an alternative if you want) but do not continue without letting the user know he has made a mistake and giving him the ability to change his mind. Cheers, -- JJ Fleck PCSI1 Lycée Kléber