Path: utzoo!censor!geac!torsqnt!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!usc!apple!well!oster From: oster@well.sf.ca.us (David Phillip Oster) Newsgroups: comp.sys.mac.programmer Subject: Re: ANSI library in THINK C 4.0 Message-ID: <16615@well.sf.ca.us> Date: 11 Mar 90 12:54:09 GMT References: <90068.135735CXT105@psuvm.psu.edu> Reply-To: oster@well.UUCP (David Phillip Oster) Organization: Whole Earth 'Lectronic Link, Sausalito, CA Lines: 33 In article <90068.135735CXT105@psuvm.psu.edu> cxt105@psuvm.psu.edu writes: >Does anyone know how to build a library containing the floating-point sprintf() >function, so that you don't have to include the entire ANSI library just to >get that one feature? Remember that every Mac has SANE built in. Check your SANE Numerics manual for details, and remember that this is THINK C v4, but here is what I use: #include /* StringToFloat - convert a string to a floating point number. */ Boolean StringToFloat(s, fp)StringPtr s;float *fp;{ short index; double ff; Decimal d; DecForm df; Boolean prefix; index = 1; Str2Dec(s, &index, &d, &prefix); df.style = FIXEDDECIMAL; df.digits = d.sig.length; fp68k(&df, &d, &ff, FOD2B); *fp = ff; return index != 1; } How script manager compatible is this? Is there a preferred way that will format numbers correctly with full script manager compatibility? (Remember that in some countries, decimal point is spelled ","). -- -- David Phillip Oster - Note new address. Old one has gone Bye Bye. -- oster@well.sf.ca.us = {backbone}!well!oster