IonicWind Software

IWBasic => General Questions => Topic started by: talun on March 12, 2007, 10:35:30 AM

Title: about _atof
Post by: talun on March 12, 2007, 10:35:30 AM
Hi to all,
I need to convert strings in exponential format  and I have noticed that the val () function  it is not able to perform this conversion. I have tried with the function _atof () of the crtdll.lib (see the example below) and everything seems to work fine but I am not sure if I am doing something of wrong.


declare cdecl extern _atof(mystr as string),double

string test
double number

test = "4.94171e+006"
number = _atof(test)
print number
print val(test)

do : until inkey$ <> ""
end

Can anyone help me?

Thanks!

Sergio
Title: Re: about _atof
Post by: Parker on March 12, 2007, 07:02:52 PM
You need to use SETPRECISION to change the precision that PRINT prints.
Title: Re: about _atof
Post by: talun on March 13, 2007, 02:17:13 AM
Parker, many thanks for your reply. I know SETPRECISION, but what I would to know if to use the function atof as I have done, can create problems in my programs (for example, the atof declaration is correct?)

Thanks!

Sergio
Title: Re: about _atof
Post by: Ionic Wind Support Team on March 13, 2007, 02:16:31 PM
Looks correct to me ;)
Title: Re: about _atof
Post by: talun on March 14, 2007, 01:51:57 AM
Paul, thank you for your reply.
Can you suggest to me where to find the contents and the declarations of the crtdll lib?? (I've browsed the MSDN site with poor results)

Thanks

Sergio
Title: Re: about _atof
Post by: Ionic Wind Support Team on March 14, 2007, 09:29:25 AM
http://msdn2.microsoft.com/en-us/library/634ca0c2(VS.80).aspx

Some functions may or may not have an extra underscore prepended to them.  If you get an error from the linker that is the first place to look.  Microsoft likes to deviate from the C standard, sometimes between different VC library versions ;)

Of course just searching Google, for a specific funciton name like sprintf, will bring up hundreds of references.  Here's one that is used by Linux programmers, the C library is cross platform so the functions work the same:

http://www.phim.unibe.ch/comp_doc/c_manual/C/FUNCTIONS/funcref.htm#headers

Paul.
Title: Re: about _atof
Post by: talun on March 14, 2007, 11:00:16 AM
Thanks!   :D

Bye

Sergio