Prev: NETWORK MARKETING
Next: cl-who html output
From: Tamas K Papp on 10 May 2010 10:03 On Mon, 10 May 2010 03:25:09 -0700, sg2008 wrote: > I am using/compiling/building following version of common lisp > > Allegro CL Enterprise Edition > 8.1 [64-bit Linux (x86-64)] (May 10, 2010 2:41) Copyright (C) 1985-2007, > Franz Inc., Oakland, CA, USA. All Rights Reserved. ==== > > I debugged my problem further, it turns out that read-from-string is > outputting 0. > > input to read-from string is "1.000000000e-07\n" output from Unless ACL has nonstandard extensions (which I don't know about), \n is not a newline in CL. This is read as a symbol: CL-USER> (read-from-string "1.000000000e-07\n") |1.000000000E-07N| 16 > read-from-string routine is is 0.000000 > > here is code snap-shot: > > ==== > (setf *read-default-float-format* 'double-float) (setq > *read-default-float-format* 'double-float) (oail:warn > "read-from-string is %L" (read-from-string input)) > ==== I don't understand what you are doing. What is %L supposed to do? Again, unless ACL is doing something extra here, is seriously doubt that the dumps you are giving us come from the code you provided. Try _evaluating_ the following (instead of printing the number): (let ((*read-default-float-format* 'double-float)) (read-from-string "1.000000000e-07")) Does it give you 1e-07? > I wonder if there is something wrong with read-from-string? I doubt it - reading is fundamental to CL, and bugs in the reader are noticed quickly, especially for such fundamental operations. Tamas
From: Captain Obvious on 10 May 2010 12:23 Here is how it works for me: ---- International Allegro CL Free Express Edition 8.1 [Windows] (Jul 28, 2007 7:55) Copyright (C) 1985-2007, Franz Inc., Oakland, CA, USA. All Rights Reserved. ---- CG-USER(1): 1.000000000e-07 1.0e-7 CG-USER(2): (read-from-string "1.000000000e-07") 1.0e-7 15 CG-USER(3): (read-from-string "1.000000000e-07\n") 1.000000000E-07N 16 CG-USER(4): CG-USER(4): (read-from-string "1.000000000e-07 ") 1.0e-7 16 ---- So it seems to work fine. Are you trying this in a clean system or you load some application? You see, it is possible that application have tweaked some settings so you need to untweak them back. If it is possible, try starting clean Allegro CL, without init files, without anything and try there.
From: Thomas A. Russ on 10 May 2010 13:24 sg2008 <samirg70(a)gmail.com> writes: > Thank u, > > I am using/compiling/building following version of common lisp > > Allegro CL Enterprise Edition > 8.1 [64-bit Linux (x86-64)] (May 10, 2010 2:41) > Copyright (C) 1985-2007, Franz Inc., Oakland, CA, USA. All Rights > Reserved. > ==== > > I debugged my problem further, it turns out that read-from-string is > outputting 0. > > input to read-from string is "1.000000000e-07\n" > output from read-from-string routine is is 0.000000 Um, could this just be an output issue? What is the format of the routine that is printing "output from read-from-string routine is is 0.000000" If this is telling the output formatter to print only 6 decimal digits, then of course 1e-7 will correctly print as 0.000000 Try the following, without going through some other printing routine other than the standard lisp printer. Otherwise you can get misled by other software that you have inserted: (format t "~,6F" 1e-6) (format t "~,6F" 1e-7) (format t "~,7F" 1e-7) (format t "~,10F" 1e-7) (format t "~F" 1e-7) > here is code snap-shot: > > ==== > (setf *read-default-float-format* 'double-float) > (setq *read-default-float-format* 'double-float) You don't need both of these. Either one will do. > (oail:warn "read-from-string is %L" (read-from-string input)) What is OAIL:WARN? It's not a standard function, and I have no idea what sort of formatting %L is supposed to do. > ==== > > I wonder if there is something wrong with read-from-string? So I wonder if something is wrong with your formatting. > > when I input 1e-6, output is dumped out as follows: > > === > input to read-from-string is "1.000000000e-06\n" > output from read-from-string is 0.000001 > ==== It must be something you are doing with your own software. I'm certain the underlying lisp system is doing the right thing. -- Thomas A. Russ, USC/Information Sciences Institute
From: Captain Obvious on 10 May 2010 15:06
TAR> Um, could this just be an output issue? What is the format of the TAR> routine that is printing TAR> "output from read-from-string routine is is 0.000000" We have a winner here! |