Author Topic: parseFloat()  (Read 3176 times)

dbell

  • Newbie
  • *
  • Posts: 44
parseFloat()
« on: December 15, 2013, 10:41:11 am »
I'm building callouses from banging my forehead on the keyboard, trying to figure out if there is a way to apply stream.parseFloat() to a string!

It doesn't appear to be directly possible, but I have no idea which inherits from whom, and can't find anything other than the very skimpy Arduino Reference pages on Serial and Stream functions.
I'd read the source code, and copy it if necessary, but I can't find that, either. All my (Win7) PC search will turn up is the Reference page...

Any suggestions?

Thanks!
Dave

dbell

  • Newbie
  • *
  • Posts: 44
Re: parseFloat()
« Reply #1 on: December 15, 2013, 11:51:35 am »
OK, ignore the comment about not finding the source code.
Windoze reported no matches after 5 minutes, but an hour later, there's a screenful!

Still wonder if there's a version applicable to a string...

MichaelMeissner

  • Full Member
  • ***
  • Posts: 166
Re: parseFloat()
« Reply #2 on: December 15, 2013, 12:09:02 pm »
You might try the C/C++ standard function strtod: http://www.cplusplus.com/reference/cstdlib/strtod/

dbell

  • Newbie
  • *
  • Posts: 44
Re: parseFloat()
« Reply #3 on: December 15, 2013, 02:08:31 pm »
Another winner! 

#include <stdlib.h>
and
strtof(buf, NULL)  // strtod() might have worked, but I believe it returns a full-length double

Thanks, Michael!

Dave