Thank You. parseNum is far better than my solution.
On Mon, May 19, 2014 at 8:37 AM, Alexander Burger <a...@software-lab.de>wrote: > Hi Danilo, > > > I just noticed that by setting *Scl to NIL reader will simply ignore the > > decimal point. I haven't seen it in documentation. > > Ooos, no. Better don't do that. '*Scl' is expected to be a number. > Everything else will result in undefined behavior. > > > > I would like to get something like: > > > > : 100 > > -> 100 > > : 3.0 > > -> (decimal 30 -1) > > : 0.0040 > > -> (decimal 40 -4) > > The reader (REPL, or from a file) can't do that. The handling of the > decimal point is a kind of hard coded read macro. > > > Handing the decimal point on the application level is of course > possible. The +FixField class in the GUI (lib/form.l), for example, > accepts both input with and without a decimal point. > > You could achieve something like the above with a function, e.g.: > > (de parseNum (Str) > (let Lst (chop Str) > (if (member *Sep0 Lst) > (list > 'decimal > (format (delete *Sep0 Lst)) > (- 1 (length @)) ) > (format Lst) ) ) ) > > : (parseNum "3.0") > -> (decimal 30 -1) > > : (parseNum "0.0040") > -> (decimal 40 -4) > > ♪♫ Alex > -- > UNSUBSCRIBE: mailto:firstname.lastname@example.org?subject=Unsubscribe >