Overview
Features
Download
Documentation
Community
Add-Ons & Services

NumberParser

Please post support and help requests here.

NumberParser

Postby Patrock » 30 Sep 2009, 22:56

Hello,

I'm new to this forum, so hello everyone. I'm using Poco for some Mixed-Reality-Applications and am very happy with it.

One problem i discovered is the Configuration-System/NumberParser when in release mode with a certain combination of libraries.

I can't read in double values.

In the file NumberParser.cpp , line 165+
Code: Select all
double NumberParser::parseFloat(const std::string& s)
{
   double result;
   if (tryParseFloat(s, result))
      return result;
   else
      throw SyntaxException("Not a valid floating-point number", s);
}

   
bool NumberParser::tryParseFloat(const std::string& s, double& value)
{
   char temp;
   return std::sscanf(s.c_str(), "%lf%c", &value, &temp) == 1;  <---------
}


I get problems in the marked line. I could debug tthis and everything seems fine. The string is "0.05" for example (but the number is irrelevant)
VAlue is 0 after the call and temp is '.'. So there is some error in the scanning. the number is parsed till the dot and then everything is discarded. the result gets 2 and so an Exception is thrown.

I couldn't remake this error in my tests without poco. What could this be ?


Some libraries i include when the error occurs.
ws2_32.lib
or
libmx/libmex from Simulink.


i have replaced the code with
Code: Select all
      std::stringstream ss(s);
   ss  >> value;
   return 1;


and everything works fine, but this couldn't be the solution.

OK, that's it, thx in advance for your help, perhaps someone experienced related errors ?

Greets,

Patrock
Patrock
 
Posts: 1
Joined: 30 Sep 2009, 22:46

Re: NumberParser

Postby guenter » 01 Oct 2009, 06:23

Looks like a locale issue to me. Maybe one of the other libraries is changing the current C locale (LC_NUMERIC) to one that expects a comma as decimal point.
guenter
 
Posts: 1110
Joined: 11 Jul 2006, 16:27
Location: Austria


Return to Support

Who is online

Users browsing this forum: No registered users and 2 guests

cron