home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.misc:3072 comp.unix.programmer:4046 comp.unix.questions:9652
- Newsgroups: comp.unix.misc,comp.unix.programmer,comp.unix.questions
- Path: sparky!uunet!elroy.jpl.nasa.gov!sdd.hp.com!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!sunova!falcon!rupen
- From: rupen@falcon.ssc.gov (Rupen Sheth)
- Subject: Is there a strtof() function (str to float)?
- Message-ID: <1992Jul31.201313.11253@sunova.ssc.gov>
- Originator: rupen@falcon
- Sender: usenet@sunova.ssc.gov (News Admin)
- Nntp-Posting-Host: falcon.ssc.gov
- Organization: Superconducting Super Collider Laboratory, Dallas
- Date: Fri, 31 Jul 1992 20:13:13 GMT
- Lines: 37
-
- Hi:
- Env: Sun Sparc.
-
- In trying to convert a string to a floating number, I don't always
- get the exact value.
-
- For example:
- float value;
- char str[10]; /* Say, str = "+0.02" */
-
- sscanf(str, "%g", &value);
- OR
- sscanf(str, "%f", &value);
-
- value is 0.0199999995529651642
-
- Is there a strtof() function that can convert a string to a float?
- If not, is there another way I can convert a string %f or %g to a
- float without these rounding errors?
-
- I am sure there is a way around this that I am not aware of.
- Please help !!!
- Respond by email to the address below.
-
- Thank you.
- ---
- Rupen Sheth
- -------------------------------------------------------------------------------
- Superconducting Super Collider Laboratory EMail: rupen@falcon.ssc.gov
- 2550 Beckleymeade Ave. MS 4004 Phone: (214) 708-3344
- Dallas, TX 75237 FAX: (214) 708-4827
- -------------------------------------------------------------------------------
- --
- Rupen Sheth
- -------------------------------------------------------------------------------
- Superconducting Super Collider Laboratory EMail: rupen@falcon.ssc.gov
- 2550 Beckleymeade Ave. MS 4004 Phone: (214) 708-3344
-