[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Using numbers as float
- From: Mark Edgar <medgar@...>
- Date: Thu, 29 Jun 2006 12:41:14 -0700
Jose Marin wrote:
I'm compiling Lua to use floats, altering the file
The macro lua_str2number uses strtod (returns a
I could cast to (float)strtod, but I'm worried abou
Is there some fast way of convert a string to a float?
strtod() works just fine; no cast is required:
float x = strtod("3.2", NULL);
You probably won't find anything faster, as your implementation's
strtod() is probably written in nice fast assembly.
If you have a C99 conforming system, you can use strtof() instead. I
don't know that you'll notice a performance difference between strtod()