From: Alex DeCaria Date: 2010-04-14T22:48:09+09:00 Subject: Re: Method to groom a string to floating point representation Jean-Julien Fleck wrote: > Hello Alex, > >> The user is still aware if they entered an incorrect string, since they >> are entering it into a GUI textbox, and the string cleaning is done >> after each character is entered. �Thus, if they try to enter a misplaced >> + sign or another bad character, they won't see it appear in the >> textbox, which should cause them to notice it. > > Well, then you can't use the Float() trick because 1.0e3 is a valid > but 1.0e is not. > Then there will be a lot of strings your user won't be able to type > even if they are valid in the end. > > Cheers, Yes, there has to be some additional logic to allow a trailing 'e' with the assumption that the user will next enter a valid character afterward. That's what makes it a little complicated (and fun) to figure out. The goal is, as the user is entering data, to not allow them to enter anything that is obviously not going to work as a floating point representation. --Alex -- Posted via http://www.ruby-forum.com/.