From: Jorgen Sigvardsson
Subject: How to parse strings into floats?
Date: 
Message-ID: <3389DEE8.F01@wermland.se>
Hi.

I'm a student of Computer Science that just have begun learning LISP.
As I'm learning the language on my own (My University does not offer
LISP-courses), I have stumbled into a little problem. How does one parse
strings into floats? There is a parse-integer function but no equivalent
for floats. Is there an easy way to do this or do I have to do it the
hard way?

Thanks!

// Jorgen

From: William Paul Vrotney
Subject: Re: How to parse strings into floats?
Date: 
Message-ID: <vrotneyEAt7Cw.9w1@netcom.com>
In article <············@wermland.se> Jorgen Sigvardsson
<······@wermland.se> writes:

> 
> I'm a student of Computer Science that just have begun learning LISP.
> As I'm learning the language on my own (My University does not offer
> LISP-courses), 

Sometimes Lisp is taught as an adjunct to an introductory AI course.

> I have stumbled into a little problem. How does one parse
> strings into floats? There is a parse-integer function but no equivalent
> for floats. Is there an easy way to do this or do I have to do it the
> hard way?
> 
> Thanks!
> 
> // Jorgen


What Lisp are you using?  If you have Common Lisp just use READ-FROM-STRING

        (setq /a (read-from-string "2.7"))
        2.7

        (describe /a)
        2.7 is a SINGLE-FLOAT

-- 

William P. Vrotney - ·······@netcom.com
From: Marco Antoniotti
Subject: Re: How to parse strings into floats?
Date: 
Message-ID: <scflo4zpm28.fsf@infiniti.PATH.Berkeley.EDU>
In article <·················@netcom.com> ·······@netcom.com (William Paul Vrotney) writes:

   From: ·······@netcom.com (William Paul Vrotney)
   Newsgroups: comp.lang.lisp
   Date: Mon, 26 May 1997 22:19:44 GMT
   Organization: Netcom On-Line Services
   References: <············@wermland.se>
   Lines: 31
   Sender: ·······@netcom15.netcom.com

   In article <············@wermland.se> Jorgen Sigvardsson
   <······@wermland.se> writes:

   > 
   > I'm a student of Computer Science that just have begun learning LISP.
   > As I'm learning the language on my own (My University does not offer
   > LISP-courses), 

   Sometimes Lisp is taught as an adjunct to an introductory AI course.

   > I have stumbled into a little problem. How does one parse
   > strings into floats? There is a parse-integer function but no equivalent
   > for floats. Is there an easy way to do this or do I have to do it the
   > hard way?
   > 
   > Thanks!
   > 
   > // Jorgen


   What Lisp are you using?  If you have Common Lisp just use READ-FROM-STRING

	   (setq /a (read-from-string "2.7"))
	   2.7

	   (describe /a)
	   2.7 is a SINGLE-FLOAT

READ-FROM-STRING does not quite cut it in many occasions.  However,
St. Mark Kantrowitz has a PARSE-FLOAT package sitting in the
AI.Repository

http://www.cs.cmu.edu/afs/cs.cmu.edu/project/ai-repository/ai/html/air.html

Cheers
-- 
Marco Antoniotti
==============================================================================
California Path Program - UCB
Richmond Field Station
tel. +1 - 510 - 231 9472
From: Jens Kilian
Subject: Re: How to parse strings into floats?
Date: 
Message-ID: <5n0tl6$pe1@isoit109.bbn.hp.com>
A paper by William D. Clinger in PLDI90 described an algorithm for reading
floating-point numbers accurately:

	Proceedings of the ACM SIGPLAN'90 Conference on Programming
	Language Design and Implementation (PLDI), White Plains, New York,
	June 20-22, 1990. SIGPLAN Notices 25(6) (June 1990) 

	William D. Clinger: How to Read Floating-Point Numbers Accurately.
	pp. 92-101 

I'm still looking for a machine-readable version of this paper, or of the
code.

Greetings,

	Jens.
--
··········@acm.org                  phone:+49-7031-14-7698 (HP TELNET 778-7698)
                                      fax:+49-7031-14-7351
PGP:       06 04 1C 35 7B DC 1F 26  As the air to a bird, or the sea to a fish,
0x555DA8B5 BB A2 F0 66 77 75 E1 08  so is contempt to the contemptible. [Blake]