April 25, 2024, 07:21:23 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


about _atof

Started by talun, March 12, 2007, 10:35:30 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

talun

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

Parker

You need to use SETPRECISION to change the precision that PRINT prints.

talun

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

Ionic Wind Support Team

Ionic Wind Support Team

talun

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

Ionic Wind Support Team

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.
Ionic Wind Support Team

talun

Thanks!   :D

Bye

Sergio